Can I create my own macros??

Subhendu Ghosh sghosh at sghosh.org
Wed Feb 16 14:55:51 CET 2005


On Wed, 16 Feb 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$}
>
> 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.
>

You cannot make your own macros - except for the $USERn$ and $ARGn$ macros

However - you can create a nagios contact for the jabber account and use 
$CONTACTEMAIL$

printf .... | jabberalert $CONTACTEMAIL$

-- 

-sg


-------------------------------------------------------
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