Search code examples
httpnagiosxi

Nagios Alert returns "NRPE: Unable to read output" Command: check_service!httpd


I have installed Nagios on Redhat with the following configurations:

/usr/local/nagios/etc/static/commands.cfg
define command {
       command_name                     check_service
       command_line                     $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_service -a $ARG1$
}

When I try to run it manually:

if i try to use the following syntax, I get error:

/usr/local/nagios/libexec/check_nrpe -H 10.111.55.92 -c check_service -a check_http
NRPE: Unable to read output

not using nope:

/usr/local/nagios/libexec/check_http -H 10.111.55.92
HTTP OK: HTTP/1.1 200 OK - 4298 bytes in 0.024 second response time |time=0.024462s;;;0.000000 size=4298B;;;0

I am consistently getting Nagios Email notifications:

HOST: Proxy (Dev) i-01aa24242424d7
IP: 10.111.55.92
Service: Apache Running
Service State: UNKNOWN
Attempts: 3/3
Duration: 0d 9h 28m 49s
Command: check_service!httpd
\More Details:
NRPE: Unable to read output

Not sure how I can use nrpe with check_service to check http

Just. running the check_nrpe with check_http displays the version of installed nope

/usr/local/nagios/libexec/check_nrpe -H 10.111.55.92 -a check_http
NRPE v3.2.1

/usr/local/nagios/etc/nrpe.cfg

command[check_users]=/usr/local/nagios/libexec/check_users -w 10 -c 15
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_root_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 10 -c 15 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 500 -c 750
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 500 -c 750
command[check_ping]=/usr/local/nagios/libexec/check_ping $ARG1$
command[check_http]=/usr/local/nagios/libexec/check_http

# LINUX DEFAULT
command[check_service]=/bin/sudo -n /bin/systemctl status -l $ARG1$

# GLUSTER CHECKS
command[check_glusterdata]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /gluster

# GITLAB CHECKS
command[gitlab_ctl]=/bin/sudo -n /bin/gitlab-ctl status $ARG1$
command[gitlab_rake]=/bin/sudo -n /bin/gitlab-rake gitlab:check
command[check_gitlabdata]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /var/opt/gitlab

# OPENSHIFT CHECKS
command[check_openshift_pods]=/usr/local/nagios/libexec/check_pods

File: /usr/local/nagios/etc/nagios.cfg

cfg_dir=/usr/local/nagios/etc/static

Solution

  • You seem to be confusing two plugins. check_service will just check a service is running locally. Try calling it like this:

    /usr/local/nagios/libexec/check_nrpe -H 10.111.55.92 -c check_service -a httpd

    I'd hesitate to use the check_service command you have in there though. Giving nrpe access to run systemctl with sudo seems dangerous to me.

    check_http is an http client. It will actually connect to an http server and check a given URI. It can check status codes and do all sorts of things.

    It looks like in your nrpe.cfg you didn't include any arguments to check_http. It will just print its help message if you call it like that, I don't think it will check the local machine.

    Note that when you call check_http above manually, you supply -H. That -H is not passed through automatically, you need to provide arguments to your check_http command in nrpe.cfg.

    Change the line:

    command[check_http]=/usr/local/nagios/libexec/check_http

    To something like:

    command[check_http]=/usr/local/nagios/libexec/check_http -H 127.0.0.1

    And it should work better assuming your http is listening on localhost.

    You probably don't want to call check_http via nrpe like this though. Let your nagios server call check_http out to the remote machine.