1

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?

Daniel
  • 251
  • 3
  • 12
  • Perhaps something about your environment vs the environment of the icinga user? Login to the server as the user Ichinga is running as and try running the command manually. – Zoredache Jul 10 '13 at 16:51
  • I just tried running it as the "nagios" user (as specified in icinga.cfg) and get the same "HTTP CRITICAL" output. – Daniel Jul 10 '13 at 17:08
  • which version of plugins? – Marcel Jul 10 '13 at 17:35
  • you're missing "-t 7" in your manual test. plus post the command definition of 'check_http' too. further, show the exact command line and env of the user when testing, as explained here: https://wiki.icinga.org/display/testing/Icinga+Plugin+Testing – dnsmichi Jul 10 '13 at 17:48
  • root@icinga:/usr/lib/nagios/plugins# sudo -u nagios /usr/lib/nagios/plugins/check_http -H www.mysite.com -u "/apath/" -s "not a string" -t 7 Result: HTTP CRITICAL: HTTP/1.1 200 OK - string 'not a string' not found on... – Daniel Jul 10 '13 at 18:21

1 Answers1

1

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:

# 'check_http' command definition
define command {
    command_name    check_http
    command_line    /usr/lib/nagios/plugins/check_http -H '$HOSTADDRESS$' -I '$HOSTADDRESS$' -f follow
}

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.

Keith
  • 4,627
  • 14
  • 25