Update dsmon.sh

This commit is contained in:
2024-03-12 09:57:50 -05:00
parent 454ed02b70
commit 670d0e3761

View File

@@ -338,39 +338,39 @@ RUNCMD(){
ncount=0 ncount=0
while read hostid hostname hostip hostlimits; do while read hostid hostname hostip hostlimits; do
if [ "${hostname}" != "host" ]; then if [ "${hostname}" != "host" ]; then
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} & 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++)) ((ncount++))
fi fi
done <<< $(MYSQL_PWD="sysmoninsert" mysql -h ${mysqlip} -P 3307 -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0 ORDER BY host ASC") done <<< $(MYSQL_PWD="sysmoninsert" mysql -h ${mysqlip} -P 3307 -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0 ORDER BY host ASC")
nc_count=0; lcount=0; completed=false # nc_count=0; lcount=0; completed=false
until [ "${completed}" == "true" ]; do # until [ "${completed}" == "true" ]; do
for nodecmd in /tmp/.dsmon.runcmd.*.done; do # for nodecmd in /tmp/.dsmon.runcmd.*.done; do
# HOST=$(grep -oP '(?<=runcmd.).*?(?=.done)' <<< "${nodecmd}") # # HOST=$(grep -oP '(?<=runcmd.).*?(?=.done)' <<< "${nodecmd}")
# if [ "${HOST}" != "*" ]; then # # if [ "${HOST}" != "*" ]; then
# # if [[ "${nodecmd}" != *"*"* ]]; then
# # nodecmd_output=$(cat ${nodecmd})
# # [ "${nodecmd_output}" != "" ] && echo -e "${nodecmd_output}\n"
# # fi
# # rm -f ${nodecmd}
#
# if [[ "${nodecmd}" != *"*"* ]]; then # if [[ "${nodecmd}" != *"*"* ]]; then
# nodecmd_output=$(cat ${nodecmd}) # nodecmd_output=$(cat ${nodecmd})
# [ "${nodecmd_output}" != "" ] && echo -e "${nodecmd_output}\n" # [ "${nodecmd_output}" != "" ] && echo -e "${nodecmd_output}\n"
# fi
# rm -f ${nodecmd} # rm -f ${nodecmd}
# ((nc_count++))
if [[ "${nodecmd}" != *"*"* ]]; then # fi
nodecmd_output=$(cat ${nodecmd}) # done
[ "${nodecmd_output}" != "" ] && echo -e "${nodecmd_output}\n" # if [ ${nc_count} -eq ${ncount} ]; then
rm -f ${nodecmd} # echo -e "${idsCL[LightGreen]}Complete, the command was ran on all nodes\n"
((nc_count++)) # completed=true
fi # break
done # fi
if [ ${nc_count} -eq ${ncount} ]; then # [ ${lcount} -ne ${nc_count} ] && echo -e "${idsCL[Yellow]}${nc_count} of ${ncount} completed ...\n"
echo -e "${idsCL[LightGreen]}Complete, the command was ran on all nodes\n" # lcount=${nc_count}
completed=true #
break # sleep 2s
fi # done
[ ${lcount} -ne ${nc_count} ] && echo -e "${idsCL[Yellow]}${nc_count} of ${ncount} completed ...\n"
lcount=${nc_count}
sleep 2s
done
echo echo
end=`date +%s` end=`date +%s`