I want to call a command directly from a Nagios service file, instead of passing arguments clumsily to commands.cfg. For example I want do this:
define service {
service_description footest
check_command $USER1$/check_http example.com -u http://example.com/index.html
use generic-service
host_name example
}
But I get a:
Error: Service check command '/usr/share/nagios/libexec/check_http example.com -u http://example.com/index.html' specified in service 'footest' for host 'example' not defined anywhere!
If you absolutely insist on doing this, which is a really, really terrible idea, this snippet should work:
Seriously, though, please don't.
Nagios best practice is to split your check into a command and check, a check_command is defined as a command like
before it should be used in a service check.
I have had success with a check_any command definition in commands.cfg
Which I use in a definition like:
You need to break it into two parts, the first the check_command and the second the check itself.
Create the template to check a URL:
Use the template to check a specific URL (www.example.com in this case):