Update dsmon.sh

This commit is contained in:
2025-06-01 21:45:28 -05:00
parent 1377020e66
commit 4ac9b106d9

View File

@@ -133,33 +133,34 @@ CHECK(){
#for hostid in "${!host_ip[@]}"; do #for hostid in "${!host_ip[@]}"; do
for hostname in "${hostnames_sort[@]}"; do for hostname in "${hostnames_sort[@]}"; do
until [ $(ls /tmp/dscheck.*.running 2>/dev/null | wc -l) -lt 6 ]; do tmp=tmp; done until [ $(ls /tmp/dscheck.*.running 2>/dev/null | wc -l) -lt 6 ]; do tmp=tmp; done
RUN_CHECK ${hostname} > /tmp/dscheck.${hostname}.results 2>/dev/null & # RUN_CHECK ${hostname} > /tmp/dscheck.${hostname}.results 2>/dev/null &
RUN_CHECK
done done
[ "${1}" != "report" ] && echo -e "${idsCL[LightGreen]}Done${idsCL[Default]}\n" [ "${1}" != "report" ] && echo -e "${idsCL[LightGreen]}Done${idsCL[Default]}\n"
nc_count=0; completed=false; scanstart=$(date +%s) # nc_count=0; completed=false; scanstart=$(date +%s)
until [ "${completed}" == "true" ]; do # until [ "${completed}" == "true" ]; do
# until [ $(ls /tmp/dscheck.*.done 2>/dev/null | wc -l) -gt 0 ]; do tmp=tmp; done # # until [ $(ls /tmp/dscheck.*.done 2>/dev/null | wc -l) -gt 0 ]; do tmp=tmp; done
for host in /tmp/dscheck.*.done; do # for host in /tmp/dscheck.*.done; do
NTS=$(grep -oP '(?<=dscheck.).*?(?=.done)' <<< "${host}") # NTS=$(grep -oP '(?<=dscheck.).*?(?=.done)' <<< "${host}")
if [ "${NTS}" != "*" ]; then # if [ "${NTS}" != "*" ]; then
hoststatus=$(cat /tmp/dscheck.${NTS}.results) # hoststatus=$(cat /tmp/dscheck.${NTS}.results)
[ "${hoststatus}" != "" ] && echo -e "${hoststatus}" # [ "${hoststatus}" != "" ] && echo -e "${hoststatus}"
rm -f /tmp/dscheck.${NTS}.* # rm -f /tmp/dscheck.${NTS}.*
((nc_count++)) # ((nc_count++))
fi # fi
done # done
if [ $(($(date +%s)-scanstart)) -gt 300 ]; then # if [ $(($(date +%s)-scanstart)) -gt 300 ]; then
SENDNOTICE "DSmon Scan Stuck" "DSmon Check scan has been running for 10mins, klling all bash...." 1 # SENDNOTICE "DSmon Scan Stuck" "DSmon Check scan has been running for 10mins, klling all bash...." 1
killall bash # killall bash
exit 1 # exit 1
fi # fi
if [ ${nc_count} -eq ${#hostnames_sort[@]} ]; then # if [ ${nc_count} -eq ${#hostnames_sort[@]} ]; then
completed=true # completed=true
break # break
fi # fi
sleep 1s # sleep 1s
done # done
end=`date +%s`; runtime=$((end-start)); echo -e "\nScript Runtime: ${runtime}" end=`date +%s`; runtime=$((end-start)); echo -e "\nScript Runtime: ${runtime}"
echo echo