Update dsmon.sh

This commit is contained in:
2024-01-06 23:19:07 -06:00
parent 3a37c5e96a
commit 8a88fa1378

View File

@@ -127,6 +127,38 @@ 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
RUN_CHECK ${hostname} > /tmp/dscheck.${hostname}.results 2>/dev/null &
done
nc_count=0; completed=false; scanstart=$(date +%s)
until [ "${completed}" == "true" ]; do
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
end=`date +%s`; runtime=$((end-start)); echo -e "\nScript Runtime: ${runtime}"
echo
}
RUN_CHECK(){
hostname=${1}
hostid=${host_ids[$hostname]} hostid=${host_ids[$hostname]}
# if [ "${1}" != "report" ]; then # if [ "${1}" != "report" ]; then
echo -e "${idsST[Bold]}"; DIVIDER false lightCyan 85 echo -e "${idsST[Bold]}"; DIVIDER false lightCyan 85
@@ -253,7 +285,7 @@ CHECK(){
# echo -e "${host_name[$hostid]} - (${host_ip[$hostid]})\n\n${DRIVE} : ${DRIVEINFO_FREE[$DRIVE]}GB out of ${DRIVEINFO_TOT[$DRIVE]}GB Free (${DRIVEINFO_FREEPER[$DRIVE]}%)\n\n$(date)" | mail -s "Free Space ${fs_status}: '${host_name[$hostid]}'" ${ALERT_EMAIL} # echo -e "${host_name[$hostid]} - (${host_ip[$hostid]})\n\n${DRIVE} : ${DRIVEINFO_FREE[$DRIVE]}GB out of ${DRIVEINFO_TOT[$DRIVE]}GB Free (${DRIVEINFO_FREEPER[$DRIVE]}%)\n\n$(date)" | mail -s "Free Space ${fs_status}: '${host_name[$hostid]}'" ${ALERT_EMAIL}
SENDNOTICE "Free Space ${fs_status}: '${host_name[$hostid]}'" "${host_name[$hostid]} - (${host_ip[$hostid]}) SENDNOTICE "Free Space ${fs_status}: '${host_name[$hostid]}'" "${host_name[$hostid]} - (${host_ip[$hostid]})
${DRIVE} : ${DRIVEINFO_FREE[$DRIVE]}GB out of ${DRIVEINFO_TOT[$DRIVE]}GB Free (${DRIVEINFO_FREEPER[$DRIVE]})percent" ${fs_priority} ${DRIVE} : ${DRIVEINFO_FREE[$DRIVE]}GB out of ${DRIVEINFO_TOT[$DRIVE]}GB Free (${DRIVEINFO_FREEPER[$DRIVE]})percent" ${fs_priority}
fi fi
done done
@@ -264,11 +296,7 @@ ${DRIVE} : ${DRIVEINFO_FREE[$DRIVE]}GB out of ${DRIVEINFO_TOT[$DRIVE]}GB Free ($
# [ "${1}" != "report" ] && # [ "${1}" != "report" ] &&
echo -e "${idsCL[Yellow]} ${host_name[$hostid]} is down${idsCL[Default]}"; echo echo -e "${idsCL[Yellow]} ${host_name[$hostid]} is down${idsCL[Default]}"; echo
fi fi
touch /tmp/dscheck.${hostname}.done
done
end=`date +%s`; runtime=$((end-start)); echo -e "\nScript Runtime: ${runtime}"
echo
} }
SETUPSSH(){ SETUPSSH(){