From c6a9e3a9edfbdf6fb2e9cde1489a7d8237b7cf6c Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sat, 6 Jan 2024 23:34:07 -0600 Subject: [PATCH] Update dsmon.sh --- dsmon.sh | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/dsmon.sh b/dsmon.sh index 252f7cd..5e87a0d 100755 --- a/dsmon.sh +++ b/dsmon.sh @@ -142,25 +142,24 @@ CHECK(){ nc_count=0; completed=false; scanstart=$(date +%s) until [ "${completed}" == "true" ]; do - if [ -f /tmp/dscheck.*.done ]; then - for host in /tmp/dscheck.*.done; 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 + until [ $(ls /tmp/dscheck.*.done 2>/dev/null | wc -l) -gt 0 ]; do tmp=tmp; done + for host in /tmp/dscheck.*.done; 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 sleep 1s done