check_breeze.pl 2.2 KB

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