Update dsmon.sh
This commit is contained in:
54
dsmon.sh
54
dsmon.sh
@@ -111,7 +111,7 @@ CHECK(){
|
|||||||
|
|
||||||
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|shm|mmcblk|-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|shm|mmcblk|overlay|-volume|Music|media-data|Software' | awk '{ print $1 " " $2 " " $4 }')
|
||||||
DRIVEINFO=(${DRIVEINFO})
|
DRIVEINFO=(${DRIVEINFO})
|
||||||
NUMDRIVES=$((${#DRIVEINFO[@]} / 3))
|
NUMDRIVES=$((${#DRIVEINFO[@]} / 3))
|
||||||
|
|
||||||
@@ -134,36 +134,38 @@ CHECK(){
|
|||||||
systempartition=true
|
systempartition=true
|
||||||
elif [ "${ia}" = "mmcblk0p1" ] && [ ${DRIVEINFO[$((${ii}+1))]//M/} -lt 1024 ]; then
|
elif [ "${ia}" = "mmcblk0p1" ] && [ ${DRIVEINFO[$((${ii}+1))]//M/} -lt 1024 ]; then
|
||||||
systempartition=true
|
systempartition=true
|
||||||
elif [ "${ia}" != "overlay" ]; then
|
|
||||||
#echo "${ia};${ib};${ic}"
|
|
||||||
DRIVE_INFO+=("${ia};${ib};${ic}")
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( $(bc <<<"$dfreeper <= 15") )); then
|
|
||||||
fs_status='error'
|
|
||||||
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
|
|
||||||
|
|
||||||
elif (( $(bc <<<"$dfreeper <= 25") )); then
|
|
||||||
fs_status='warn'
|
|
||||||
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
|
|
||||||
|
|
||||||
else
|
else
|
||||||
fs_status=''
|
systempartition=false
|
||||||
fs_status_color='Green'
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
c=0; cw=40; spcA=''
|
if [ $systempartition = false ]; then
|
||||||
spc1=`expr ${cw} - ${#dname}`
|
|
||||||
until [ $c = ${spc1} ]; do spcA="${spcA} "; c=`expr $c + 1`; done
|
|
||||||
|
|
||||||
c=0; cw=12; spcB=''
|
if (( $(bc <<<"$dfreeper <= 15") )); then
|
||||||
spc2=`expr ${cw} - ${#dfree}`
|
fs_status='error'
|
||||||
until [ $c = ${spc2} ]; do spcB="${spcB} "; c=`expr $c + 1`; done
|
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
|
||||||
|
|
||||||
echo -e "${idsCL[$fs_status_color]} ${dname}${spcA}: ${dfree}GB Free${spcB}- ${dfreeper}% -${idsCL[Default]}"
|
elif (( $(bc <<<"$dfreeper <= 25") )); then
|
||||||
|
fs_status='warn'
|
||||||
|
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
|
||||||
|
|
||||||
|
else
|
||||||
|
fs_status=''
|
||||||
|
fs_status_color='Green'
|
||||||
|
fi
|
||||||
|
|
||||||
|
c=0; cw=40; spcA=''
|
||||||
|
spc1=`expr ${cw} - ${#dname}`
|
||||||
|
until [ $c = ${spc1} ]; do spcA="${spcA} "; c=`expr $c + 1`; done
|
||||||
|
|
||||||
|
c=0; cw=12; spcB=''
|
||||||
|
spc2=`expr ${cw} - ${#dfree}`
|
||||||
|
until [ $c = ${spc2} ]; do spcB="${spcB} "; c=`expr $c + 1`; done
|
||||||
|
|
||||||
|
echo -e "${idsCL[$fs_status_color]} ${dname}${spcA}: ${dfree}GB Free${spcB}- ${dfreeper}% -${idsCL[Default]}"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user