From 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 30 Sep 2013 00:03:24 +0200 Subject: Import Nagios Plugins site Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files. --- web/attachments/131931-check_jabber.pl | 97 ++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 web/attachments/131931-check_jabber.pl (limited to 'web/attachments/131931-check_jabber.pl') 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 @@ +#!/usr/bin/perl -w +################################################################## +# CHECK_JABBER.PL +# +# Jabber Plugin for Nagios +# License: GPL +# C.Doblado (cdoblado@pulsartec.com) +# check_jabber.pl, v1.0 2005/04/27 +# +################################################################# + +use strict; +use Getopt::Std; +use Net::Jabber qw(Client); + +use lib "/usr/lib/nagios/plugins/"; +use utils qw($TIMEOUT %ERRORS &print_revision); + +sub CheckJabber; +sub Help; + +my $PROGNAME = "check_jabber"; + + +sub CheckJabber +{ + my $host=shift; + my $port=shift; + my $result; + my $con= new Net::Jabber::Client(); + $con->Connect(hostname=>$host,port=>$port); + if ($con->Connected()){ + $result->{NUM}=1; + $result->{MSG}="Jabber server OK at port $port \n"; + $con->Disconnect(); + } + else { + $result->{NUM}=0; + $result->{MSG}="Jabber server Error at port $port \n"; + } + return $result; +} + + +sub Help +{ + print_revision($PROGNAME, '$Revision: 1.0 $'); + print "\nCheckjabber checks the Jabber server status\n"; + print "Usage: checkjabber.pl -s server [-p port -v version -h help] \n"; + print " (default port is 5222) \n\n"; +} + + +##### Main ##### + +# TIMEOUT alarm +$SIG{'ALRM'} = sub { + print ("ERROR: No response from server (alarm timeout)\n"); + exit $ERRORS{"UNKNOWN"}; +}; +alarm($TIMEOUT); + + +# Arguments +my %options=(); +getopts("s:p:h:v",\%options); + + +# Options +if (defined $options{s}){ + if (not defined $options{p}){ + $options{p}='5222'; # default Jabber port + } + my $status=CheckJabber($options{s},$options{p}); + print "$status->{MSG}\n"; + if ($status->{NUM}==1) { + exit $ERRORS{"OK"}; + } + elsif ($status->{NUM}==0) { + exit $ERRORS{"CRITICAL"}; + } + else { + exit $ERRORS{"UNKNOWN"}; + } +} +elsif ($options{v}) { + print_revision($PROGNAME, '$Revision: 1.0 $'); + exit $ERRORS{"UNKNOWN"}; +} +else { + Help; + exit $ERRORS{"UNKNOWN"}; +} + + + + -- cgit v1.2.3-74-g34f1