How to access user-defined service variables in a command object

Paul M. Dubuc work at paul.dubuc.org
Mon Feb 8 22:14:37 CET 2010


I should have made more clear what I am trying to do below.  I know I can 
access the service __ALARM_NUMBER from the command definition by giving the 
literal host_name and service description like this (I've updated the service 
definition in my previous example to illustrate):

$_SERVICE_ALARM_NUMBER:localhost:DUMMY

but I would like the command definition to be able to do this using the macro 
names $HOSTNAME$ and $SERVICEDESC$ so that one command definition works for 
all services that use it for notification.  Is there a way to do this?  I 
would not like to have to define a separate command and contact group for 
every alarm number.

Also, I'm using Nagios 3.2.0.

Thanks,
Paul Dubuc

Paul M. Dubuc wrote:
> I'm trying to integrate the use of an internally developed alarm 
> generation command into our Nagios configuration.  So I want to define 
> an Nagios command object that calls this command with arguments specific 
> to the service that is generating the status condition that generates 
> the alarm.  One of the arguments is an alarm number.  I can set this 
> number in the service definition as a user defined variable:
> 
> define service{
 >     host_name localhost
 >     service_description DUMMY
>     ...
>     __ALARM_NUMBER   123
> }
> 
> Is it possible to access this variable in the command definition using 
> on-demand macros?  I tried to do this in the following way, but it 
> doesn't seem to work:
> 
> define command{
>     command_name    notify-service-by-alarm
>     command_line    /usr/local/bin/sendalarm $HOSTALIAS$ 
> $_SERVICE_ALARM_NUMBER:HOSTNAME:SERVICEDESC$ $SERVICESTATE$ 
> $SERVICEDESC$ $SERVICEOUTPUT$
> }
> 
> Is there an alternative?
> 
> Thanks,
> 
> Paul M. Dubuc
> 

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
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