Command line format for external notification.
krimo
aait at free.fr
Wed Jun 29 13:17:29 CEST 2005
Paul L. Allen a écrit :
> 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.
>
This solution does not work ;).
>
> 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...
Thanks for your reply. I have already considered this solution but this
is not the one I prefer. If I choose this solution, that means I would
have failed in the optimal configuration of Nagios (I can't admit it ;)
). Also my script can't be used anymore if Ihave two macros containing
strings.
The best solution is to correcftly configure Nagios command line and
Iknow there 's a way to do that. It's not a problem of perl code but
Nagios configuration (it's why I post in the nagios mailing list and not
perl one). Finally, I'm not a perl coder as you have seen ;) (I prefer C
lang. but in this case I do not decide any).
Regards
aaits
-------------------------------------------------------
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_idt77&alloc_id492&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