File check_disks of Package nagios-plugins-disks
1
#!/bin/bash
2
CHECK_MULTI_CMD_FILE="/tmp/check_disks.cmd"
3
CNT=0
4
5
rm -rf ${CHECK_MULTI_CMD_FILE}
6
7
for a in `grep -E '(xfs|ext2|ext3|ext4|btrfs|reiserfs|vfat|tmpfs|vzfs)' /proc/mounts | awk '{print $1}' | grep ^/ | grep -v -E '(^/vz/template:|^/dev$)' | sort -u` ; do
8
b=`readlink -e ${a}`
9
if [ "`mount | grep ^${b} | wc -l`" == "1" ] ; then
10
a=${b}
11
fi
12
if [ -d /etc/nagios/check_disks/ ] ; then
13
b=`echo ${a} | sed -e s@"/"@"_"@g`
14
if [ -s /etc/nagios/check_disks/${b} ] ; then
15
# format is 20%:10%
16
warn=`cat /etc/nagios/check_disks/${b} | awk -F: '{print $1}'`
17
crit=`cat /etc/nagios/check_disks/${b} | awk -F: '{print $2}'`
18
iwarn=`cat /etc/nagios/check_disks/${b} | awk -F: '{print $3}'`
19
icrit=`cat /etc/nagios/check_disks/${b} | awk -F: '{print $4}'`
20
if [ -z "${warn}" ] || [ -z "${crit}" ] ; then
21
warn="20%"
22
crit="10%"
23
fi
24
if [ -z "${iwarn}" ] || [ -z "${icrit}" ] ; then
25
iwarn="20%"
26
icrit="10%"
27
fi
28
else
29
warn="20%"
30
crit="10%"
31
iwarn="20%"
32
icrit="10%"
33
fi
34
else
35
warn="20%"
36
crit="10%"
37
iwarn="20%"
38
icrit="10%"
39
fi
40
echo "command[check_disk_${CNT}]=/usr/lib/nagios/plugins/check_disk -w ${warn} -c ${crit} -W ${iwarn} -K ${icrit} -p ${a}" >> ${CHECK_MULTI_CMD_FILE}
41
CNT=`expr ${CNT} + 1`
42
done
43
if [ -x /usr/lib/nagios/plugins/check_multi ] ; then
44
if [ -f ${CHECK_MULTI_CMD_FILE} ] ; then
45
/usr/lib/nagios/plugins/check_multi -f ${CHECK_MULTI_CMD_FILE} -s dont_be_paranoid=1 --report 520
46
else
47
if [ -x /usr/lib/nagios/plugins/check_disk ] ; then
48
/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -W 20% -K 10% -p /
49
else
50
echo "Couldn't find any valid filesystem to check and i'm unable to execute check_disk plugin"
51
exit 2
52
fi
53
fi
54
else
55
echo "Plugin: /usr/lib/nagios/plugins/check_multi not executable"
56
exit 2
57
fi
58