Checking /proc/mounts on remote server

From Nagios Wiki

Jump to: navigation, search

[edit] Purpose

To show how to call check_disk command from NRPE, rather than making a separate NRPE handler for each mount point.

(This has been tested on CentOS 4)

[edit] On Monitored Server

Install Nagios' nrpe and plguins ('yum install nagios-nrpe nagios-plugins')

Open nrpe.cfg and add the following command

command[check_disks_proc_mounts]=/usr/lib/nagios/plugins/check_disk -w 15% -c 10% $(for x in $(cat /proc/mounts |awk '{print $2}')\; do echo -n " -p $x "\; done)

(If you see part of that command in a different color (e.g. blue), then it probably means that your editor is interpreting it as a comment. Disregard that and do NOT try to escape that character, or you will end up putting in characters that Nagios cannot interpret.

[edit] On Nagios Server

root@nagios plugins]# pwd

/usr/lib/nagios/plugins

[root@nagios plugins]# ./check_nrpe -H monitored-server -c check_disks_proc_mounts

DISK OK - free space: / 5811 MB (59%); /boot 35 MB (57%); /opt 3401 MB (34%); /dev/shm 1948 MB (100%); /tmp 6731 MB (94%); /var 4222 MB (84%);| /=4033MB;8367;8859;0;9844 /boot=26MB;51;54;0;60 /opt=6676MB;8564;9068;0;10076 /dev/shm=0MB;1655;1753;0;1948 /tmp=395MB;6057;6413;0;7126 /var=820MB;4284;4536;0;5041 

Once that tests ok, then add (something like) the following definition in your commands.cfg file

define  command {
        command_name    check_nrpe_disk_procs
        command_line    $USER1$/check_nrpe -H $HOSTNAME$ -c check_disks_proc_mounts -t 20
        }

Once you do, then you can add the following sort of host check (assuming, of course, that your host is already in your config)

define service{
        use                    local-service
        host_name              monitored_server
        service_description    check_disk on proc mounts
        check_command          check_nrpe_disk_procs
}
Personal tools
Advertisement