From 465e7996e4504db2ec20cbd25c4acfd26be5c04d Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sun, 12 Feb 2023 12:55:32 -0600 Subject: [PATCH] Update dsmon.sh --- dsmon.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dsmon.sh b/dsmon.sh index afe095c..50ac8f4 100755 --- a/dsmon.sh +++ b/dsmon.sh @@ -222,9 +222,9 @@ CHECK(){ fs_status_color='Green' fi - D_WARNING_LEVEL=$(bc <<< "scale=2; 100-${WARNING_LEVEL}") - D_CRITICAL_LEVEL=$(bc <<< "scale=2; 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]}$(expr 100 - ${WARNING_LEVEL})%${idsCL[Cyan]} / ${idsCL[RedBold]}$(expr 100 - ${CRITICAL_LEVEL})%${idsST[Reset]}${idsCL[Cyan]} )${idsCL[Default]}" + 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} fi