summaryrefslogtreecommitdiffstats
path: root/web/attachments/131931-check_jabber.pl
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/131931-check_jabber.pl')
-rw-r--r--web/attachments/131931-check_jabber.pl97
1 files changed, 97 insertions, 0 deletions
diff --git a/web/attachments/131931-check_jabber.pl b/web/attachments/131931-check_jabber.pl
new file mode 100644
index 0000000..1176441
--- /dev/null
+++ b/web/attachments/131931-check_jabber.pl
@@ -0,0 +1,97 @@
1#!/usr/bin/perl -w
2##################################################################
3# CHECK_JABBER.PL
4#
5# Jabber Plugin for Nagios
6# License: GPL
7# C.Doblado (cdoblado@pulsartec.com)
8# check_jabber.pl, v1.0 2005/04/27
9#
10#################################################################
11
12use strict;
13use Getopt::Std;
14use Net::Jabber qw(Client);
15
16use lib "/usr/lib/nagios/plugins/";
17use utils qw($TIMEOUT %ERRORS &print_revision);
18
19sub CheckJabber;
20sub Help;
21
22my $PROGNAME = "check_jabber";
23
24
25sub CheckJabber
26{
27 my $host=shift;
28 my $port=shift;
29 my $result;
30 my $con= new Net::Jabber::Client();
31 $con->Connect(hostname=>$host,port=>$port);
32 if ($con->Connected()){
33 $result->{NUM}=1;
34 $result->{MSG}="Jabber server OK at port $port \n";
35 $con->Disconnect();
36 }
37 else {
38 $result->{NUM}=0;
39 $result->{MSG}="Jabber server Error at port $port \n";
40 }
41 return $result;
42}
43
44
45sub Help
46{
47 print_revision($PROGNAME, '$Revision: 1.0 $');
48 print "\nCheckjabber checks the Jabber server status\n";
49 print "Usage: checkjabber.pl -s server [-p port -v version -h help] \n";
50 print " (default port is 5222) \n\n";
51}
52
53
54##### Main #####
55
56# TIMEOUT alarm
57$SIG{'ALRM'} = sub {
58 print ("ERROR: No response from server (alarm timeout)\n");
59 exit $ERRORS{"UNKNOWN"};
60};
61alarm($TIMEOUT);
62
63
64# Arguments
65my %options=();
66getopts("s:p:h:v",\%options);
67
68
69# Options
70if (defined $options{s}){
71 if (not defined $options{p}){
72 $options{p}='5222'; # default Jabber port
73 }
74 my $status=CheckJabber($options{s},$options{p});
75 print "$status->{MSG}\n";
76 if ($status->{NUM}==1) {
77 exit $ERRORS{"OK"};
78 }
79 elsif ($status->{NUM}==0) {
80 exit $ERRORS{"CRITICAL"};
81 }
82 else {
83 exit $ERRORS{"UNKNOWN"};
84 }
85}
86elsif ($options{v}) {
87 print_revision($PROGNAME, '$Revision: 1.0 $');
88 exit $ERRORS{"UNKNOWN"};
89}
90else {
91 Help;
92 exit $ERRORS{"UNKNOWN"};
93}
94
95
96
97