I am trying to use Icinga to monitor a website for a particular string. When I run the plugin from the command line, it seems to work fine, but in Icinga-Web, it always shows up as successful no matter what I enter for the string.
#Doesn't Work - always returns ok
define service {
host_name mywebserver
service_description Check Website
servicegroups Websites
check_command check_http!-s "no such string" -H www.mysite.com -u /apath/ -t 7
use generic-service
notification_interval 60 ; set > 0 if you want to be renotified
}
The wierd thing is if I run the plugin located in /usr/lib/nagios/plugins/check_http as follows, it gives me what I would expect:
./check_http -H www.mysite.com -u "/apath/" -s "no such string"
HTTP CRITICAL: HTTP/1.1 200 OK - string 'no such string' not found on...
Why would this be?
Best Answer
Clearly your manual test and your Icinga conf are different.
Go find your definition for the check_http command. It is almost certainly not processing the ARGs you are passing to it, at least not in the way you think it is.
I'm guessing you're using Ubuntu or Debian, judging by the plugin path. Go look in
/etc/nagios-plugins/config/http.cfg
, and you'll probably find something like this:Notice how it doesn't use any of ARG1, ARG2, etc., so it completely ignores all of
-s "no such string" -H www.mysite.com -u /apath/ -t 7
You should write a new command that accepts the arguments you want to use, and then change your check_command to something like
check_http_path_expect!/apath/!"no such string"
, as an example.Reading the docs page Understanding Macros and How They Work will help.