Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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