From 00b23dc94121c2f9b6ff5be34ed7eaaa0bb1960b Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Fri, 26 Jan 2024 10:04:55 -0600 Subject: [PATCH] Update dsmon.sh --- dsmon.sh | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/dsmon.sh b/dsmon.sh index cb1a2c2..c12b7a7 100755 --- a/dsmon.sh +++ b/dsmon.sh @@ -340,31 +340,16 @@ SETUPSSH(){ RUNCMD(){ start=`date +%s` - declare -A host_ip - declare -A host_name - rm -f /tmp/.dsmon.runcmd.* + ncount=0 while read hostid hostname hostip hostlimits; do if [ "${hostname}" != "host" ]; then - host_ip[${hostid}]=$(echo ${hostip} | cut -d ";" -f1) - host_name[${hostid}]="${hostname}" + RUNCMD_SUB $(echo ${hostip} | cut -d ";" -f1) ${hostname} ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} & + ((ncount++)) 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") - ncount=0 - for hostid in "${!host_ip[@]}"; do - # 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 - RUNCMD_SUB ${host_ip[$hostid]} ${host_name[$hostid]} ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} & - ((ncount++)) - done - nc_count=0; completed=false until [ "${completed}" == "true" ]; do for nodecmd in /tmp/.dsmon.runcmd.*.done; do @@ -375,14 +360,15 @@ RUNCMD(){ # [ "${nodecmd_output}" != "" ] && echo -e "${nodecmd_output}\n" # fi # rm -f ${nodecmd} + echo ${nodecmd} ((nc_count++)) done - echo "${ncount} - ${nc_count}" + echo "${ncount} - ${nc_count}\n" if [ ${nc_count} -eq ${ncount} ]; then completed=true break fi - sleep 1s + sleep 2s done echo