Random Project

Perfect Plugin

I’m using NRPE on Client Side. Below is the configuration.

Upload “check_dirsize11.sh” script on Nagios Client Node under “/usr/lib64/nagios/plugins/” directory.

Open nrpe.cfg file & append new line as follows.
vim /etc/nagios/nrpe.cfg
command[check_syslog_dir]=/usr/lib64/nagios/plugins/check_dirsize11.sh -d /var/log/

Restart NRPE Service.
systemctl restart nrpe

Now on the Nagios Server Side, configure remote host as follows:

define service{
use generic-service
host_name linuxbox1.example.local
service_description SYSLOG Directory Size
check_command check_nrpe!check_syslog_dir
}

Save & Exit.

You can also run the NRPE Command from Nagios Server to get the output. The command is,

/usr/local/nagios/libexec/check_nrpe -H 172.16.1.96 -c check_syslog_dir

Important Note:

If you’re getting sudo error to access “DU” command, append below line inside Nagios client sudo file.
%nagios ALL=(ALL) NOPASSWD:ALL

Now, modify “check_dirsize11.sh” plugin, line no:46
DU=”/usr/bin/sudo /usr/bin/du”

If you want directory size output in “GB”, then change line no. 159 as follows.

duresult=`$DU -sh $dirpath 2>&1` || error=”Error”

(Replace -sk with -sh)

That’s it.