[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

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

   1  #! /usr/bin/perl -wT
   2  #
   3  # $Id: check_wave.pl,v 1.4 2002/10/28 13:05:08 kdebisschop Exp $
   4  
   5  
   6  use strict;
   7  use lib "/usr/lib/nagios/plugins";
   8  use utils qw($TIMEOUT %ERRORS &print_revision &support);
   9  use vars qw($PROGNAME);
  10  use Getopt::Long;
  11  use vars qw($opt_V $opt_h $verbose $opt_w $opt_c $opt_H);
  12  my (@test, $low1, $med1, $high1, $snr, $low2, $med2, $high2);
  13  my ($low, $med, $high, $lowavg, $medavg, $highavg, $tot, $ss);
  14  
  15  $PROGNAME = "check_wave";
  16  sub print_help ();
  17  sub print_usage ();
  18  
  19  $ENV{'PATH'}='';
  20  $ENV{'BASH_ENV'}='';
  21  $ENV{'ENV'}='';
  22  
  23  Getopt::Long::Configure('bundling');
  24  GetOptions
  25      ("V"   => \$opt_V, "version"    => \$opt_V,
  26       "h"   => \$opt_h, "help"       => \$opt_h,
  27       "v" => \$verbose, "verbose"  => \$verbose,
  28       "w=s" => \$opt_w, "warning=s"  => \$opt_w,
  29       "c=s" => \$opt_c, "critical=s" => \$opt_c,
  30       "H=s" => \$opt_H, "hostname=s" => \$opt_H);
  31  
  32  if ($opt_V) {
  33      print_revision($PROGNAME,'$Revision: 1.4 $'); #'
  34      exit $ERRORS{'OK'};
  35  }
  36  
  37  if ($opt_h) {
  38      print_help();
  39      exit $ERRORS{'OK'};
  40  }
  41  
  42  $opt_H = shift unless ($opt_H);
  43  print_usage() unless ($opt_H);
  44  my $host = $1 if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0]+(\.[a-zA-Z][-a-zA-Z0]+)*)$/);
  45  print_usage() unless ($host);
  46  
  47  ($opt_c) || ($opt_c = shift) || ($opt_c = 120);
  48  my $critical = $1 if ($opt_c =~ /([0-9]+)/);
  49  
  50  ($opt_w) || ($opt_w = shift) || ($opt_w = 60);
  51  my $warning = $1 if ($opt_w =~ /([0-9]+)/);
  52  
  53  $low1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`;
  54  @test = split(/ /,$low1);
  55  $low1 = $test[2];
  56  
  57  $med1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`;
  58  @test = split(/ /,$med1);
  59  $med1 = $test[2];
  60  
  61  $high1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`;
  62  @test = split(/ /,$high1);
  63  $high1 = $test[2];
  64  
  65  sleep(2);
  66  
  67  $snr = `snmpget $host public .1.3.6.1.4.1.762.2.5.2.1.17.1`;
  68  @test = split(/ /,$snr);
  69  $snr = $test[2];
  70  $snr = int($snr*25);
  71  
  72  $low2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`;
  73  @test = split(/ /,$low2);
  74  $low2 = $test[2];
  75  
  76  $med2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`;
  77  @test = split(/ /,$med2);
  78  $med2 = $test[2];
  79  
  80  $high2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`;
  81  @test = split(/ /,$high2);
  82  $high2 = $test[2];
  83  
  84  $low = $low2 - $low1;
  85  $med = $med2 - $med1;
  86  $high = $high2 - $high1;
  87  
  88  $tot = $low + $med + $high;
  89  
  90  if ($tot==0) {
  91      $ss = 0;
  92  } else {
  93      $lowavg = $low / $tot;
  94      $medavg = $med / $tot;
  95      $highavg = $high / $tot;
  96      $ss = ($medavg*50) + ($highavg*100);
  97  }
  98  
  99  printf("Signal Strength at: %3.0f%,  SNR at $snr%",$ss);
 100  
 101  if ($ss<$critical) {
 102      exit(2);
 103  } elsif ($ss<$warning) {
 104      exit(1);
 105  } else {
 106      exit(0);
 107  }
 108  
 109  
 110  sub print_usage () {
 111      print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>]\n";
 112  }
 113  
 114  sub print_help () {
 115      print_revision($PROGNAME,'$Revision: 1.4 $');
 116      print "Copyright (c) 2000 Jeffery Blank/Karl DeBisschop\n";
 117      print "\n";
 118      print_usage();
 119      print "\n";
 120      print "<warn> = Signal strength at which a warning message will be generated.\n";
 121      print "<crit> = Signal strength at which a critical message will be generated.\n\n";
 122      support();
 123  }


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