From 0b38b4f272aaa203b0cb15ffdcb98588708e1361 Mon Sep 17 00:00:00 2001 From: trondham Date: Mon, 15 Feb 2010 13:55:33 +0000 Subject: [PATCH] * version 1.2.0-beta1 * Added option '--disable-sysfs' to disable the use of /sysfs, i.e. only use the /proc filesystem git-svn-id: svn+ssh://vcs-usit.uio.no/svnroot/usit-unix-intern/trunk/usit-nagios-plugins/trondham/check_linux_bonding@16576 e53b7cee-c147-0410-b3a0-ae4c1fa63963 --- check_linux_bonding | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/check_linux_bonding b/check_linux_bonding index 34c62dc..dd5e38e 100755 --- a/check_linux_bonding +++ b/check_linux_bonding @@ -43,7 +43,7 @@ if (! isatty(*STDOUT)) { # Version and similar info my $NAME = 'check_linux_bonding'; -my $VERSION = '1.1.0'; +my $VERSION = '1.2.0-beta1'; my $AUTHOR = 'Trond H. Amundsen'; my $CONTACT = 't.h.amundsen@usit.uio.no'; @@ -64,16 +64,17 @@ my %reverse_exitcode # Options with default values my %opt - = ( 'timeout' => 5, # default timeout is 5 seconds - 'help' => 0, - 'man' => 0, - 'version' => 0, - 'blacklist' => [], - 'no_bonding' => 'ok', - 'state' => 0, - 'short-state' => 0, - 'linebreak' => undef, - 'verbose' => 0, + = ( 'timeout' => 5, # default timeout is 5 seconds + 'help' => 0, + 'man' => 0, + 'version' => 0, + 'blacklist' => [], + 'no_bonding' => 'ok', + 'state' => 0, + 'short-state' => 0, + 'linebreak' => undef, + 'verbose' => 0, + 'disable_sysfs' => 0, ); # Get options @@ -87,6 +88,7 @@ GetOptions('t|timeout=i' => \$opt{timeout}, 'short-state' => \$opt{shortstate}, 'linebreak=s' => \$opt{linebreak}, 'v|verbose' => \$opt{verbose}, + 'disable-sysfs' => \$opt{disable_sysfs}, ) or pod2usage(-exitstatus => $E_UNKNOWN, -verbose => 0); # If user requested help @@ -345,12 +347,17 @@ sub find_bonding_procfs { sub find_bonding { my $bonding = undef; - # first try sysfs - $bonding = find_bonding_sysfs(); + if ($opt{disable_sysfs}) { + $bonding = find_bonding_procfs(); + } + else { + # first try sysfs + $bonding = find_bonding_sysfs(); - # second try procfs - if (scalar keys %{ $bonding } == 0) { - $bonding = find_bonding_procfs(); + # second try procfs + if (scalar keys %{ $bonding } == 0) { + $bonding = find_bonding_procfs(); + } } # if no bonding interfaces found, exit -- 2.43.0