4
0

check_breeze.pl 2.2 KB

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