check_breeze.pl 2.2 KB

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