Update install-dsmon.sh
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user