From d47ad7f29f1a5ed25f17346f0fedccb4b52175aa Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Fri, 26 Jan 2024 09:54:23 -0600 Subject: [PATCH] Update dsmon.sh --- dsmon.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dsmon.sh b/dsmon.sh index 38404ee..eb4e5a7 100755 --- a/dsmon.sh +++ b/dsmon.sh @@ -366,13 +366,14 @@ RUNCMD(){ nc_count=0; completed=false until [ "${completed}" == "true" ]; do for nodecmd in /tmp/.dsmon.runcmd.*.done; do - HOST=$(grep -oP '(?<=runcmd.).*?(?=.done)' <<< "${nodecmd}") - if [ "${HOST}" != "*" ]; then + # HOST=$(grep -oP '(?<=runcmd.).*?(?=.done)' <<< "${nodecmd}") + # if [ "${HOST}" != "*" ]; then + if [[ "${nodecmd}" != *"*"* ]]; then nodecmd_output=$(cat ${nodecmd}) [ "${nodecmd_output}" != "" ] && echo -e "${nodecmd_output}\n" - rm -f ${nodecmd} - ((nc_count++)) fi + rm -f ${nodecmd} + ((nc_count++)) done if [ ${nc_count} -eq ${ncount} ]; then completed=true @@ -393,7 +394,9 @@ RUNCMD_SUB(){ tmpfile=/tmp/.dsmon.runcmd.${host// /-} touch ${tmpfile}.running echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${host} - Running command: ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} ${21} ${22}${idsCL[Default]}${idsST[Reset]}" >> ${tmpfile}.running - if ! ssh -tq -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${ip} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} ${21} ${22} >> ${tmpfile}.running ; then + if ssh_output=$(ssh -tq -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${ip} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} ${21} ${22}) ; then + echo -e "${ssh_output}" >> ${tmpfile}.running + else echo -e "${idsST[Bold]}${idsCL[Red]} ${host} - Timeout${idsCL[Default]}${idsST[Reset]}" >> ${tmpfile}.running fi mv ${tmpfile}.running ${tmpfile}.done