From 86b309e1b65fa1c63aa5d5663cbe8c2f43be2452 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Thu, 6 Jul 2023 20:25:48 -0500 Subject: [PATCH] Update install-dsmon.sh --- install-dsmon.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/install-dsmon.sh b/install-dsmon.sh index 78b0009..82b9922 100755 --- a/install-dsmon.sh +++ b/install-dsmon.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -# Wrapper script for install, for easier execution via URL. if [ -d /opt/idssys/defaults ]; then source /opt/idssys/defaults/colors.inc @@ -107,6 +106,7 @@ echo "Test Alert" | mail -r DSMon_$(hostname -s)@scity.us -s "Test" $SET_ALERTEM echo -e "${idsCL[Yellow]}Adding task to crontab... ${idsCL[Default]}" sleep 1s (crontab -l ; echo "$(($RANDOM % 15)) */1 * * * /usr/local/bin/dsmon hdd >/dev/null 2>&1")| crontab - +sleep 1s (crontab -l ; echo "*/5 * * * * /usr/local/bin/dsmon sys >/dev/null 2>&1")| crontab - @@ -140,18 +140,22 @@ if [ "${SET_SERVERMONID}" = "new" ]; then thresholdlog+=("${KEY}:${THRESHOLD[$KEY]}") done - if [ "$(CHECK_HOST 10.10.10.50)" != "false" ]; then + if [ "$(CHECK_HOST 10.10.1.50)" != "false" ]; then mysqlip=10.10.1.50 - elif [ "$(CHECK_HOST 100.100.55.1)" != "false" ]; then + elif [ "$(CHECK_HOST 100.100.5.2)" != "false" ]; then mysqlip=100.100.5.2 else - nmip= + mysqlip= + fi + + if [ "${mysqlip}" != "" ]; then + QRY="USE servermonitor; INSERT INTO hosts (\`host\`,\`hostname\`,\`ip\`,\`limits\`) VALUES ('${ADD_SERVERNAME}','${ADD_SERVERHOSTNAME}','${SERVERIPS// /}','${thresholdlog[@]}');" + mysql -h ${mysqlip} --user=sysmoninsert --password=sysmoninsert -e "${QRY}" + QRY="USE servermonitor; SELECT id FROM hosts WHERE host='${ADD_SERVERNAME}';" + SET_SERVERMONID=`mysql -h ${mysqlip} --user=sysmoninsert --password=sysmoninsert -e "${QRY}"` + else + echo -e "${idsCL[Red]}Could not connect to MySQL${idsCL[Default]}" fi - - QRY="USE servermonitor; INSERT INTO hosts (\`host\`,\`hostname\`,\`ip\`,\`limits\`) VALUES ('${ADD_SERVERNAME}','${ADD_SERVERHOSTNAME}','${SERVERIPS// /}','${thresholdlog[@]}');" - mysql -h ${mysqlip} --user=sysmoninsert --password=sysmoninsert -e "${QRY}" - QRY="USE servermonitor; SELECT id FROM hosts WHERE host='${ADD_SERVERNAME}';" - SET_SERVERMONID=`mysql -h ${mysqlip} --user=sysmoninsert --password=sysmoninsert -e "${QRY}"` echo -en "${idsCL[LightGreen]}Server successfully added, it was given ID# " echo -e ${SET_SERVERMONID//id