PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|C|nagios-plugins-1.4.10|contrib|check_apache.pl =

page 1 of 3



#!/usr/bin/perl
#
# (c)2001 Sebastian Hetze, Linux Information Systems AG
# send bug reports to <S.Hetze@Linux-AG.com>
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# you should have received a copy of the GNU General Public License
# along with this program (or with Nagios);  if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA
#
#
# Check apache status information provided by mod_status to find
# out about the load (number of servers working) and the
# performance (average response time for recent requests).
#
# Usage:
# check_apache -H <host> [-lhV] [-w <warn>] [-c <crit>] [-u <url>]
#
# check_apache <host> <warn> <crit> <url> (if you cannot avoid it)
#

use LWP::UserAgent;
use URI::URL;
use Getopt::Long;
Getopt::Long::Configure('bundling');

$version=0.01;

my %ERRORS = ('UNKNOWN' , '-1',
              'OK' , '0',
              'WARNING', '1',
              'CRITICAL', '2');


#
#              some default values
#
$perf_w=500;
$perf_c=1000;
$load_w=20;
$load_c=30;
$TIMEOUT=15;

#
#              get command line options the regular way
#
GetOptions
        ("V"   => \$opt_V, "version"       => \$opt_V,
         "h"   => \$opt_h, "help"          => \$opt_h,
         "l"   => \$opt_l, "load"          => \$opt_l,
         "v" => \$verbose, "verbose"       => \$verbose,
         "w=s" => \$opt_w, "warning=s"     => \$opt_w,
         "c=s" => \$opt_c, "critical=s"    => \$opt_c,
         "H=s" => \$opt_H, "hostname=s"    => \$opt_H,
         "u=s" => \$opt_u, "url=s"         => \$opt_u);

#
#              handle the verbose stuff first
#
if ($opt_V) {
        print "\n";
        print "check_apache nagios plugin version $version\n";
        print "\n";
        print "The nagios plugins come with ABSOLUTELY NO WARRANTY.  You may redistribute\n";
        print "copies of the plugins under the terms of the GNU General Public License.\n";
        print "For more information about these matters, see the file named COPYING.\n";
        print "\n";
        print "Copyright (c) 2001 Sebastian Hetze  Linux Information Systems AG\n";
        print "\n";
        print "\n";
        exit $ERRORS{'UNKNOWN'};
} 

if ($opt_h) {
        print_help();
        exit $ERRORS{'UNKNOWN'};
}

#
#              now get options the weired way and set the defaults
#              if nothing else is provided
#
$opt_H = shift unless ($opt_H);
print_usage() unless ($opt_H);

if($opt_l) {
   $autostring="?auto";
   ($opt_w) || ($opt_w = shift) || ($opt_w = $load_w);
   $warn = $1 if ($opt_w =~ /([0-9]+)/);
   ($opt_c) || ($opt_c = shift) || ($opt_c = $load_c);
=1=

= PAGE 1 = NEXT > |2|3

UP TO ROOT | UP TO DIR

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.0406818 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)