From 17166181cb7409d0aa43ac61cd146be0e6a5eec8 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sat, 6 Jan 2024 23:29:14 -0600 Subject: [PATCH] Update dsmon.sh --- dsmon.sh | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/dsmon.sh b/dsmon.sh index ac429f2..e6e7c2f 100755 --- a/dsmon.sh +++ b/dsmon.sh @@ -142,23 +142,25 @@ CHECK(){ nc_count=0; completed=false; scanstart=$(date +%s) until [ "${completed}" == "true" ]; do - for host in /tmp/dscheck.*.done >/dev/null 2>&1; do - NTS=$(grep -oP '(?<=dscheck.).*?(?=.done)' <<< "${nodestatus}") - if [ "${NTS}" != "*" ]; then - hoststatus=$(cat /tmp/dscheck.${NTS}.results) - [ "${hoststatus}" != "" ] && echo -e "${hoststatus}" - rm -f /tmp/dscheck.${NTS}.* - ((nc_count++)) + if [ -f /tmp/dscheck.*.done ]; then + for host in /tmp/dscheck.*.done >/dev/null 2>&1; do + NTS=$(grep -oP '(?<=dscheck.).*?(?=.done)' <<< "${nodestatus}") + if [ "${NTS}" != "*" ]; then + hoststatus=$(cat /tmp/dscheck.${NTS}.results) + [ "${hoststatus}" != "" ] && echo -e "${hoststatus}" + rm -f /tmp/dscheck.${NTS}.* + ((nc_count++)) + fi + done + if [ $(($(date +%s)-scanstart)) -gt 600 ]; then + SENDNOTICE "NMG Scan Stuck" "DSmon Check scan has been running for 10mins, klling all bash...." 1 + killall bash + exit 1 + fi + if [ ${nc_count} -eq ${#hostnames_sort[@]} ]; then + completed=true + break fi - done - if [ $(($(date +%s)-scanstart)) -gt 600 ]; then - SENDNOTICE "NMG Scan Stuck" "DSmon Check scan has been running for 10mins, klling all bash...." 1 - killall bash - exit 1 - fi - if [ ${nc_count} -eq ${#hostnames_sort[@]} ]; then - completed=true - break fi sleep 1s done