Command line format for external notification.

Paul L. Allen pla at softflare.com
Wed Jun 29 12:46:19 CEST 2005


Andreas Ericsson writes: 

> aait at free.fr wrote:
>> Example: 
>> 
>> define command{
>>    command_name    notify-by-xmlrpc
>>    command_line    /usr/lib/nagios/myagent/notification/my_script
>> $HOSTNAME$ CRITICAL $OUTPUT$ $SERVICEDESC$ $DATETIME$
>>    }
> 
> Put single quotes around each macro.

As the perl motto has it, "there's more than one way to do it."  An
alternative solution would be to rearrange the parameters so that
$OUTPUT$ is the last parameter.  Then after shifting out the hostname,
etc., what is left is $OUTPUT$. 

 $hostname = shift;
 $status = shift;
 $servicedesc = shift;
 $datetime = shift;
 $output = join(' ', @ARGV); 

Back in the days before perl had references, this sort of trick was the
standard way of coding subroutines which took multiple parameters, one of
which was an array - pass the scalars first and the array last. 

This approach is not better than yours, it's just one that I'd hope a
competent perl coder would have used instinctively.  Mr Aait didn't... 

-- 
Paul Allen
Softflare Support 



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
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