Logoj0ke.net Open Build Service > Projects > server:monitoring > nagios-plugins-disks > check_disks
Sign Up | Log In

File check_disks of Package nagios-plugins-disks (Revision e580ebb899ca26c90fe17116aa4d211d)

Currently displaying revision e580ebb899ca26c90fe17116aa4d211d, show latest

 
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:)' | 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
        if [ -z "${warn}" ] || [ -z "${crit}" ] ; then
19
                warn="20%"
20
                crit="10%"
21
        fi
22
  else
23
        warn="20%"
24
        crit="10%"
25
  fi
26
 else
27
    warn="20%"
28
    crit="10%"
29
 fi
30
 echo "command[check_disk_${CNT}]=/usr/lib/nagios/plugins/check_disk -w ${warn} -c ${crit} -p ${a}" >> ${CHECK_MULTI_CMD_FILE}
31
 CNT=`expr ${CNT} + 1`
32
done
33
if [ -x /usr/lib/nagios/plugins/check_multi ] ; then
34
        if [ -f ${CHECK_MULTI_CMD_FILE} ] ; then
35
                /usr/lib/nagios/plugins/check_multi -f ${CHECK_MULTI_CMD_FILE} -s dont_be_paranoid=1
36
        else
37
                if [ -x /usr/lib/nagios/plugins/check_disk ] ; then
38
                        /usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /
39
                else
40
                        echo "Couldn't find any valid filesystem to check and i'm unable to execute check_disk plugin"
41
                        exit 2
42
                fi
43
        fi
44
else
45
        echo "Plugin: /usr/lib/nagios/plugins/check_multi not executable"
46
        exit 2
47
fi
48