Changing check_http.c

Jim Avery jim at jimavery.me.uk
Tue Apr 21 23:38:19 CEST 2009


2009/4/21 Andrew Davis <nccomp at gmail.com>:
> My checkcommands.cfg has an "check_http" entry that looks like this:
>
> # 'check_http' command definition
> define command{
>         command_name    check_http
>         command_line    $USER1$/check_http -I $HOSTADDRESS$ $ARG1$
>         }
>
> My services.cfg has a correlating entry that looks like this:
>
> ## HTTP - alternate URL suffix
> define service {
>         host_name                       server
>         service_description             HTTP
>         check_command                   check_http!-p 9090 -u /proteus
>         ~
>         action_url
> /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
> }
>
> When I run this at the command line, I see:
>
> /usr/local/nagios/libexec/check_http -I server -p 9090 -u /proteus
> HTTP OK - HTTP/1.1 301 Moved Permanently - 0.002 second response time
> |time=0.002480s;;;0.000000 size=577B;;;0
>
> So far, so good, but what I really want to see is the URL in the output.
> Obviously, looking at the test, I can combine the server name, port, and URL
> suffix to figure out the URL. Unfortunately, while I'm good at shell
> scripting and perl, I'm not a C guy and the http test (check_http) is
> written in C. Anyone know what I would change in check_http.c to have the
> output show something like this:
>
> /usr/local/nagios/libexec/check_http -I server -p 9090 -u /proteus
> HTTP OK - HTTP/1.1 301 Moved Permanently http://server:9090/proteus - 0.002
> second response time |time=0.002480s;;;0.000000 size=577B;;;0
>
> Its one thing to be told that my website is down, but when I'm runnng
> multiple copies of Apache, Tomcat, and custom apps and hosting perhaps 20
> different URL's and port combinations, it would be a LOT more convenient if
> Nagios showed me which URL was failing in the output of the test.

I agree, but since the plugin doesn't do that, I sometimes put the
full url in the "notes" directive in the service definition (or even
notes_url) so I can get to them easily.   You can modify your
notification command to add whichever to your notification email too
if you use the relevant macro.

hth,

Jim

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list