0

I created my own command to check a specific URL

define command{
    command_name    check_url
    command_line    /usr/lib/nagios/plugins/check_http -f follow -H '$HOSTNAME$' -I '$HOSTADDRESS$' -u '$ARG1$'
    }

If I run my command from the command line, it works:

/usr/lib/nagios/plugins/check_http -f follow -H www.example.com -u http://www.example.com/server-status

HTTP OK: HTTP/1.1 200 OK - 4826 bytes in 0.011 second response time  |time=0.010625s;;;0.000000 size=4826B;;;0

But when run through Icinga, I'm getting

HTTP WARNING: HTTP/1.1 404 NOT FOUND - 314 bytes in 0.011 second response time 
Chris Curvey
  • 9,738
  • 10
  • 48
  • 70

3 Answers3

3

My guess is for check_http plugin for -u option you should provide the url appended after the server name not the whole url. Ex.

/usr/lib/nagios/plugins/check_http -f follow -H www.example.com -u /server-status

MangeshBiradar
  • 3,820
  • 1
  • 23
  • 41
1

Your manual test is not equivalent to your command definition.

The distinction with -H/-I is subtle, but very important.

Keith
  • 339
  • 2
  • 16
1

When I have problems like this, where Icinga is abstracting exactly how it is executing the command, I find it helpful to find out precicely what Icinga is executing. I would accomplish this as follows:

Move check_http to a temporary location

# mv /usr/lib/nagios/plugins/check_http /usr/lib/nagios/plugins/check_http_actual

Make a bash script that Icinga will call instead of the actual check_http script

# vi /usr/lib/nagios/plugins/check_http

In that file, create this simple bash script, which simply echos the command line arguments it was called with, then exits:

#!/bin/bash
echo $@

Then of course, make that bash script executable:

# chmod +x /usr/lib/nagios/plugins/check_http

Now in Icinga, run the check_http command. At that point, the return status shown in the Icinga web interface will show exactly how Icinga is calling check_http. Seeing the raw command, it should be obvious as to what Icinga is doing wrong. Once you correct Icinga's mistake, you can simply move the original check_http script back into place:

# mv /usr/lib/nagios/plugins/{check_http_actual,check_http}
Chris Grimmett
  • 293
  • 5
  • 18