3 # SENDIM 1.0 by Sergio Freire (sergio-s-freire@ptinovacao.pt)
4 # Nagios plugin to send notifications using instant messages through a jabber server
6 # Note: a) you can send messages to several different IM systems like ICQ,AIM,MSN,etc...
7 # b) to test this plugin you can execute it with the arguments needed and write the message followed by a CTRL+D
9 # Please check http://www.jabber.org and http://www.jabberstudio.org for more information on Jabber Instant Messaging
12 use Net
::Jabber
qw(Client);
18 if ( (!defined($opt_u)) || (!defined($opt_p)) || (!defined($opt_t)))
20 print "USE: sendim -u user_JID -p password -t destination_JID\n";
21 print 'EXAMPLE: sendim -u nagios@jabber.org -p nagios -t bitcoder@nagios.org'."\n";
22 print " (send an instant message as user nagios\@jabber.org to bitcoder\@jabber.org)\n";
26 my @buf=split('@',$opt_u);
28 @buf=split('/',$buf[1]);
30 my $resource=$buf[1] || "nagios";
33 my $debug=0; # Set debug=1 to enable output of debug information
40 print "LOGIN: $login\nSERVER: $server\nRESOURCE: $resource\n" if $debug;
41 print "TO: $jid_dest\n" if $debug;
43 $Con1 = new Net
::Jabber
::Client
();
44 $Con1->Connect(hostname
=>$server);
46 if ($Con1->Connected()) {
47 print "CON1: We are connected to the server...\n" if $debug;
50 @result1 = $Con1->AuthSend(username
=>$login,
55 $Con1->PresenceSend();
58 @result1=$Con1->MessageSend( to
=>$jid_dest,