Update dsmon.sh
This commit is contained in:
80
dsmon.sh
80
dsmon.sh
@@ -109,46 +109,46 @@ CHECK(){
|
|||||||
echo -e "${idsCL[LightCyan]} ${host_name[$hostid]} - Drive Space Check${idsCL[Default]}"
|
echo -e "${idsCL[LightCyan]} ${host_name[$hostid]} - Drive Space Check${idsCL[Default]}"
|
||||||
DIVIDER; echo -e "${idsST[Reset]}"
|
DIVIDER; echo -e "${idsST[Reset]}"
|
||||||
|
|
||||||
# checkhost=$(CHECK_HOST ${host_ip[$hostid]})
|
checkhost=$(CHECK_HOST ${host_ip[$hostid]})
|
||||||
# if [ "${checkhost}" != "false" ]; then
|
if [ "${checkhost}" != "false" ]; then
|
||||||
# DRIVEINFO=$(ssh root@${host_ip[$hostid]} df -BM | grep -vE '^Filesystem|tmpfs|cdrom|@|ram|loop|udev|veeamimage|nvme|localhost|sda|sdb|shm|mmcblk|overlay|-volume|Music|media-data|Software' | awk '{ print $1 " " $2 " " $4 }')
|
DRIVEINFO=$(ssh root@${host_ip[$hostid]} df -BM | grep -vE '^Filesystem|tmpfs|cdrom|@|ram|loop|udev|veeamimage|nvme|localhost|sda|sdb|shm|mmcblk|overlay|-volume|Music|media-data|Software' | awk '{ print $1 " " $2 " " $4 }')
|
||||||
# DRIVEINFO=(${DRIVEINFO})
|
DRIVEINFO=(${DRIVEINFO})
|
||||||
# NUMDRIVES=$((${#DRIVEINFO[@]} / 3))
|
NUMDRIVES=$((${#DRIVEINFO[@]} / 3))
|
||||||
#
|
|
||||||
# for ((i = 0 ; i <= $((${NUMDRIVES}-1)) ; i++)); do
|
for ((i = 0 ; i <= $((${NUMDRIVES}-1)) ; i++)); do
|
||||||
# ii=$((${i}*3))
|
ii=$((${i}*3))
|
||||||
# dname=${DRIVEINFO[${ii}]}
|
dname=${DRIVEINFO[${ii}]}
|
||||||
# dtot=$(bc <<< "scale=2; ${DRIVEINFO[$((${ii}+1))]}/1024/10")
|
dtot=$(bc <<< "scale=2; ${DRIVEINFO[$((${ii}+1))]}/1024/10")
|
||||||
# dfree=$(bc <<< "scale=2; ${DRIVEINFO[$((${ii}+2))]}/1024/10")
|
dfree=$(bc <<< "scale=2; ${DRIVEINFO[$((${ii}+2))]}/1024/10")
|
||||||
# dfreeper=$(printf "%0.2f" $(jq -n ${dfree}/${dtot}*100))
|
dfreeper=$(printf "%0.2f" $(jq -n ${dfree}/${dtot}*100))
|
||||||
# dname=${dname//\/dev\/mapper\//}
|
dname=${dname//\/dev\/mapper\//}
|
||||||
# dname=${dname//\/dev\//}
|
dname=${dname//\/dev\//}
|
||||||
#
|
|
||||||
# if (( $(bc <<<"$dfreeper <= 15") )); then
|
if (( $(bc <<<"$dfreeper <= 15") )); then
|
||||||
# fs_status='error'
|
fs_status='error'
|
||||||
# fs_status_color='Red'
|
fs_status_color='Red'
|
||||||
# if [ "${ALERT_EMAIL}" != "" ]; then echo -e "${host_name[$hostid]} - (${host_ip[$hostid]})\n${dname} : ${dfree} GB free\t$(date)" | mail -s "Free Space Critical: '${host_name[$hostid]}'" ${ALERT_EMAIL}; fi
|
if [ "${ALERT_EMAIL}" != "" ]; then echo -e "${host_name[$hostid]} - (${host_ip[$hostid]})\n${dname} : ${dfree} GB free\t$(date)" | mail -s "Free Space Critical: '${host_name[$hostid]}'" ${ALERT_EMAIL}; fi
|
||||||
#
|
|
||||||
# elif (( $(bc <<<"$dfreeper <= 25") )); then
|
elif (( $(bc <<<"$dfreeper <= 25") )); then
|
||||||
# fs_status='warn'
|
fs_status='warn'
|
||||||
# fs_status_color='Yellow'
|
fs_status_color='Yellow'
|
||||||
# if [ "${ALERT_EMAIL}" != "" ]; then echo -e "${host_name[$hostid]} - (${host_ip[$hostid]})\n${dname} : ${dfree} GB free\t$(date)" | mail -s "Free Space Warning: '${host_name[$hostid]}'" ${ALERT_EMAIL}; fi
|
if [ "${ALERT_EMAIL}" != "" ]; then echo -e "${host_name[$hostid]} - (${host_ip[$hostid]})\n${dname} : ${dfree} GB free\t$(date)" | mail -s "Free Space Warning: '${host_name[$hostid]}'" ${ALERT_EMAIL}; fi
|
||||||
#
|
|
||||||
# else
|
else
|
||||||
# fs_status=''
|
fs_status=''
|
||||||
# fs_status_color='Green'
|
fs_status_color='Green'
|
||||||
# fi
|
fi
|
||||||
#
|
|
||||||
# c=0; cw=30; spc=''
|
c=0; cw=30; spc=''
|
||||||
# spc1=`expr ${cw} - ${#dname}`
|
spc1=`expr ${cw} - ${#dname}`
|
||||||
# until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||||
# echo -e "${idsCL[$fs_status_color]} ${dname}${spc}: ${dfree}GB Free - ${dfreeper}%${idsCL[Default]}"
|
echo -e "${idsCL[$fs_status_color]} ${dname}${spc}: ${dfree}GB Free - ${dfreeper}%${idsCL[Default]}"
|
||||||
#
|
|
||||||
# done
|
done
|
||||||
#
|
|
||||||
# else
|
else
|
||||||
# echo -e "${idsCL[Yellow]} ${host_name[$hostid]} is down${idsCL[Default]}"
|
echo -e "${idsCL[Yellow]} ${host_name[$hostid]} is down${idsCL[Default]}"
|
||||||
# fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user