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.
-
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"
Mike : You might want to define a separate command like "check_http_text" to differentiate it from the default "check_http"From TCampbell -
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"
Funky Si : Thanks that worked great. One question -w and -c are they what determine if the alerts is a warning or critical?Brent : Yes, those are timeouts in seconds. (I just grabbed the line I use in my nagios file - which uses custom timeouts)From Brent -
You can set the following in the Nagios config too see what command is actually be executed ( see the expansion of the full command):
debug_level=-1 debug_verbosity=2 debug_file=/usr/local/nagios/var/nagios.debug
Funky Si : Are these options available on nagios 2.11 or were they only introduced in nagios 3?From Kyle Brandt
0 comments:
Post a Comment