Custom Nagios Command and Services

To add a custom service check in nagios the following need to be done.

Add an new command in commands.cfg file. Based on my installation the path is

/usr/local/nagios/etc/objects/commands.cfg

I added these line to add a new command.

#check SSL Certificate
define command{
command_name check_ssl_certificate
command_line $USER1$/check_ssl_certificate -v -H $ARG1$ -c $ARG2$ -w $ARG3$
}

Note: $USER1$ path is the path of libexec folder of nagios and check_ssl_certificate is the script which I’m going to use to generate data.

Now add following lines in your host cfg file

define service{
use local-service
host_name myhost
service_description SSL Check
check_command check_ssl_certificate!google.com!30!15
}

Now restart the nagios service.

/etc/init.d/nagios restart