Short version: if I want to change one of the "command definitions" in the Nagios set, what is the best way to do it?

For example, I would like to add the -f (follow) flag to one of the check_http commands found in /etc/nagios-plugins/config/http.cfg. But it feels wrong to be editing those files.

Should I edit the existing commands to meet my needs? Should I add my own command to the http.cfg file to meet my needs? Is there a place where I can add my own command file?

Pointers to the docs are gladly welcomed!


Define your own command with a new name in etc/objects/commands.cfg, something like this:

define command{
        command_name    check_http
        command_line    $USER1$/check_http -I $HOSTADDRESS$ $ARG1$

define command{
        command_name    check_http_redirect
        command_line    $USER1$/check_http -I $HOSTADDRESS$ -f $ARG1$

and call it with corresponding state which you want to handle in /etc/nagios-plugins/config/http.cfg:

define service{
    use                     generic-service
    host_name               domain.com
    service_description     domain.com
    check_command           check_http_redirect!warning
    process_perf_data       0
    contact_groups          admin

An example when running from the command line:

$ check_http -H domain.com -f warning
HTTP WARNING: HTTP/1.1 301 Moved Permanently - 428 bytes in 0.003 second response time |time=0.002897s;;;0.000000 size=428B;;;0

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.