1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
| #!/bin/bash
#--dir:Monitoring of the mount point
#--critical:critical value
#--warning:warning value
#--ip
[ $# -eq 0 ] && {
echo "$0 [--dir PATH --critical NUM --warning NUM -h|--help]"
exit 99
}
while [ $# -ne 0 ];do
case $1 in
-h|--help)
echo "$0 [--dir PATH --critical NUM --warning NUM -h|--help]"
--dir)
DIR=$2
--critical)
CRITICAL=$2
shift 2
;;
--warning)
WARNING=$2
shift 2
;;
--ip)
IP=$2
shift 2
;;
*)
echo "$0 [--dir PATH --critical NUM --warning NUM -h|--help]"
exit 99
;;
esac
done
USEAGE=`df -h|awk -v mount=$DIR '$NF==mount{print $(NF-1)}'|cut -d% -f1`
if [ $USEAGE -ge $CRITICAL ];then
MSG="PROBLEM Service Alert:$IP:$DIR is CRITICAL,Used $USEAGE%"
/usr/local/bin/sendEmail -f FROMEMAIL -t TOEMAIL -s SMTPSERVER -u "SUBJECT" -xu YOURUSERNAME -xp YOUPASS -m "$MSG"
elif [ $USEAGE -ge $WARNING ];then
MSG="PROBLEM Service Alert:$IP:$DIR is WARNING,Used $USEAGE%"
/usr/local/bin/sendEmail -f FROMEMAIL -t TOEMAIL -s SMTPSERVER -u "SUBJECT" -xu YOURUSERNAME -xp YOUPASS -m "$MSG"
fi
|