From 2821da3bfa36e9b21c3936272f049bd361c18e05 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sun, 19 Mar 2023 18:11:30 -0500 Subject: [PATCH] Update dsmon.sh --- dsmon.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/dsmon.sh b/dsmon.sh index 3d812f3..786746e 100755 --- a/dsmon.sh +++ b/dsmon.sh @@ -212,25 +212,30 @@ CHECK(){ if (( $(bc <<<"${DRIVEINFO_FREEPER[$DRIVE]} <= ${CRITICAL_LEVEL}") )); then fs_status='CRITICAL' + fs_priority=2 fs_status_color='RedBold' elif (( $(bc <<<"${DRIVEINFO_FREEPER[$DRIVE]} <= ${WARNING_LEVEL}") )); then fs_status='Warning' + fs_priority=1 fs_status_color='Yellow' elif (( $(bc <<<"${DRIVEINFO_FREE[$DRIVE]} < 5") )); then fs_status='Warning' + fs_priority=1 fs_status_color='Magenta' else fs_status='Normal' + fs_priority=0 fs_status_color='Green' fi D_WARNING_LEVEL=$(printf "%0.2f" $(jq -n 100-${WARNING_LEVEL})) D_CRITICAL_LEVEL=$(printf "%0.2f" $(jq -n 100-${CRITICAL_LEVEL})) [ "${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]}${D_WARNING_LEVEL}%${idsCL[Cyan]} / ${idsCL[RedBold]}${D_CRITICAL_LEVEL}%${idsST[Reset]}${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} + if [ "${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} + SENDNOTICE "Free Space ${fs_status}: '${host_name[$hostid]}'" "${host_name[$hostid]} - (${host_ip[$hostid]})\n\n${DRIVE} : ${DRIVEINFO_FREE[$DRIVE]}GB out of ${DRIVEINFO_TOT[$DRIVE]}GB Free (${DRIVEINFO_FREEPER[$DRIVE]}%)" ${fs_priority} fi done @@ -288,6 +293,15 @@ RUNCMD(){ done } +SENDNOTICE(){ + [ "${PUSHOVER_APP_TOKEN}" != "" ] && PUSH_TO_MOBILE "${2} + +$(date)" "${1}" ${3} & + + [ "${EMAIL_NOTICE}" != "" ] && echo -e "${2}\n\n$(date)" | mail -s "${1}" ${EMAIL_NOTICE} + +} + case $action in check) CHECK ${2};; setupssh) SETUPSSH;;