Check_HTTP query

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Check_HTTP query

Post by neworderfac33 »

Thank you - that's helping as I can now successfully identify text in either the header or the content, but can anyone confirm the correct syntax for specifying the URL as when I do this:

./check_http -H MyHost -u MyURL --expect=301 -s "Document Moved" -v

I get an OK, but when I add a trailing "/" to the URL, I get a Critical

Thanks all, and have a good weekend.

Pete
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Check_HTTP query

Post by mcapra »

The trailing slash thing depends on the web server. With Apache, mod_dir is usually the culprit here:
http://httpd.apache.org/docs/current/mod/mod_dir.html
Former Nagios employee
https://www.mcapra.com/
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Check_HTTP query

Post by neworderfac33 »

OK, So here's what I have:

Code: Select all


define command{
        command_name    check_http_url
        command_line    $USER1$/check_http -I $HOSTADDRESS$ -u $ARG1$
}

define host{
    host_name                    URL1
    hostgroups                   000-URL1
    address                      www.MyURL.com/
    max_check_attempts           5
    check_period                 24x7
    contact_groups               admins
    notification_period          24x7
    }

define hostgroup{
        hostgroup_name  000-URL1
        alias           Website Checking
}

define service{
    use                     generic-service
    host_name               URL1
    service_description     URL1 + Text [Country of Residence] + Status [301]
    check_command           check_http_url!URL1 -u /blah/blah/system/ -s "Country of Residence" --expect=301
    #register                0
    }
returns "Name or service not known"

Any offers?

As always, thanks for your help.

Pete
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Check_HTTP query

Post by mcapra »

Your Service's check_command is malformed:

Code: Select all

check_command           check_http_url!URL1 -u /blah/blah/system/ -s "Country of Residence" --expect=301
Drop the "URL1" since it doesn't fit into your command definition. It's just hanging out there. Also remove the -u argument since your Command definition is already including it.

Code: Select all

check_command           check_http_url!/blah/blah/system/ -s "Country of Residence" --expect=301
Also remove the preceding slash from your Host's address definition. www.MyURL.com should be sufficient (especially if you're including the preceding slash in your URL path).
Former Nagios employee
https://www.mcapra.com/
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Check_HTTP query

Post by neworderfac33 »

Thank you for coming back to me.
So now I have:

Code: Select all

define host{
    host_name                    URL1
    hostgroups                   000-URL1
    address                      http://www.yada.dev.com
    max_check_attempts           5
    check_period                 24x7
    contact_groups               admins
    notification_period          24x7
    }

define service{
    use                          generic-service
    host_name                    URL1
    service_description          MyServiceDescription
    check_command                check_http_url!/my/sub/folder/ -s "Country of Residence" --expect=301
    #register                     0
    }
So, I'm testing for the presence of the text string "Country of residence" in "www.yada.dev.com/my/sub/folder"

But its STILL showing "Name or Service not known"

Sorry to be a nuisance!

Pete
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Check_HTTP query

Post by mcapra »

Oh pete, you're not a nuisance :)

Your Host definition's address should not contain http://. See if removing that does the trick!
Former Nagios employee
https://www.mcapra.com/
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Check_HTTP query

Post by neworderfac33 »

No luck, I'm afraid - just to recap:

Code: Select all

define command{
        command_name    check_http_url
        command_line    $USER1$/check_http -I $HOSTADDRESS$ -u $ARG1$
}

define host{
    host_name                    URL1
    hostgroups                   000-URL1
    address                      MyURL.dev.com
    max_check_attempts           5
    check_period                 24x7
    contact_groups               admins
    notification_period          24x7
    }

define service{
    use                          generic-service
    host_name                    URL1
    service_description          URL1 - URL1/my/folder/structure + Text [Country of Residence] + Status [301]
    check_command                check_http_url!URL1/my/folder/structure/ -s "Country of Residence" --expect=301
    #register                     0
    }
Within the service, I have tried both "URL" and the name of the actual url to which it refers, but both return "Name or service not known".

Maybe Core just isn't meant to be able to monitor a URL without a server hostname to attach it to (he finished, desperately)?

And yes, I AM a nuisance! Perhaps I should ask Core to resolve complex quantum mechanics equations and explain the meaning of life while I'm at it..! :-)

Pete
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Check_HTTP query

Post by mcapra »

Your check_http_url command definition seems to have switched back to using -I instead of -H. Try changing it like so:

Code: Select all

define command{
        command_name    check_http_url
        command_line    $USER1$/check_http -H $HOSTADDRESS$ -u $ARG1$
}
Former Nagios employee
https://www.mcapra.com/
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Check_HTTP query

Post by neworderfac33 »

NOW we're getting somewhere.

The following:

Code: Select all


define command{
        command_name    check_http_url
        command_line    $USER1$/check_http -H $HOSTADDRESS$ -u $ARG1$
}

define host{
    host_name                    URL1
    hostgroups                   000-URL1
    address                      MYURL.uat.com
    max_check_attempts           5
    check_period                 24x7
    contact_groups               admins
    notification_period          24x7
    }

define service{
    use                          generic-service
    host_name                    URL1
    service_description          
    check_command                check_http_url!URL1/My/URL/name/ --expect=301
}
returns:
HTTP CRITICAL - Invalid HTTP response received from host: HTTP/1.1 400 Bad Request
which is a bit further on than I was yesterday.

Thanks for your continued patience.

Pete
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Check_HTTP query

Post by mcapra »

Your Service's check command seems to have changed between posts. It no longer includes a preceding slash for the URL:

Code: Select all

 check_command                check_http_url!URL1/My/URL/name/ --expect=301
Try giving it a preceding slash like so:

Code: Select all

 check_command                check_http_url!/URL1/My/URL/name/ --expect=301
Former Nagios employee
https://www.mcapra.com/
Locked