version 1.6, 2015/03/25 03:17:08 |
version 1.10, 2015/03/26 04:44:15 |
|
|
#!/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.9 2015/03/26 03:42:23 andrew Exp $ |
######################################################################## |
######################################################################## |
# check_openbgpd *** A nagios check for OpenBSD bgpd |
# check_openbgpd *** A nagios check for OpenBSD bgpd |
# |
# |
|
|
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-2015 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. |
|
|
state( $w, $c ); |
state( $w, $c ); |
|
|
my $opt = shift @argv; |
my $opt = shift @argv; |
given ($opt) { |
for ($opt) { |
when ( '-V' || '--version' ) { |
when ( '-V' || '--version' ) { |
print_revision( $PROGNAME, '$Revision$ ' ); |
print_revision( $PROGNAME, '$Revision$ ' ); |
exit $ERRORS{'OK'} |
exit $ERRORS{'OK'} |
|
|
when (/^-?-c(?:ritical)?/xms) { $c = parse_check( shift @argv ) } |
when (/^-?-c(?:ritical)?/xms) { $c = parse_check( shift @argv ) } |
when (/^-?-u(?:nknown)?/xms) { |
when (/^-?-u(?:nknown)?/xms) { |
$checks{_UNKNOWN} = { |
$checks{_UNKNOWN} = { |
WARNING => $w, |
WARNING => $w, |
CRITICAL => $c, |
CRITICAL => $c, |
} |
}; |
} |
} |
when (/^-?-n(?:eighbor)?/xms) { |
when (/^-?-n(?:eighbor)?/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'} } |
default { print_help(); exit $ERRORS{'UNKNOWN'} } |