From f33ced8382fab32c8e2d343553e1f497fbd574bc Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Thu, 6 Jul 2023 20:16:51 -0500 Subject: [PATCH] Update install-dsmon.sh --- install-dsmon.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/install-dsmon.sh b/install-dsmon.sh index b16f898..0176689 100755 --- a/install-dsmon.sh +++ b/install-dsmon.sh @@ -9,7 +9,6 @@ else source /dev/stdin <<< "$(curl -sL http://go.scity.us/defaultinc)" fi - echo "" echo -e "${idsCL[LightGreen]}DiskSpace-Monitor Installation Script${idsCL[Default]}" echo "" @@ -108,7 +107,6 @@ 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 - @@ -141,11 +139,19 @@ if [ "${SET_SERVERMONID}" = "new" ]; then for KEY in "${!THRESHOLD[@]}"; do thresholdlog+=("${KEY}:${THRESHOLD[$KEY]}") done + + if [ "$(CHECK_HOST 10.10.10.50)" != "false" ]; then + mysqlip=10.10.1.50 + elif [ "$(CHECK_HOST 100.100.55.1)" != "false" ]; then + mysqlip=100.100.5.2 + else + nmip= + fi QRY="USE servermonitor; INSERT INTO hosts (\`host\`,\`hostname\`,\`ip\`,\`limits\`) VALUES ('${ADD_SERVERNAME}','${ADD_SERVERHOSTNAME}','${SERVERIPS// /}','${thresholdlog[@]}');" - mysql -h mysqldb.scity.us -P 6033 --user=sysmoninsert --password=sysmoninsert -e "${QRY}" + mysql -h ${mysqlip} -P 3306 --user=sysmoninsert --password=sysmoninsert -e "${QRY}" QRY="USE servermonitor; SELECT id FROM hosts WHERE host='${ADD_SERVERNAME}';" - SET_SERVERMONID=`mysql -h mysqldb.scity.us -P 6033 --user=sysmoninsert --password=sysmoninsert -e "${QRY}"` + SET_SERVERMONID=`mysql -h ${mysqlip} -P 3306 --user=sysmoninsert --password=sysmoninsert -e "${QRY}"` echo -en "${idsCL[LightGreen]}Server successfully added, it was given ID# " echo -e ${SET_SERVERMONID//id