Nginx 1.6.3 status monitoring with Adagios on CentOS 7


cd /usr/lib64/nagios/plugins/

Install prerequisites:

yum install perl-libwww-perl nagios-plugins-perl

Create a check command:

pynag add command command_name="2ks-check_nginx_status" command_line='$USER1$/ -H $HOSTADDRESS$ -p $_SERVICE_PORT$ -s $_SERVICE_SERVER_NAME$ $_SERVICE_OPTIONAL_ARGUMENTS$'

Create an okconfig template:

cd /etc/nagios/okconfig
echo 'define service {
    service_description            Nginx status
    use                            generic-service
    host_name                      HOSTNAME
    check_command                  2ks-check_nginx_status
    __PORT                         80
    __SERVER_NAME                  HOSTNAME
define service {
    use                            okc-linux-check_proc
    __WARNING                      1:
    __NAME                         nginx
    host_name                      HOSTNAME
    service_description            Process nginx
    __CRITICAL                     :10
    check_command                 okc-check_nrpe!check_procs -a $_SERVICE_WARNING$ $_SERVICE_CRITICAL$ $_SERVICE_NAME$
}' > nginx.cfg-example

Add the template to a host:

okconfig addtemplate --template nginx

Reload nagios and run the service checks from the Adagios web interface, and they should be green:

Problem: Running the plugin in nagios causes this error:

NGINX UNKNOWN - unable to write temporary data in :/tmp/123.123.123._check_nginx_status...

Probable causes:

You ran the plugin as root, it saved the *check_nginx_status file in /tmp with root ownership, and nagios can’t overwrite it.
SELinux or other ACL’s are preventing nagios from write to /tmp.

Delete the file:

rm -f /tmp/*check_nginx_status

Or reset permissions on /tmp:

chmod 777 /tmp/
chown root:root /tmp/
restorecon -R /tmp/ #NOTE: SELinux should be in permissive mode when using Adagios, unless you can create rules for it.
Nginx 1.6.3 status monitoring with Adagios on CentOS 7