[BACK]Return to check_openbgpd CVS log [TXT][DIR] Up to [local] / nagios / check_openbgpd

Diff for /nagios/check_openbgpd/check_openbgpd between version 1.2 and 1.3

version 1.2, 2009/11/13 22:23:24 version 1.3, 2009/11/19 19:52:51
Line 1 
Line 1 
 #!/usr/bin/perl -T  #!/usr/bin/perl -T
 # $RedRiver: check_openbgpd,v 1.1 2009/11/13 02:05:20 andrew Exp $  # $RedRiver: check_openbgpd,v 1.2 2009/11/13 22:23:24 andrew Exp $
 ########################################################################  ########################################################################
 # check_openbgpd *** A nagios check for OpenBSD bgpd  # check_openbgpd *** A nagios check for OpenBSD bgpd
 #  #
Line 143 
Line 143 
   
     foreach my $d ( 'low', 'high' ) {      foreach my $d ( 'low', 'high' ) {
         if ( defined $c{$d} ) {          if ( defined $c{$d} ) {
             $c{$d} =~ s/[^-\d\.]//gxms;              $c{$d} =~ s/[^-\d\.\%]//gxms;
             if ( !length $c{$d} ) {              if ( !length $c{$d} ) {
                 delete $c{$d};                  delete $c{$d};
             }              }
Line 208 
Line 208 
   
     if ( $c->{low} || $c->{high} ) {      if ( $c->{low} || $c->{high} ) {
         $result = undef;          $result = undef;
         my $num = $d;          my ( $num, $max ) = split m{/}xms, $d;
         $num =~ s/[^-\d\.]//gxms;          $num =~ s/[^-\d\.]//gxms;
   
         if ( !length $num ) {          if ( !length $num ) {
             return 'State (' . $d . ') is not numeric';              return 'State (' . $d . ') is not numeric';
         }          }
   
         if ( $c->{low} && $num < $c->{low} ) {      DIRECTION: foreach my $dir qw( low high ) {
             return 'is below threshold (' . $d . ' < ' . $c->{low} . ')';              if ( !$c->{$dir} ) { next DIRECTION; }
         }  
   
         if ( $c->{high} && $num > $c->{high} ) {              my $check = $c->{$dir};
             return 'is above threshold (' . $d . ' > ' . $c->{high} . ')';              my $cnum  = $num;
   
               if ( $check =~ s/\%$//xms ) {
                   if ( !defined $max ) {
                       return 'max-prefix not specified and % check requested';
                   }
   
                   # convert to percent
                   $cnum = 100 * $cnum / $max;
               }
   
               my @nums       = ( $cnum, $check );
               my $abovebelow = 'below';
               my $symbol     = '<';
               if ( $dir eq 'high' ) {
                   @nums       = ( $check, $cnum );
                   $abovebelow = 'above';
                   $symbol     = '>';
               }
   
               if ( $nums[0] < $nums[1] ) {
                   return join q{ }, 'is', $abovebelow,
                       'threshold (' . $d,
                       $symbol, $c->{$dir} . ')';
               }
         }          }
     }      }
   
Line 240 
Line 263 
                 print_revision( $PROGNAME, '$Revision$ ' );                  print_revision( $PROGNAME, '$Revision$ ' );
                 exit $ERRORS{'OK'}                  exit $ERRORS{'OK'}
             }              }
             when (/^-?-h(?:elp)?/xms) { print_help(); exit $ERRORS{'OK'} }              when (/^-?-h(?:elp)?/xms)     { print_help(); exit $ERRORS{'OK'} }
             when (/^-?-w(?:arning)?/xms)  { $w = parse_check( shift @argv ) }              when (/^-?-w(?:arning)?/xms)  { $w = parse_check( shift @argv ) }
             when (/^-?-c(?:ritical)?/xms) { $c = parse_check( shift @argv ) }              when (/^-?-c(?:ritical)?/xms) { $c = parse_check( shift @argv ) }
             when (/^-?-n(?:eighbor)?/xms) {              when (/^-?-n(?:eighbor)?/xms) {
Line 275 
Line 298 
   
 RANGE is specified as two optional numbers separated with a colon (:).  The  RANGE is specified as two optional numbers separated with a colon (:).  The
 check is that the value is between the two numbers.  If either number is left  check is that the value is between the two numbers.  If either number is left
 off, that check is ignored  off, that check is ignored.
   
   If either number in a RANGE is specified as a percent, check is that
   max-prefix is specified and that the number is within the specified percent.
   
 NEIGHBOR is the name that shows when running "bgpctl show summary"  NEIGHBOR is the name that shows when running "bgpctl show summary"
   
 Examples:  Examples:
Line 307 
Line 333 
   
 WARNING  WARNING
     If P3 is above 10 and below 200 or above 300.      If P3 is above 10 and below 200 or above 300.
   
   
   $PROGNAME -n P1 -w 50%:70% -c 10%:90% -n P2 P3
   
   No checks on P1
   
   CRITICAL
       If P2 or P3 do not have max-prefix set or if they do but learned prefixes
       are below 10% or above 90% of max-prefix.
   
   WARNING
       If P2 or P3 have learned prefixes below 50% or above 90% of max-prefix.
   
 EOL  EOL
   

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>