Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

check_linux_bonding

Current Version
1.3.2
Last Release Date
2012-12-14
Compatible With
  • Nagios 2.x
  • Nagios 3.x
License
GPL
Hits
133201
Files:
FileDescription
check_linux_bonding-1.3.2.tar.gzGzipped tarball
check_linux_bonding-1.3.2.zipZip archive
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
check_linux_bonding
check_linux_bonding is a plugin for Nagios that checks bonded network interfaces on Linux. The plugin is fairly simple and will report any interfaces that are down (both masters and slaves). It will also alert you of bonding interfaces with only one slave, since that usually points to a misconfiguration. If no bonding interfaces are detected, the plugin will exit with an OK value by default. It is therefore safe to run this plugin on all your Linux machines.

The plugin will first try to use the sysfs (/sys) filesystem to detect bonding interfaces. If that does not work, i.e. the kernel or bonding module is too old for the necessary files to exist, the plugin will use procfs (/proc) as a fallback. The plugin supports an unlimited number of bonding interfaces.

check_linux_bonding is designed to be used with NRPE, i.e. run locally. Example:

$ ./check_linux_bonding
Bonding interface bond0 [mode=4 (802.3ad)]: Slave eth2 is down

In the OK output, the plugin will indicate which of the slaves is active with an exclamation mark "!", if applicable. If one of the slaves is configured as primary, this is indicated with an asterisk "*":

$ ./check_linux_bonding
Interface bond0 is up: mode=1 (active-backup), 2 slaves: eth0*!, eth1
Reviews (6)
Hi everyone,

Thank you for the nice Nagios plugin and the good work.
Here is my patch for version 1.3.2 after bonding driver changed in Linux 3.13.0.

Tested on Ubuntu (Linux 3.13.0-52-generic #86~precise1-Ubuntu SMP Tue May 5 18:08:21 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux):

I installed liblinux-kernelsort-perl to be able to compare kernel versions.

sudo apt-get install liblinux-kernelsort-perl

Then patch check_linux_bonding.


@@ -25,6 +25,7 @@ use strict;
use warnings;
use POSIX qw(isatty);
use Getopt::Long qw(:config no_ignore_case);
+use Linux::KernelSort;

# Global (package) variables used throughout the code
use vars qw( $NAME $VERSION $AUTHOR $CONTACT $E_OK $E_WARNING $E_CRITICAL
@@ -255,6 +256,15 @@ sub find_bonding_sysfs {
my $masters_file = "$sysdir/bonding_masters";
my @bonds = ();
my %bonding = ();
+ my $device;
+ my $kernel = new Linux::KernelSort;
+ my ($kernver, @rest) = split('-', `uname -r`);
+ my $retcmp = $kernel->compare($kernver,"3.13.0");
+ if ( $retcmp >= 0 ) {
+ $device = "lower";
+ } else {
+ $device = "slave";
+ }

if (! -f $masters_file) {
return {};
@@ -311,8 +321,8 @@ sub find_bonding_sysfs {

# get slave status
foreach my $slave (@slaves) {
- open my $STATE, '
0
byglynastill, October 12, 2014
1 of 1 people found this review helpful
It would appear the patch by BlauwBlaatje on April 29, 2014 has been truncated so is missing the final part of the patch. The following works for me:

--- check_linux_bonding.a 2014-10-13 11:13:17.899342000 +0100
+++ check_linux_bonding.b 2014-10-13 11:33:03.010804900 +0100
@@ -255,7 +255,14 @@
my $masters_file = "$sysdir/bonding_masters";
my @bonds = ();
my %bonding = ();
-
+ my $device;
+ my ($kernver, @rest) = split('-', `uname -r`);
+ if ( $kernver >= 3.13 ) {
+ $device = "lower";
+ } else {
+ $device = "slave";
+ }
+
if (! -f $masters_file) {
return {};
}
@@ -311,8 +318,8 @@

# get slave status
foreach my $slave (@slaves) {
- open my $STATE, '
As of Linux 3.13 the bonding driver uses /sys/class/net/bond0/lower_eth0/operstate instead of /sys/class/net/bond0/slave_eth0/operstate. Here is a patch (you might brush it up a bit ;))

--- check_linux_bonding.a 2014-04-30 09:22:10.523457651 +0200
+++ check_linux_bonding.b 2014-04-30 09:26:33.975182901 +0200
@@ -255,6 +255,13 @@
my $masters_file = "$sysdir/bonding_masters";
my @bonds = ();
my %bonding = ();
+ my $device;
+ my ($kernver, @rest) = split('-', `uname -r`);
+ if ( $kernver >= 3.13 ) {
+ $device = "lower";
+ } else {
+ $device = "slave";
+ }

if (! -f $masters_file) {
return {};
@@ -311,8 +318,8 @@

# get slave status
foreach my $slave (@slaves) {
- open my $STATE, '
bybmalynovytch, July 23, 2012
1 of 1 people found this review helpful
Thank you for this excellent plugin !

You'll find below a patch of my own, allowing to ignore warnings if ad_num is different from number of registered slave.
In most cases, people would prefer being warned, but in my case, the same 802.3ad is bound on 2 different switches, generating 2x2 802.3ad, with one being "master", the 2 other links being "waiting" for a failure to become active.
This leads to being warned because 2 slaves over 4 seem to be missing in the active 802.3ad bonding, which is half true and half false.
I therefore don't wan't to be warned.

Regards,
Benjamin


--- check_linux_bonding.orig 2012-07-24 10:52:55.973316334 +0200
+++ check_linux_bonding 2012-07-24 11:10:44.681319464 +0200
@@ -78,6 +78,7 @@
-n, --no-bonding Alert level if no bonding interfaces found [ok]
--slave-down Alert level if a slave is down [warning]
--disable-sysfs Don't use sysfs (default), use procfs
+ --ignore-num-ad Don't warn if num_ad_ports != num_slaves
-b, --blacklist Blacklist failed interfaces
-d, --debug Debug output, reports everything
-h, --help Display this help text
@@ -110,6 +111,7 @@
'linebreak' => undef,
'verbose' => 0,
'disable_sysfs' => 0,
+ 'ignore_num_ad' => 0,
'slave_down' => 'warning',
);

@@ -124,6 +126,7 @@
'linebreak=s' => \$opt{linebreak},
'v|verbose' => \$opt{verbose},
'disable-sysfs' => \$opt{disable_sysfs},
+ 'ignore-num-ad' => \$opt{ignore_num_ad},
'slave-down=s' => \$opt{slave_down},
) or do { print $USAGE; exit $E_UNKNOWN };

@@ -490,7 +493,7 @@
$b, $bonding{$b}{mode};
report($msg, $E_CRITICAL);
}
- elsif (defined $bonding{$b}{ad_num} and $bonding{$b}{ad_num} != scalar keys %slave) {
+ elsif ($opt{ignore_num_ad} == 0 and defined $bonding{$b}{ad_num} and $bonding{$b}{ad_num} != scalar keys %slave) {
my $msg = sprintf 'Bonding interface %s [%s]: Number of AD ports (%d) does not equal the number of slaves (%d)',
$b, $bonding{$b}{mode}, $bonding{$b}{ad_num}, scalar keys %slave;
report($msg, $E_WARNING);
Owner's reply

Thanks for the patch. It has been included in version 1.3.2 of the plugin.

byaBill, February 23, 2012
2 of 2 people found this review helpful
This is a great piece of work. Thank you for making it available.