From eee9be0cd3c5bc35c7dfedd47f72d5870a047de0 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Mon, 2 Jan 2023 15:51:26 -0600 Subject: [PATCH] Update dsmon.sh --- dsmon.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dsmon.sh b/dsmon.sh index 1141930..de0a3e8 100755 --- a/dsmon.sh +++ b/dsmon.sh @@ -127,7 +127,7 @@ CHECK(){ # for x in "${!DRIVEINFO[@]}"; do printf "[%s]=%s\n" "$x" "${DRIVEINFO[$x]}" ; done NUMDRIVES=$((${#DRIVEINFO[@]} / 3)) - declare -A DRIVEINFO_TOT DRIVEINFO_FREE DRIVEINFO_FREEPER + declare -A DRIVEINFO_TOT DRIVEINFO_FREE DRIVEINFO_FREEPER DRIVEINFO_SHORTNAME declare -a DRIVES for ((i = 0 ; i <= $((${NUMDRIVES}-1)) ; i++)); do @@ -156,6 +156,7 @@ CHECK(){ DRIVEINFO_TOT[$dname]=$dtot DRIVEINFO_FREE[$dname]=$dfree DRIVEINFO_FREEPER[$dname]=$dfreeper + DRIVEINFO_SHORTNAME[$dname]=$dname_short DRIVES+=("$dname") fi done @@ -221,14 +222,14 @@ CHECK(){ fs_status_color='Green' fi - [ "${1}" != "report" ] && echo -e "${idsCL[Cyan]} ${DRIVE}${spcA}:${idsCL[$fs_status_color]} ${DRIVEINFO_FREE[$DRIVE]} GB${spcB}${DRIVEINFO_FREEPER[$DRIVE]}%${spcC}${DRIVEINFO_TOT[$DRIVE]} GB${idsST[Reset]}${spcD}${idsCL[Cyan]}( ${idsCL[Yellow]}${WARNING_LEVEL}%${idsCL[Cyan]} / ${idsCL[Red]}${CRITICAL_LEVEL}%${idsCL[Cyan]} )${idsCL[Default]}" + [ "${1}" != "report" ] && echo -e "${idsCL[Cyan]} ${DRIVEINFO_SHORTNAME[$DRIVE]}${spcA}:${idsCL[$fs_status_color]} ${DRIVEINFO_FREE[$DRIVE]} GB${spcB}${DRIVEINFO_FREEPER[$DRIVE]}%${spcC}${DRIVEINFO_TOT[$DRIVE]} GB${idsST[Reset]}${spcD}${idsCL[Cyan]}( ${idsCL[Yellow]}${WARNING_LEVEL}%${idsCL[Cyan]} / ${idsCL[Red]}${CRITICAL_LEVEL}%${idsCL[Cyan]} )${idsCL[Default]}" if [ "${ALERT_EMAIL}" != "" ] && [ "${fs_status}" != "Normal" ] && [ "${1}" = "report" ]; then 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} fi done - unset DRIVEINFO_TOT DRIVEINFO_FREE DRIVEINFO_FREEPER DRIVES DRIVEINFO host_limits_tmp + unset DRIVEINFO_TOT DRIVEINFO_FREE DRIVEINFO_FREEPER DRIVEINFO_SHORTNAME DRIVES DRIVEINFO host_limits_tmp else [ "${1}" != "report" ] && echo -e "${idsCL[Yellow]} ${host_name[$hostid]} is down${idsCL[Default]}"; echo