[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3master/usr/share/se3/scripts-alertes/ -> check_breeze (source)

   1  #! /usr/bin/perl -wT
   2  
   3  
   4  use strict;
   5  use Getopt::Long;
   6  use vars qw($opt_V $opt_h $opt_w $opt_c $opt_H $opt_C $PROGNAME);
   7  use lib "/usr/lib/nagios/plugins" ;
   8  use utils qw(%ERRORS &print_revision &support &usage);
   9  
  10  $PROGNAME = "check_breeze";
  11  
  12  sub print_help ();
  13  sub print_usage ();
  14  
  15  $ENV{'PATH'}='';
  16  $ENV{'BASH_ENV'}=''; 
  17  $ENV{'ENV'}='';
  18  
  19  Getopt::Long::Configure('bundling');
  20  GetOptions
  21      ("V"   => \$opt_V, "version"    => \$opt_V,
  22       "h"   => \$opt_h, "help"       => \$opt_h,
  23       "w=s" => \$opt_w, "warning=s"  => \$opt_w,
  24       "c=s" => \$opt_c, "critical=s" => \$opt_c,
  25       "H=s" => \$opt_H, "hostname=s" => \$opt_H,
  26       "C=s" => \$opt_C, "community=s" => \$opt_C);
  27  
  28  if ($opt_V) {
  29      print_revision($PROGNAME,'$Revision: 1.5 $');
  30      exit $ERRORS{'OK'};
  31  }
  32  
  33  if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
  34  
  35  ($opt_H) || usage("Host name/address not specified\n");
  36  my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/);
  37  ($host) || usage("Invalid host: $opt_H\n");
  38  
  39  ($opt_w) || usage("Warning threshold not specified\n");
  40  my $warning = $1 if ($opt_w =~ /([0-9]{1,2}|100)+/);
  41  ($warning) || usage("Invalid warning threshold: $opt_w\n");
  42  
  43  ($opt_c) || usage("Critical threshold not specified\n");
  44  my $critical = $1 if ($opt_c =~ /([0-9]{1,2}|100)/);
  45  ($critical) || usage("Invalid critical threshold: $opt_c\n");
  46  
  47  ($opt_C) || ($opt_C = "public") ;
  48  
  49  my $sig=0;
  50  $sig = `/usr/bin/snmpget $host $opt_C .1.3.6.1.4.1.710.3.2.3.1.3.0`;
  51  my @test=split(/ /,$sig);
  52  $sig=$test[2];
  53  $sig=int($sig);
  54  if ($sig>100){$sig=100}
  55  
  56  print "Signal Strength at: $sig%\n";
  57  
  58  exit $ERRORS{'CRITICAL'} if ($sig<$critical);
  59  exit $ERRORS{'WARNING'} if ($sig<$warning);
  60  exit $ERRORS{'OK'};
  61  
  62  
  63  sub print_usage () {
  64      print "Usage: $PROGNAME -H <host> [-C community] -w <warn> -c <crit>\n";
  65  }
  66  
  67  sub print_help () {
  68      print_revision($PROGNAME,'$Revision: 1.5 $');
  69      print "Copyright (c) 2000 Jeffrey Blank/Karl DeBisschop
  70  
  71  This plugin reports the signal strength of a Breezecom wireless equipment
  72  
  73  ";
  74      print_usage();
  75      print "
  76  -H, --hostname=HOST
  77     Name or IP address of host to check
  78  -C, --community=community
  79     SNMPv1 community (default public)
  80  -w, --warning=INTEGER
  81     Percentage strength below which a WARNING status will result
  82  -c, --critical=INTEGER
  83     Percentage strength below which a CRITICAL status will result
  84  
  85  ";
  86      support();
  87  }


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1