check_breeze.pl 2.2 KB

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