From fe15773955f833505c246b4e4a45a011a7e69190 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Fri, 26 Jan 2024 09:25:42 -0600 Subject: [PATCH] update --- defaults.inc | 2 +- dsmon.sh | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/defaults.inc b/defaults.inc index b9a9618..7f0832d 100755 --- a/defaults.inc +++ b/defaults.inc @@ -5,7 +5,7 @@ VERS=2.3.12-01262024 DS_FOLDER=/opt/idssys/dsmon DS_CRONTAB_FOLDER=/opt/idssys/nodemgmt/crontabs -noheader=" gettsip-node get-crontab update report updatenodes " +noheader=" gettsip-node get-crontabs get-crontab update report updatenodes " if [ "${NM_NODEMANAGER}" != "" ]; then diff --git a/dsmon.sh b/dsmon.sh index 9c75e2b..175ea09 100755 --- a/dsmon.sh +++ b/dsmon.sh @@ -343,7 +343,7 @@ RUNCMD(){ declare -A host_name while read hostid hostname hostip hostlimits; do - if [ "$hostid" != "id" ]; then + if [ "${hostname}" != "host" ]; then host_ip[${hostid}]=$(echo $hostip | cut -d ";" -f1) host_name[${hostid}]=$hostname fi @@ -372,20 +372,22 @@ RUNCMD(){ declare -A host_name while read hostid hostname hostip hostlimits; do - if [ "$hostid" != "id" ]; then + if [ "${hostname}" != "host" ]; then host_ip[${hostid}]=$(echo $hostip | cut -d ";" -f1) host_name[${hostid}]=$hostname fi done <<< $(MYSQL_PWD="sysmoninsert" mysql -h ${mysqlip} -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 + # checkhost=$(CHECK_HOST ${host_ip[$hostid]}) + # if [ "${checkhost}" != "false" ]; then echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${host_name[$hostid]} - Running command: ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20}${idsCL[Default]}${idsST[Reset]}" - ssh -tq -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${host_ip[$hostid]} ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} - else - echo -e "${idsST[Bold]}${idsCL[Red]} ${host_name[$hostid]} - Timeout${idsCL[Default]}${idsST[Reset]}" - fi + if [ ! ssh -tq -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${host_ip[$hostid]} ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} ]; then + echo -e "${idsST[Bold]}${idsCL[Red]} ${host_name[$hostid]} - Timeout${idsCL[Default]}${idsST[Reset]}" + fi + # else + # echo -e "${idsST[Bold]}${idsCL[Red]} ${host_name[$hostid]} - Timeout${idsCL[Default]}${idsST[Reset]}" + # fi done echo @@ -402,7 +404,7 @@ UPDATENODES(){ declare -A host_name while read hostid hostname hostip hostlimits; do - if [ "$hostid" != "id" ]; then + if [ "${hostname}" != "host" ]; then echo -e "${idsCL[LightCyan]}Updating DSMON on '${hostname}'${idsCL[Default]}" ssh -tq -o ConnectTimeout=3 -o ConnectionAttempts=1 root@$(echo $hostip | cut -d ";" -f1) "dsmon update" echo @@ -461,7 +463,7 @@ GETCRONTABS(){ checkhost=$(CHECK_HOST ${host_ip[$hostid]}) if [ "${checkhost}" != "false" ]; then # echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${host_name[$hostid]} - Gathering Crontabs ... ${idsCL[Default]}${idsST[Reset]}" - ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 -t root@${host_ip[$hostid]} dsmon get-crontab ${rtpsswd} & + ssh -tq -o ConnectTimeout=3 -o ConnectionAttempts=1 -t root@${host_ip[$hostid]} dsmon get-crontab ${rtpsswd} & else echo -e "${idsST[Bold]}${idsCL[Red]} ${host_name[$hostid]} - Timeout${idsCL[Default]}${idsST[Reset]}" fi