Merge pull request #2046 from RincewindsHat/fix/format_string
[monitoring-plugins.git] / plugins-scripts / check_breeze.pl
blob531625c4ac91b836e971bb3248e7a494e0163a11
1 #!@PERL@ -w
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 FindBin;
8 use lib "$FindBin::Bin";
9 use utils qw(%ERRORS &print_revision &support &usage);
11 $PROGNAME = "check_breeze";
13 sub print_help ();
14 sub print_usage ();
16 $ENV{'PATH'}='@TRUSTED_PATH@';
17 $ENV{'BASH_ENV'}='';
18 $ENV{'ENV'}='';
19 $ENV{'CDPATH'}='';
21 Getopt::Long::Configure('bundling');
22 GetOptions
23 ("V" => \$opt_V, "version" => \$opt_V,
24 "h" => \$opt_h, "help" => \$opt_h,
25 "w=s" => \$opt_w, "warning=s" => \$opt_w,
26 "c=s" => \$opt_c, "critical=s" => \$opt_c,
27 "H=s" => \$opt_H, "hostname=s" => \$opt_H,
28 "C=s" => \$opt_C, "community=s" => \$opt_C);
30 if ($opt_V) {
31 print_revision($PROGNAME,'@NP_VERSION@');
32 exit $ERRORS{'UNKNOWN'};
35 if ($opt_h) {print_help(); exit $ERRORS{'UNKNOWN'};}
37 ($opt_H) || usage("Host name/address not specified\n");
38 my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/);
39 ($host) || usage("Invalid host: $opt_H\n");
41 ($opt_w) || usage("Warning threshold not specified\n");
42 my $warning = $1 if ($opt_w =~ /([0-9]{1,2}|100)+/);
43 ($warning) || usage("Invalid warning threshold: $opt_w\n");
45 ($opt_c) || usage("Critical threshold not specified\n");
46 my $critical = $1 if ($opt_c =~ /([0-9]{1,2}|100)/);
47 ($critical) || usage("Invalid critical threshold: $opt_c\n");
49 ($opt_C) || ($opt_C = "public") ;
51 my $sig=0;
52 $sig = `/usr/bin/snmpget $host $opt_C .1.3.6.1.4.1.710.3.2.3.1.3.0`;
53 my @test=split(/ /,$sig);
54 $sig=$test[2];
55 $sig=int($sig);
56 if ($sig>100){$sig=100}
58 print "Signal Strength at: $sig%\n";
60 exit $ERRORS{'CRITICAL'} if ($sig<$critical);
61 exit $ERRORS{'WARNING'} if ($sig<$warning);
62 exit $ERRORS{'OK'};
65 sub print_usage () {
66 print "Usage: $PROGNAME -H <host> [-C community] -w <warn> -c <crit>\n";
69 sub print_help () {
70 print_revision($PROGNAME,'@NP_VERSION@');
71 print "Copyright (c) 2000 Jeffrey Blank/Karl DeBisschop
73 This plugin reports the signal strength of a Breezecom wireless equipment
76 print_usage();
77 print "
78 -H, --hostname=HOST
79 Name or IP address of host to check
80 -C, --community=community
81 SNMPv1 community (default public)
82 -w, --warning=INTEGER
83 Percentage strength below which a WARNING status will result
84 -c, --critical=INTEGER
85 Percentage strength below which a CRITICAL status will result
88 support();