#!/usr/bin/perl -wT
# -----------------------------------------------------------------------------
# File Name: check_ircd.pl
#
# Author: Richard Mayhew - South Africa
#
# Date: 1999/09/20
#
# $Id: check_ircd.pl 22 2002-05-07 05:35:49Z sghosh $
#
# Description: This script will check to see if an IRCD is running
# about how many users it has
#
# Email: netsaint@splash.co.za
#
# -----------------------------------------------------------------------------
# Copyright 1999 (c) Richard Mayhew
#
# Credits go to Ethan Galstad for coding Nagios
#
# If any changes are made to this script, please mail me a copy of the
# changes :)
#
# Some code taken from Charlie Cook (check_disk.pl)
#
# License GPL
#
# -----------------------------------------------------------------------------
# Date Author Reason
# ---- ------ ------
#
# 1999/09/20 RM Creation
#
# 1999/09/20 TP Changed script to use strict, more secure by
# specifying $ENV variables. The bind command is
# still insecure through. Did most of my work
# with perl -wT and 'use strict'
#
# test using check_ircd.pl (irc-2.mit.edu|irc.erols.com|irc.core.com)
# 2002/05/02 SG Fixed for Embedded Perl
#
# ----------------------------------------------------------------[ Require ]--
require 5.004;
# -------------------------------------------------------------------[ Uses ]--
use Socket;
use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $verbose);
use vars qw($PROGNAME);
use lib utils.pm;
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
# ----------------------------------------------------[ Function Prototypes ]--
sub print_help ();
sub print_usage ();
sub connection ($$$$);
sub bindRemote ($$$);
# -------------------------------------------------------------[ Enviroment ]--
$ENV{PATH} = "";
$ENV{ENV} = "";
$ENV{BASH_ENV} = "";
# -----------------------------------------------------------------[ Global ]--
$PROGNAME = "check_ircd";
my $NICK="ircd$$";
my $USER_INFO="monitor localhost localhost : ";
# -------------------------------------------------------------[ connection ]--
sub connection ($$$$)
{
my ($in_remotehost,$in_users,$in_warn,$in_crit) = @_;
my $state;
my $answer;
print "connection(debug): users = $in_users\n" if $verbose;
$in_users =~ s/\ //g;
if ($in_users >= 0) {
if ($in_users > $in_crit) {
$state = "CRITICAL";
$answer = "Critical Number Of Clients Connected : $in_users (Limit = $in_crit)\n";
} elsif ($in_users > $in_warn) {
$state = "WARNING";
$answer = "Warning Number Of Clients Connected : $in_users (Limit = $in_warn)\n";
} else {
$state = "OK";
$answer = "IRCD ok - Current Local Users: $in_users\n";
}
=1= |