Update install-dsmon.sh
This commit is contained in:
@@ -24,7 +24,17 @@ if [ -d "/opt/idssys/dsmon" ]; then
|
||||
esac
|
||||
fi
|
||||
|
||||
do_with_root $APTFUNC install wget curl git mailutils mariadb-client bc
|
||||
[ "$(ip route | awk '/default/ { print $5 }')" == "link" ] && RNIP=$(ip addr show $(ip route | awk '/1 dev eth0/ { print $5; exit }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) ||
|
||||
RNIP=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1)
|
||||
|
||||
if [[ "${RNIP}" == "10.6.1"* ]]; then
|
||||
mysqlcmd=mysql
|
||||
else
|
||||
mysqlcmd=mariadb
|
||||
fi
|
||||
|
||||
|
||||
do_with_root $APTFUNC install wget curl git mailutils bc
|
||||
|
||||
do_with_root set -eu
|
||||
do_with_root git clone https://git.schroedercity.com/voltron/dsmon.git /opt/idssys/dsmon
|
||||
@@ -154,9 +164,9 @@ if [ "${SET_SERVERMONID}" = "new" ]; then
|
||||
|
||||
if [ "${mysqlip}" != "" ]; then
|
||||
QRY="USE servermonitor; INSERT INTO hosts (\`host\`,\`hostname\`,\`ip\`,\`limits\`) VALUES ('${ADD_SERVERNAME}','${ADD_SERVERHOSTNAME}','${SERVERIPS// /}','${thresholdlog[@]}');"
|
||||
mariadb --skip-ssl -h ${mysqlip} -u sysmoninsert -psysmoninsert -e "${QRY}"
|
||||
${mysqlcmd} --skip-ssl -h ${mysqlip} -u sysmoninsert -psysmoninsert -e "${QRY}"
|
||||
QRY="USE servermonitor; SELECT id FROM hosts WHERE host='${ADD_SERVERNAME}';"
|
||||
SET_SERVERMONID=`mariadb --skip-ssl -h ${mysqlip} -u sysmoninsert -psysmoninsert -e "${QRY}"`
|
||||
SET_SERVERMONID=`${mysqlcmd} --skip-ssl -h ${mysqlip} -u sysmoninsert -psysmoninsert -e "${QRY}"`
|
||||
else
|
||||
echo -e "${idsCL[Red]}Could not connect to MySQL${idsCL[Default]}"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user