forward alerts to jabber clients ?

thomas.seglard.enata at cnp.fr thomas.seglard.enata at cnp.fr
Fri Apr 7 16:49:19 CEST 2006


Hello,

is there a way to send hobbit's alerts to a jabber's client ? I've done a 
script but it doesn't seem to work ("Cannot connect( )") and I don't know 
why ! So, I will try to use rss and forward the threads to jabber via 
rrs2jabber. If someone got a working script or a better idea, you're 
welcome !

Thomas

Here is my perl script alertjabber.pl. You can use it by adding the 
following line to hobbit-alerts.cfg :

SCRIPT /Soft/HOBBIT-4.1.2p1/server/bin/alertjabber.pl 
hobbit at myjabber.server.org REPEAT=10

#!/usr/bin/perl
#
#######################################################
#
# Author Thomas Seglard
# Created from various code examples found on the web
# Feel free to use or modify as needed to suit your needs
# Description :
# Get hobbit's variables and send them to jabber's server
#
#######################################################

use strict;
use Net::Jabber qw(Client) ;
use Net::Jabber qw(Message) ;
use Net::Jabber qw(Protocol) ;
use Net::Jabber qw(Presence) ;

use constant SERVER    => 'myjabber.server.org';
use constant PORT      => 5222;
use constant USER      => 'hobbit';
use constant PASSWORD  => 'hobbit';
use constant RESOURCE  => 'Psi';
use constant MAXWAIT   => 2 ;
my $MSG  = $ENV{'BBALPHAMSG'};
my $DST  = $ENV{'RCPT'};
my $HST  = $ENV{'BBHOSTSVC'};

my $connection = Net::Jabber::Client->new();
$connection->Connect( "hostname" => SERVER,"port" => PORT )  or die
"Cannot connect ($!)\n";

my @result = $connection->AuthSend( "username" => USER,"password" =>
PASSWORD,"resource" => RESOURCE );
if ($result[0] ne "ok") {
 die "Ident/Auth with server failed: $result[0] - $result[1]\n";
}
my $message = Net::Jabber::Message->new();
 $message->SetMessage( "to"                 => $DST,
                         "subject"      => "Alerte $HST",
                         "type"         => "chat",
                         "body"         => $MSG);

   $connection->Send($message);
   sleep(MAXWAIT);
$connection->Disconnect();
exit;

Ce message (et toutes ses pieces jointes eventuelles) est confidentiel et etabli a l'intention exclusive de ses destinataires.
Toute utilisation de ce message non conforme a sa destination, toute diffusion ou toute publication, totale ou partielle, est
interdite, sauf autorisation expresse.
L'internet ne permettant pas d'assurer l'integrite de ce message, CNP Assurances et ses filiales declinent toute responsabilite
au titre de ce message, s'il a ete altere, deforme ou falsifie.

*****

This message and any attachments (the "message") are confidential and intended solely for the addressees.
Any unauthorised use or dissemination is prohibited.
E-mails are susceptible to alteration.
Neither CNP Assurances nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20060407/834dc74b/attachment.html>


More information about the Xymon mailing list