summaryrefslogtreecommitdiffstats
path: root/contrib/nagios_sendim.pl
diff options
context:
space:
mode:
authorSubhendu Ghosh <sghosh@users.sourceforge.net>2002-11-18 21:58:58 (GMT)
committerSubhendu Ghosh <sghosh@users.sourceforge.net>2002-11-18 21:58:58 (GMT)
commite799d3f2549e808a6a96dc41a6dac783aef648c2 (patch)
tree1fa0577136c77559a2f88dba8aeea0bd6282036c /contrib/nagios_sendim.pl
parent6b2b23058730c44fea2e802076ff65388860c94a (diff)
downloadmonitoring-plugins-e799d3f2549e808a6a96dc41a6dac783aef648c2.tar.gz
javaproc, sendim
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@211 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'contrib/nagios_sendim.pl')
-rw-r--r--contrib/nagios_sendim.pl66
1 files changed, 66 insertions, 0 deletions
diff --git a/contrib/nagios_sendim.pl b/contrib/nagios_sendim.pl
new file mode 100644
index 0000000..02870a6
--- /dev/null
+++ b/contrib/nagios_sendim.pl
@@ -0,0 +1,66 @@
1#!/usr/bin/perl -w
2#
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
5#
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
8#
9# Please check http://www.jabber.org and http://www.jabberstudio.org for more information on Jabber Instant Messaging
10
11
12use Net::Jabber qw(Client);
13use Getopt::Std;
14
15my $tmp;
16my $mensagem="";
17getopts("u:p:t:");
18if ( (!defined($opt_u)) || (!defined($opt_p)) || (!defined($opt_t)))
19 {
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";
23 exit;
24 }
25
26my @buf=split('@',$opt_u);
27my $login=$buf[0];
28@buf=split('/',$buf[1]);
29my $server=$buf[0];
30my $resource=$buf[1] || "nagios";
31my $password=$opt_p;
32my $jid_dest=$opt_t;
33my $debug=0; # Set debug=1 to enable output of debug information
34
35while ($tmp=<STDIN>)
36{
37 $mensagem.=$tmp;
38}
39
40print "LOGIN: $login\nSERVER: $server\nRESOURCE: $resource\n" if $debug;
41print "TO: $jid_dest\n" if $debug;
42
43$Con1 = new Net::Jabber::Client();
44$Con1->Connect(hostname=>$server);
45
46 if ($Con1->Connected()) {
47 print "CON1: We are connected to the server...\n" if $debug;
48 }
49
50 @result1 = $Con1->AuthSend(username=>$login,
51 password=>$password,
52 resource=>$resource);
53
54
55$Con1->PresenceSend();
56$Con1->Process(1);
57
58@result1=$Con1->MessageSend( to=>$jid_dest,
59 subject=>"nagios",
60 body=>$mensagem,
61 type=>"chat",
62 priority=>1);
63
64$Con1->Process(1);
65$Con1->Disconnect();
66exit;