Linux – Nagios check for a file on a website

linuxmonitoringnagioswebsite

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 192.168.1.2 -u http://192.168.1.2/index.html -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.

Best Answer

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"