Update dsmon.sh

This commit is contained in:
2023-10-09 18:01:08 -05:00
parent 241a39f42b
commit 2c999e9906

View File

@@ -118,11 +118,11 @@ CHECK(){
#for hostid in "${!host_ip[@]}"; do
for hostname in "${hostnames_sort[@]}"; do
hostid=${host_ids[$hostname]}
if [ "${1}" != "report" ]; then
# if [ "${1}" != "report" ]; then
echo -e "${idsST[Bold]}"; DIVIDER false lightCyan 85
echo -e "${idsCL[LightCyan]} ${host_name[$hostid]} - Drive Space Check${idsCL[Default]}"
DIVIDER false lightCyan 85
fi
# fi
checkhost=$(CHECK_HOST ${host_ip[$hostid]})
if [ "${checkhost}" != "false" ]; then
@@ -184,7 +184,7 @@ CHECK(){
# for x in "${!DRIVEINFO_FREEPER[@]}"; do printf "[%s]=%s\n" "$x" "${DRIVEINFO_FREEPER[$x]}" ; done
# echo
if [ "${1}" != "report" ]; then
# if [ "${1}" != "report" ]; then
c=0; cw=18; spcA=''; spc1=`expr ${cw} - 7`; until [ $c = ${spc1} ]; do spcA="${spcA} "; c=`expr $c + 1`; done
c=0; cw=10; spcB=''; spc2=`expr ${cw} - 4`; until [ $c = ${spc2} ]; do spcB="${spcB} "; c=`expr $c + 1`; done
c=0; cw=10; spcC=''; spc3=`expr ${cw} - 5`; until [ $c = ${spc3} ]; do spcC="${spcC} "; c=`expr $c + 1`; done
@@ -192,7 +192,7 @@ CHECK(){
echo -e "${idsST[Reset]}${idsCL[White]} DRIVE${spcA} FREE GB${spcB}FREE %${spcC}TOTAL GB${spcD}WARN % / CRIT %${idsCL[Default]}"
# pf="%-20s %10s %10s %12s %50s\n"
# printf "${pf}" "${idsCL[White]}DRIVE" "FREE GB" "FREE %" "TOTAL GB" "WARN % / CRIT %${idsCL[Default]}"
fi
# fi
for DRIVE in "${DRIVES[@]}"; do
@@ -201,12 +201,12 @@ CHECK(){
WARNING_LEVEL=$(printf "%0.2f" $(jq -n 100-${host_limits_tmp[$DRIVE]}))
CRITICAL_LEVEL=$(printf "%0.2f" $(jq -n $WARNING_LEVEL-$WARNING_LEVEL/2))
if [ "${1}" != "report" ]; then
# if [ "${1}" != "report" ]; then
c=0; cw=18; spcA=''; spc1=`expr ${cw} - ${#DRIVEINFO_SHORTNAME[$DRIVE]}`; until [ $c = ${spc1} ]; do spcA="${spcA} "; c=`expr $c + 1`; done
c=0; cw=10; spcB=''; spc2=`expr ${cw} - ${#DRIVEINFO_FREE[$DRIVE]}`; until [ $c = ${spc2} ]; do spcB="${spcB} "; c=`expr $c + 1`; done
c=0; cw=10; spcC=''; spc3=`expr ${cw} - ${#DRIVEINFO_FREEPER[$DRIVE]}`; until [ $c = ${spc3} ]; do spcC="${spcC} "; c=`expr $c + 1`; done
c=0; cw=14; spcD=''; spc4=`expr ${cw} - ${#DRIVEINFO_TOT[$DRIVE]}`; until [ $c = ${spc4} ]; do spcD="${spcD} "; c=`expr $c + 1`; done
fi
# fi
if (( $(bc <<<"${DRIVEINFO_FREEPER[$DRIVE]} <= ${CRITICAL_LEVEL}") )); then
fs_status='CRITICAL'
@@ -230,7 +230,8 @@ CHECK(){
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]}"
# [ "${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]}"
# [ "${1}" != "report" ] && printf "${pf}" "${idsCL[Cyan]}${DRIVEINFO_SHORTNAME[$DRIVE]}" "${idsCL[$fs_status_color]}${DRIVEINFO_FREE[$DRIVE]} GB" "${DRIVEINFO_FREEPER[$DRIVE]}%" "${DRIVEINFO_TOT[$DRIVE]} GB" "${idsCL[Cyan]}(${idsCL[Default]}${D_WARNING_LEVEL}%${idsCL[Cyan]}/${idsCL[Default]}${D_CRITICAL_LEVEL}%${idsCL[Cyan]})(${idsCL[Yellow]}${D_WARNING_LEVEL}%${idsCL[Cyan]}/${idsCL[Red]}${D_CRITICAL_LEVEL}%${idsCL[Cyan]})${idsCL[Default]}"
@@ -246,7 +247,8 @@ ${DRIVE} : ${DRIVEINFO_FREE[$DRIVE]}GB out of ${DRIVEINFO_TOT[$DRIVE]}GB Free ($
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
# [ "${1}" != "report" ] &&
echo -e "${idsCL[Yellow]} ${host_name[$hostid]} is down${idsCL[Default]}"; echo
fi
done