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.
@t3dus, This worked for me. Just create a new configuration file myhost.conf in /usr/local/nagios/etc/objects. And paste the following definitions inside the file. After that import this file in /usr/local/nagios/etc/nagios.cfg and restart nagios with service nagios restart.
The Only way I can get it to actually check the string and generate an error when the string is missing from the site is to setup the code like this. Every other way I try it doesn't give an error when the string doesn't match the site.
Clearly something wrong with the way nagios checks this if I can't do it any other way to make it work...
define command{
command_name check_http_sg
command_line $USER1$/check_http -H snapgeek.com -u /meet-matt/ -R "2017"
}
define service{
use generic-service ; Name of service template to use
host_name snapgeek.com
service_description Keyword
check_command check_http_sg
notifications_enabled 1
}
If I use the below code then I can put ANY KEYWORD in there at all even if it doesn't exist on the site and the check will not fail! This is a huge bug on Nagios end!
define command{
command_name check_http_test
command_line $USER1$/check_http -H $HOSTADDRESS$ -u $ARG1$ -R $ARGS2$
}
define service{
use generic-service ; Name of service template to use
host_name snapgeek.com
service_description URL test
check_command check_http_test!/meet-matt/!2017
notifications_enabled 1
}
-s, --string=STRING
String to expect in the content
I'm not sure I even care to use the -u either anymore. I just want it to check text on the main site of my domains to see if it exists. I'll try a -s one and see where that goes.
define command{
command_name check_http_ffg
command_line $USER1$/check_http -H fairfieldgeeks.com --ssl -u / -R "phpBB"
}
define service{
use generic-service ; Name of service template to use
host_name fairfieldgeeks.com
service_description Keyword
check_command check_http_ffg
notifications_enabled 1
}
This one says the site is ok. As expected if I change the "phpBB" to "thisisanerror" it will error out with: HTTP CRITICAL: HTTP/1.1 200 OK - string 'thisisanerror' not found on 'https://fairfieldgeeks.com:443/' - 40840 bytes in 2.617 second response time
define command{
command_name check_http_ff
command_line $USER1$/check_http -H fairfieldgeeks.com --ssl -u / -s "phpBB"
}
define service{
use generic-service ; Name of service template to use
host_name fairfieldgeeks.com
service_description Keyword test1
check_command check_http_ff
notifications_enabled 1
}
This one errors out from the get go.. with "HTTP CRITICAL: HTTP/1.1 400 Bad Request - string '$' not found on 'https://fairfieldgeeks.com:443$' - 1383 bytes in 0.285 second response time" so yeah..
You have a typo in your configs. It should be $ARG1$ and $ARG2$ but you have $ARGS1$ and $ARGS2$ (plural). That is why you are seeing the string '$' not found message in the output, because Core does not recognize $ARGSn$ as a valid macro, but as a literal string.
My next question is how exactly does nagios go to look for strings because some strings I have used are ON the site yet it fails to find them while it can find others.
Also I seem to have to use either --ssl or -f follow otherwise these checks fail still.
t3dus wrote:My next question is how exactly does nagios go to look for strings because some strings I have used are ON the site yet it fails to find them while it can find others.
Usually when this happens it is because the string is populated by a Javascript call, or is otherwise not present in the raw text returned from the HTTP call. check_http only parses the exact text, it does not have any JS engine embedded to handle dynamic page-building.
t3dus wrote:Also I seem to have to use either --ssl or -f follow otherwise these checks fail still.
-f follow is fairly common to have, particularly in pages that do a lot of routing like WordPress does. It's just telling check_http to follow a redirect instead of treating it as a non-OK state. The --ssl should only be needed for HTTPS sites.
Last edited by tmcdonald on Fri Dec 08, 2017 11:50 am, edited 1 time in total.
Reason:Typo
t3dus wrote:Also I seem to have to use either --ssl or -f follow otherwise these checks fail still.
-f follow is fairly common to have, particularly in pages that do a lot of routing like WordPress does. It's just telling check_http to follow a redirect instead of treating it as a non-OK state. The --ssl should only be needed for HTTP sites.
Ok so I see how -f follow is important in my case. So --ssl for HTTP not HTTPS? All my websites use HTTPS