How to use the $CONTACTADDRESSx$ for winpopup messages to serveral hosts?

Andreas Ericsson ae at op5.se
Mon Jan 17 14:41:21 CET 2005


Ralf Gross wrote:
> Hi,
> 
> I recently moved from nagios 1.2 to nagios 2.0b1.
> 
> With 1.2, I used the alias directive (macro $CONTACTALIAS$) in
> contacts.cfg to send winpopup alerts to this windows clients. Nagios 2.0b1
> has the new $CONTACTADDRESSx$ macro, I can define up to 6 different
> addresses for one contact.
> The winpopup section in my misccommands.cfg looks like this:
> 
> ...nagios stuff...| /usr/bin/smbclient -U "Nagios" -M $CONTACTALIAS$
> 
> If a contact has just one address defined, I could just replace
> $CONTACTALIAS$ with $CONTACTADDRESS1$. But some people have serveral hosts
> which should get the popup alert.
> Do I have to create different commands in misccommands.cfg, eg.
> notify-by-winpopup-host-1, notify-by-winpopup-host-2...? I think there
> must be a simpler way to accomplish that.
> Any ideas?
> 

Create a wrapper script that can handle several arguments and doesn't 
barf if it is fed an empty one (in case you want to quote it in the 
command definition).

Iterate like so;
msg="$1"
network_user="$2"
shift; shift
for host_to_send_to in "$@"; do
    test -z "$host_to_send_to" && continue
    echo "$msg" | smbclient -U "$network_user" -M "$host_to_send_to"
done

Simple enough.

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Lead Developer


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
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