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