Check_HTTP query
Re: Check_HTTP query
Is he looking for something dynamic? I am not sure how you can make a HTTP call without a host.
Former Nagios employee
-
- Posts: 329
- Joined: Fri Jul 24, 2015 11:04 am
Re: Check_HTTP query
I think so, yes - we have the ability to base a website on any one of a number of different servers, so he wants the active website, without having to point to the server that it's running on.
I thought it was a bit ambitious!
Pete
I thought it was a bit ambitious!
Pete
Re: Check_HTTP query
Assuming the Core server can resolve the hostname and the hostname is consistent, you should be able to do something like this:
And put that Service check under the example.com Host, for example. This would change your command definition slightly using -H instead of -I:
And you would have to keep in mind that any Host definitions with Service checks using this Command should use a hostname or FQDN (that can be resolved by the Core server) as the host's address .
When you put it all together, you get something that looks like this (copy+pasting maybe not a good idea ):
Code: Select all
./check_http -H www.example.com
Code: Select all
define command{
command_name check_http_url
command_line $USER1$/check_http -H $HOSTADDRESS$ -u $ARG1$
}
Code: Select all
host_name www.example.com
address www.example.com
Code: Select all
define command{
command_name check_http_url
command_line $USER1$/check_http -H $HOSTADDRESS$ -u $ARG1$
}
define service{
use generic-service
host_name MyServerID
#hostgroup_name url011u
service_description URL http://MyURL + Text [Country of Residence] + Status [301] + Port [8001]
check_command check_http_url!MyURL -s "Country of Residence" --expect=301 -p 8001
#register 0
}
define host{
host_name www.example.com
address www.example.com
max_check_attempts 5
check_period 24x7
contact_groups contact_group
notification_period 24x7
}
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
-
- Posts: 329
- Joined: Fri Jul 24, 2015 11:04 am
Re: Check_HTTP query
It would appear after lots of research that what I need is something called check_url, as referenced by a possible solution to my problem at
http://stackoverflow.com/questions/9246 ... ith-nagios
but when I created check_url.pl using the code found at:
and attempted to run it, I got:
I know you don't normally provide support for plugins, but I was just wondering if I'd created this.pl file correctly by simply copying and pasting the code from the web page to VIM on my Nagios master and saving it as check_url.pl?
Thanks in advance
Pete
http://stackoverflow.com/questions/9246 ... ith-nagios
but when I created check_url.pl using the code found at:
Code: Select all
https://exchange.nagios.org/directory/Plugins/Websites,-Forms-and-Transactions/check_url/details
Code: Select all
syntax error at ./check_url.pl line 49, near "= ;"
Execution of ./check_url.pl aborted due to compilation errors.
Thanks in advance
Pete
Re: Check_HTTP query
I don't think check_url is the solution, as all it's doing is using a different variable for -H rather then $HOSTADDRESS$. I believe what @mcapra posted above is what you are looking for, the -I variable will let you specify which server to request the hostname on.
Former Nagios Employee
Re: Check_HTTP query
Also, about importing a new plugin, place it in /usr/local/nagios/libexec and make sure permissions are similar to this default plugin:
Code: Select all
-rwxr-xr-x 1 nagios nagios 401800 Dec 30 2015 check_http
Be sure to check out the Knowledgebase for helpful articles and solutions!
-
- Posts: 329
- Joined: Fri Jul 24, 2015 11:04 am
Re: Check_HTTP query
Apologies to mcapra - I started my last post before yours, but submitted it without noticing that you'd posted in the meantime!
I'll take a good look and let you know how I get on.
Thank you
Pete
I'll take a good look and let you know how I get on.
Thank you
Pete
-
- Posts: 329
- Joined: Fri Jul 24, 2015 11:04 am
Re: Check_HTTP query
Good afternoon,
With your valuable help, I've now been able to remove the dependence on a Host ID, replacing it with a website and a URL thus:
It correctly reports OK when the status is 200 (and Critical when i set it to anything else) but apart from returning OK for single characters, won't report the presence of a string in the webpage content.
I have used the Fiddler tool to look at the web page content and i can see that the string I'm searching for is present, so i was wondering if there was any way in which i could capture the whole content of the webpage somewhere (either to console or maybe a file) to further examine it to see if what I THINK I'm looking at is what I'm ACTUALLY looking at.
FYI,
./check_http -H MyWebsite.com -u /MyURL/ --expect=200 -s "Cache"
returns:
HTTP CRITICAL: Status line output matched "200" - string 'Cache' not found on 'MyWebsite.com:80MyURL' - 374 bytes in 0.016 second response time |time=0.015948s;;;0.000000 size=374B;;;0
With your valuable help, I've now been able to remove the dependence on a Host ID, replacing it with a website and a URL thus:
Code: Select all
./check_http -H MyWebsite.com -u /MyURL/ --expect=200
I have used the Fiddler tool to look at the web page content and i can see that the string I'm searching for is present, so i was wondering if there was any way in which i could capture the whole content of the webpage somewhere (either to console or maybe a file) to further examine it to see if what I THINK I'm looking at is what I'm ACTUALLY looking at.
FYI,
./check_http -H MyWebsite.com -u /MyURL/ --expect=200 -s "Cache"
returns:
HTTP CRITICAL: Status line output matched "200" - string 'Cache' not found on 'MyWebsite.com:80MyURL' - 374 bytes in 0.016 second response time |time=0.015948s;;;0.000000 size=374B;;;0
Re: Check_HTTP query
Try running check_http in verbose mode with -v. This should output exactly what check_http is looking at.
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/