[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.5 and 1.13

version 1.5, 2009/11/19 21:35:32 version 1.13, 2024/06/10 00:09:20
Line 1 
Line 1 
 #!/usr/bin/perl -T  #!/usr/bin/perl -T
 # $RedRiver: check_openbgpd,v 1.4 2009/11/19 21:22:01 andrew Exp $  # $AFresh1: check_openbgpd,v 1.12 2024/06/09 23:02:37 afresh1 Exp $
 ########################################################################  ########################################################################
 # check_openbgpd *** A nagios check for OpenBSD bgpd  # check_openbgpd *** A nagios check for OpenBSD bgpd
 #  #
Line 9 
Line 9 
 use warnings;  use warnings;
   
 use 5.010;  use 5.010;
   use if $] >= 5.016, experimental => 'switch';
   
 local %ENV = ();  local %ENV = ();
   
 my $NAGIOS_OUTPUT = 1;  my $NAGIOS_OUTPUT = 1;
   
 my $LICENSE = <<'EOL';  my $LICENSE = <<'EOL';
 Copyright (c) 2009 Andrew Fresh <andrew@afresh1.com>  Copyright (c) 2009-2024 Andrew Fresh <andrew@afresh1.com>
 Permission to use, copy, modify, and distribute this software for any  Permission to use, copy, modify, and distribute this software for any
 purpose with or without fee is hereby granted, provided that the above  purpose with or without fee is hereby granted, provided that the above
 copyright notice and this permission notice appear in all copies.  copyright notice and this permission notice appear in all copies.
Line 98 
Line 99 
     }      }
     push @cmd, 'show', 'summary';      push @cmd, 'show', 'summary';
   
     #open my $fh, '<', 'output'    # XXX      #open my $fh, '<', 'output' or die $!; # XXX
     open my $fh, '-|', @cmd or die "Couldn't open bgpctl: $!\n";      open my $fh, '-|', @cmd or die "Couldn't open bgpctl: $!\n";
     while (<$fh>) {      while (<$fh>) {
         chomp;          chomp;
Line 133 
Line 134 
 sub parse_check {  sub parse_check {
     my $check = shift;      my $check = shift;
   
     return { match => [] } unless $check;      unless ($check) {
           print_help();
           exit $ERRORS{'OK'}
       }
   
     my @values = split /,\s*/xms, $check;      my @values = split /,\s*/xms, $check;
   
     my %c = ( match => [] );      my %c = ( match => [] );
Line 220 
Line 225 
             return 'State (' . $d . ') is not numeric';              return 'State (' . $d . ') is not numeric';
         }          }
   
     DIRECTION: foreach my $dir qw( low high ) {      DIRECTION: foreach my $dir (qw( low high )) {
             if ( !$c->{$dir} ) { next DIRECTION; }              if ( !$c->{$dir} ) { next DIRECTION; }
   
             my $check = $c->{$dir};              my $check = $c->{$dir};
Line 263 
Line 268 
         state( $w, $c );          state( $w, $c );
   
         my $opt = shift @argv;          my $opt = shift @argv;
         given ($opt) {          for ($opt) {
             when ( '-V' || '--version' ) {              if ( $_ eq '-V' || $_ eq '--version' ) {
                 print_revision( $PROGNAME, '$Revision$ ' );                  print_revision( $PROGNAME, '$Revision$ ' );
                 exit $ERRORS{'OK'}                  exit $ERRORS{'OK'}
             }              }
             when (/^-?-h(?:elp)?/xms) { print_help(); exit $ERRORS{'OK'} }              elsif (/^-?-h(?:elp)?\Z/xms) { print_help(); exit $ERRORS{'OK'} }
             when (/^-?-s(?:ocket)?/xms) { $checks{_SOCKET} = shift @argv }              elsif (/^-?-s(?:ocket)?\Z/xms) {
             when (/^-?-w(?:arning)?/xms)  { $w = parse_check( shift @argv ) }                  $checks{_SOCKET} = shift @argv
             when (/^-?-c(?:ritical)?/xms) { $c = parse_check( shift @argv ) }                      || do { print_help(); exit $ERRORS{'OK'} }
             when (/^-?-u(?:nknown)?/xms) {              }
               elsif (/^-?-w(?:arning)?\Z/xms)  { $w = parse_check( shift @argv ) }
               elsif (/^-?-c(?:ritical)?\Z/xms) { $c = parse_check( shift @argv ) }
               elsif (/^-?-u(?:nknown)?\Z/xms) {
                 $checks{_UNKNOWN} = {                  $checks{_UNKNOWN} = {
                     WARNING      => $w,                      WARNING  => $w,
                         CRITICAL => $c,                      CRITICAL => $c,
                 }                  };
             }              }
             when (/^-?-n(?:eighbor)?/xms) {              elsif (/^-?-n(?:eighbor)?\Z/xms) {
                 while ( @argv && $argv[0] !~ /^-/xms ) {                  while ( @argv && $argv[0] !~ /^-/xms ) {
                     $checks{ shift @argv } = {                      $checks{ shift @argv } = {
                         WARNING      => $w,                          WARNING  => $w,
                             CRITICAL => $c,                          CRITICAL => $c,
                     }                      };
                 }                  }
             }              }
             default { print_help(); exit $ERRORS{'UNKNOWN'} }              else { print_help(); exit $ERRORS{'UNKNOWN'} }
         }          }
     }      }
     return %checks;      return %checks;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.13

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