Update dsmon.sh
This commit is contained in:
28
dsmon.sh
28
dsmon.sh
@@ -287,6 +287,33 @@ RUNCMD(){
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GETCRONTABS(){
|
||||||
|
ssh root@10.10.1.51 crontab -l | ssh -tq root@10.10.10.50 'cat > /opt/idssys/nodemgmt/crontabs/`hostname`.crontab'
|
||||||
|
|
||||||
|
declare -A host_ip
|
||||||
|
declare -A host_name
|
||||||
|
|
||||||
|
while read hostid hostname hostip hostlimits; do
|
||||||
|
if [ "$hostid" != "id" ]; then
|
||||||
|
host_ip[${hostid}]=$(echo $hostip | cut -d ";" -f1)
|
||||||
|
host_name[${hostid}]=$hostname
|
||||||
|
fi
|
||||||
|
done <<< $(MYSQL_PWD="sysmoninsert" mysql -h mysqldb.scity.us -P 3306 -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0 ORDER BY host ASC")
|
||||||
|
|
||||||
|
for hostid in "${!host_ip[@]}"; do
|
||||||
|
checkhost=$(CHECK_HOST ${host_ip[$hostid]})
|
||||||
|
if [ "${checkhost}" != "false" ]; then
|
||||||
|
if ! root@${host_ip[$hostid]} command -v sshpass > /dev/null; then
|
||||||
|
ssh -tq root@${host_ip[$hostid]} apt install -yq sshpass > /dev/null 2>&1
|
||||||
|
fi
|
||||||
|
echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${host_name[$hostid]} - Gathering crontabs${idsCL[Default]}${idsST[Reset]}"
|
||||||
|
ssh -tq root@${host_ip[$hostid]} crontab -l | ssh -tq root@10.10.10.50 'cat > /opt/idssys/nodemgmt/crontabs/`hostname`.crontab'
|
||||||
|
else
|
||||||
|
echo -e "${idsST[Bold]}${idsCL[Red]} ${host_name[$hostid]} - Timeout${idsCL[Default]}${idsST[Reset]}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
SENDNOTICE(){
|
SENDNOTICE(){
|
||||||
[ "${PUSHOVER_APP_TOKEN}" != "" ] && PUSH_TO_MOBILE "${2}
|
[ "${PUSHOVER_APP_TOKEN}" != "" ] && PUSH_TO_MOBILE "${2}
|
||||||
|
|
||||||
@@ -299,6 +326,7 @@ $(date)" "${1}" ${3} &
|
|||||||
case $action in
|
case $action in
|
||||||
check) CHECK ${2};;
|
check) CHECK ${2};;
|
||||||
setupssh) SETUPSSH;;
|
setupssh) SETUPSSH;;
|
||||||
|
get-crontabs) GETCRONTABS;;
|
||||||
run) RUN ${2};;
|
run) RUN ${2};;
|
||||||
runcmd) RUNCMD ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11};;
|
runcmd) RUNCMD ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11};;
|
||||||
update);;
|
update);;
|
||||||
|
|||||||
Reference in New Issue
Block a user