Home   Profile   Fun
#74 Linux  03.04.2007

Check scripts written in Perl for the Nagios plug-in NRPE


check_disk.pl p1 p2 p3
This script checks the amount of disk space available on the monitored system and returns ok, warning or critical. Parameter p1 is the warning threshold in percentage, p2 the critical threshold and with p3 you can pass filesystems which shall be excluded from the check (procfs, devfs for example).

check_swap.pl p1 p2
Check the amount of swap beeing used by the system. Parameter p1 ist the warning threshold in megabyte, p2 the critical threshold.

check_loadaverage.pl p1 p2
Check the load average. Parameter p1 is the warning threshold, p2 the critical threshold.

check_processes.pl p1
If you want to monitor important processes and you want to check if they are running, this script does it for you. Parameter p1 is a comma-separated list of the process names you want to monitor.



The best way to monitor things inside vservers is to install nrpe on the host system once. Otherwise you have to install it in every single vserver which is too much effort. Just install nrpe on the host and run all scripts from there. Nothing needs to be installed in the vservers. Therefore I created some scripts which can be used to monitor processes inside vservers. These scripts use the command vps. In order for them to work you must add a line to sudo on the host system:
nagios ALL=(ALL) NOPASSWD: /usr/sbin/vps

check_vserver_exactnrprocs.pl p1 p2 p3
Use this script if you want to make sure that an exact number of a process is running. Parameter p1 is the process name, p2 is the number and p3 the vserver name.

check_vserver_nrprocs.pl p1 p2 p3 p4
An example for the usage is if you want to control the number of apache processes running. Usually they should not exceed a certain limit. You can define warning and critical thresholds. The parameter p1 is the process name, p2 the warning threshold, p3 the critical threshold and p4 the vserver name.

check_vserver_processes.pl p1 p2 [p3]
This script helps to check that processes are running at all. Here the number of processes is of no interest. We just want to monitor that ssh is running for example. The parameter p1 is a comma separated list of the processes to be monitored, p2 is the vserver name and p3 is an optional parameter. If it is set to fuzzymatch a process is recognized if it contains the string you use as p1. Example: mysql matches /usr/sbin/mysql. Square brackets can be ignored: to check [nfsd] use nfsd.


Nagios 3 with failover on SLES 11 with NConf, NRPE, NSCA, PNP4Nagios and NagVis