Default argument values for nagios check commands

Andreas Ericsson ae at op5.se
Fri Nov 5 10:59:16 CET 2010


On 11/04/2010 03:50 PM, Bostjan Skufca wrote:
> Hi all!
> 
> I was wondering if it is possible (or would be easy to implement) default
> values for nagios check commands.

Try and find out ;)

> Let me explain.
> 
> I would like my nagios configuration to be as transparent as possible, which
> also means it should be as small as possible (no duplicated definitions).
> This works fine if you have homogenic host family. Once you start hitting
> diversity things are not that simple anymore. Anyway...
> 
> Currently I have to have two similar command definitions to achieve the
> effect desired, one is fixed and other has variable arguments:
> 
> ###### Start of current config
> #################################################
> ### First command
> define command{
>          command_name    check-metric_sys-intr
>          command_line    $USER3$/check_ganglia $HOSTNAME$ sys_intr less 2000
> 5000
> }
> ### Second command for hosts that do not fall into the average
> define command{
>          command_name    check-metric_sys-intr_custom
>          command_line    $USER3$/check_ganglia $HOSTNAME$ sys_intr less
> $ARG1$ $ARG2$
> }
> 
> 
> ##### Then there are service definitions
> ### For average host
> define service{
>          use service_check-metric_sys-intr    # Defined previously as
> template with "register 0"
>          host_name    host-average.example.net
> }
> ### For not-so-average host
> define service{
>          use service_check-metric_sys-intr
>          host_name    host-exception.example.net
>          check_command   check-metric_sys-intr_custom!5000!10000
> }
> ###### End of current config
> #################################################
> 
> 
> 
> I would like those arguments ARG1 and ARG2 to have some way of defining
> default values,  and the final config should look something like this (note
> the colon operator for default values and only one command definition)
> 
> 
> 
> ###### Start of desired config
> #################################################
> define command{
>          command_name    check-metric_sys-intr
>          command_line    $USER3$/check_ganglia $HOSTNAME$ sys_intr less
> $ARG1:2000$ $ARG2:5000$
> }
> 

Neat idea.

I don't have time for it just now though, so unless someone else steps
in, this will have to wait. If you can't do it yourself, or pay someone
to do it for you, I'd suggest you get an account at tracker.nagios.org
and submit this as a feature-request.

Since it's already possible to do with a fairly easy workaround, it
probably won't get a high priority though, but it might be fun as an
exercise for someone who wants to try out their programming wings.

> 
> I have not yet dug into nagios internals, but would this be possible without
> too much hassle?

Yes. Look in get_raw_command_line_r() and add your 30-40 lines of code there.

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev




More information about the Developers mailing list