I want to create a nagios check that test if a certain file is available on a public website and if that file contains a certain line of text.

From the command line I have been executing:

./check_http -H -u -t 5 -s "Company Name"

Which passes OK and fails if I delete the file or change the text it is looking for.

Now I want to incorporate this into my nagios config files.

I create a Host which has the address of the ip address above and create a service as follows.

check_command check_http!-u /index.html -t 5 -s "Company Name"

But if I change the filename it is checking or the text it is checking it still passes even though I know they don't exist on the website.

What am I doing wrong I think I must be testing a different file or something for it to always pass.

  • Can you have a look at the web server logs and see exactly what the request is, if it's a 200, or 404, or 500 etc, to begin with? – Xerxes Jun 2 '09 at 13:27
  • Can you show us the command_line value in the command definition as well? – Kyle Brandt Jun 2 '09 at 13:33

When you are executing the command manually, you are calling /usr/lib/nagios/plugins/check_http correct?

When you are calling check_http from the nagios config, it looks at /etc/nagios-plugins/config/http.cfg to determine the check_http command arguments.

What you need to do is create a custom check like:

define command {
    command_name                   check_web_content
    command_line                   $USER1$/check_http -H $HOSTADDRESS$ -t 60 -w 15 -c 45 -u $ARG1$ -s $ARG2$


Then in your service configuration your check_command should be something like:

check_command check_web_content!http://www.domain.com/index.html!"Text on site"
  • Thanks that worked great. One question -w and -c are they what determine if the alerts is a warning or critical? – Simon Foster Jun 2 '09 at 13:52
  • Yes, those are timeouts in seconds. (I just grabbed the line I use in my nagios file - which uses custom timeouts) – Brent Jun 2 '09 at 14:03

First you need to define a command:

define command {
    command_name    check_http
    command_line    $USER1$/check_http -H $HOSTADDRESS$ \
                    -u $ARG1$ -t $ARG2$ -s $ARG3$

Then for your host entry define the check_command as follows:

check_command    check_http!/index.html!5!"Company Name"
  • 2
    You might want to define a separate command like "check_http_text" to differentiate it from the default "check_http" – Mike Fiedler Jun 2 '09 at 13:40

You can set the following in the Nagios config too see what command is actually be executed ( see the expansion of the full command):

  • 2
    Are these options available on nagios 2.11 or were they only introduced in nagios 3? – Simon Foster Jun 2 '09 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.