Can I create my own macros??

Andreas Ericsson ae at op5.se
Wed Feb 16 11:26:48 CET 2005


matato at pregi.net wrote:
> Hi,
>   I've installed nagios and used jabber as its chatlert notification. What
>   I did was to pipe the different macros to a perl script that I made such
>   that the script will do the chat alert thing.
> The script named jabberalert.pl looks like this:
> 
> #!/usr/local/bin/perl
> use warnings;
> use strict;
> 
> use Notice;
> our @array;
> our $contact = shift @ARGV;
> 
> while(<STDIN>){
> push @array, $_;
> }
> 
> 
> my $alert = new Notice;
> $alert->contact_jabber('myaccount at jabber.server');
> $alert->message('Nagios', "@array");
> $alert->jabber;
> 
> 
> The command definition for chatalert looks like this:
> define command{
>         command_name    hostchatalert
>         command_line    /usr/bin/printf "HOST $HOSTSTATE$!!!\n\nHost:
>         $HOSTNAME$($HOSTALIAS$)\nAddress: $HOSTADDRESS$\nLastCheck: $DATETIME$\n\nAlert Message:\n $OUTPUT$" | jabberalert.pl
> }
> 
> For now, the script works fine with a hard coded contact_jabber. But what
> I wanted to do is to use a variable in place of that contact_jabber, let's
> say:$alert->contact_jabber("$contact");
> 
> Upon reading the manual of the macros, I found out that the Email and
> pager really exist. Is it possible if I could just create a jabber entry
> in the contacts.cfg like that of the email and pager so that I can use the
> $CONTACTJABBER$ in my command definition of chatalert like this:
> define command{
>         command_name    hostchatalert
>         command_line    /usr/bin/printf "HOST $HOSTSTATE$!!!\n\nHost:
>         $HOSTNAME$($HOSTALIAS$)\nAddress: $HOSTADDRESS$\nLastCheck: $DATETIME$\n\nAlert Message:\n $OUTPUT$" | jabberalert.pl
> $CONTACTJABBER$}
> 

No. In nagios 2.x you could use the address1 through address6 for that 
though, or simply add a new contact or do any of a hundred different 
things. What you cannot do is invent macros on the fly.

> and change my perl script such that these line:
>   $alert->contact_jabber('myaccount at jabber.server');
> 
> will look like this.
>   my $contact = shift @ARGV;
>   $alert->contact_jabber("$contact");
> 
> 
> Or do you have any other idea??
> 
> thanks.
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&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
> 

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


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&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