check_rpc: recognize capitalized "Program" in rpcinfo output (fixes #1488)
[monitoring-plugins.git] / plugins-scripts / check_wave.pl
blobc24015c0cdd4c3c289c5a622521901bfc6d61088
1 #!@PERL@ -w
5 use strict;
6 use FindBin;
7 use lib "$FindBin::Bin";
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);
15 $PROGNAME = "check_wave";
16 sub print_help ();
17 sub print_usage ();
19 $ENV{'PATH'}='@TRUSTED_PATH@';
20 $ENV{'BASH_ENV'}='';
21 $ENV{'ENV'}='';
22 $ENV{'CDPATH'}='';
24 Getopt::Long::Configure('bundling');
25 GetOptions
26 ("V" => \$opt_V, "version" => \$opt_V,
27 "h" => \$opt_h, "help" => \$opt_h,
28 "v" => \$verbose, "verbose" => \$verbose,
29 "w=s" => \$opt_w, "warning=s" => \$opt_w,
30 "c=s" => \$opt_c, "critical=s" => \$opt_c,
31 "H=s" => \$opt_H, "hostname=s" => \$opt_H);
33 if ($opt_V) {
34 print_revision($PROGNAME,'@NP_VERSION@'); #'
35 exit $ERRORS{'UNKNOWN'};
38 if ($opt_h) {
39 print_help();
40 exit $ERRORS{'UNKNOWN'};
43 $opt_H = shift unless ($opt_H);
44 print_usage() unless ($opt_H);
45 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]+)*)$/);
46 print_usage() unless ($host);
48 ($opt_c) || ($opt_c = shift) || ($opt_c = 120);
49 my $critical = $1 if ($opt_c =~ /([0-9]+)/);
51 ($opt_w) || ($opt_w = shift) || ($opt_w = 60);
52 my $warning = $1 if ($opt_w =~ /([0-9]+)/);
54 $low1 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`;
55 @test = split(/ /,$low1);
56 $low1 = $test[2];
58 $med1 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`;
59 @test = split(/ /,$med1);
60 $med1 = $test[2];
62 $high1 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`;
63 @test = split(/ /,$high1);
64 $high1 = $test[2];
66 sleep(2);
68 $snr = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.762.2.5.2.1.17.1`;
69 @test = split(/ /,$snr);
70 $snr = $test[2];
71 $snr = int($snr*25);
73 $low2 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`;
74 @test = split(/ /,$low2);
75 $low2 = $test[2];
77 $med2 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`;
78 @test = split(/ /,$med2);
79 $med2 = $test[2];
81 $high2 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`;
82 @test = split(/ /,$high2);
83 $high2 = $test[2];
85 $low = $low2 - $low1;
86 $med = $med2 - $med1;
87 $high = $high2 - $high1;
89 $tot = $low + $med + $high;
91 if ($tot==0) {
92 $ss = 0;
93 } else {
94 $lowavg = $low / $tot;
95 $medavg = $med / $tot;
96 $highavg = $high / $tot;
97 $ss = ($medavg*50) + ($highavg*100);
100 printf("Signal Strength at: %3.0f%, SNR at $snr%",$ss);
102 if ($ss<$critical) {
103 exit(2);
104 } elsif ($ss<$warning) {
105 exit(1);
106 } else {
107 exit(0);
111 sub print_usage () {
112 print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>]\n";
115 sub print_help () {
116 print_revision($PROGNAME,'@NP_VERSION@');
117 print "Copyright (c) 2000 Jeffery Blank/Karl DeBisschop\n";
118 print "\n";
119 print_usage();
120 print "\n";
121 print "<warn> = Signal strength at which a warning message will be generated.\n";
122 print "<crit> = Signal strength at which a critical message will be generated.\n\n";
123 support();