diff options
Diffstat (limited to 'check_snmp_switch_traffic.pl')
-rwxr-xr-x | check_snmp_switch_traffic.pl | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/check_snmp_switch_traffic.pl b/check_snmp_switch_traffic.pl index b38dc58..d1e9194 100755 --- a/check_snmp_switch_traffic.pl +++ b/check_snmp_switch_traffic.pl @@ -109,17 +109,24 @@ sub nagios_die ($) { my $host; my $port = 161; my $community = 'public'; +my $timeout = 10; my $help = 0; Getopt::Long::Configure ("bundling"); GetOptions('host|H=s' => \$host, 'port|p=i' => \$port, 'community|C=s' => \$community, + 'timeout|t=i' => \$timeout, 'help|?' => \$help) or pod2usage(2); pod2usage(0) if $help; pod2usage(2) unless (defined $host); +$SIG{'ALRM'} = sub { + nagios_die('Check timed out'); +}; +alarm($timeout); + my ($session, $err) = Net::SNMP->session( -hostname => $host, -port => $port, @@ -154,6 +161,7 @@ check_snmp_swtich_traffic --host|-H HOSTNAME [options] --port|-p PORT --community|-C COMMUNITY + --timeout|-t TIMEOUT --help|-? =head1 OPTIONS @@ -172,6 +180,11 @@ Port to connect to. If not specified it defaults to 161. SNMPv1 Community string. If not specified it defaults to "public". +=item B<--timeout|-t> + +Maximum runtime in seconds of this script before returning UNKNOWN. +If not specified it defaults to 10. + =item B<--help|-?> Display a help message about the available options. |