Where can arguments go?

Jonathan Nilsson jnilsson at uci.edu
Wed Feb 22 01:06:52 CET 2012


It looks like you are using variables in the wrong location. Those should
go in the command definition. See below for a sample, and hopefully you can
adapt it to your specific needs.


> I'm running into confusion, because I need to specify a
> port number in the host definition, and I can't really see how to do it.
>

I'm going to assume that "check-snmp-switch-alive" is a script that you
have written and that the command from the command-line is:

/usr/local/nagios/libexec/check-snmp-switch-alive <hostname> -p <portnumber>

in the host/service definitions, the check_command separates arguments with
the exclamation symbol "!" like this:


> define host {
>        name                    snmp-switch     ; The name of this host
> template
>        use                     generic-switch
>        #check_command          check-host-alive ; Default command to check
> if routers
> are "alive"
>        check_command           check-snmp-switch-alive!<port>!<arg2>
>        register                0               ; DONT REGISTER THIS - ITS
> JUST A TEMPLATE
> }
>

where <port> would be the port number and <arg2> could be any string of
other options, including "-[a-z]" switches and their arguments. You then
define the command like this:

define command {
      command_name check-snmp-switch-alive
      command_line /usr/local/nagios/libexec/check-snmp-switch-alive
$HOSTNAME$ -p $ARG1$ $ARG2$
}


> Is this a possible / sane thing to do?  Is this the right way to approach
> it, or am I missing a way that actually makes sense?
>

Yes, I would say that this is appropriate for a switch/router. Personally,
I usually don't overwrite the default host check_command since check_ping
is fine, and instead add additional services as needed, such as SNMP checks
to get more info.

Good luck!
--
Jonathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20120221/f7748705/attachment.html>
-------------- next part --------------
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
-------------- next part --------------
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null


More information about the Users mailing list