- check_linux_bonding on Nagios Exchange | Icinga Exchange
check_linux_bonding is a plugin for the Nagios monitoring software that checks bonding 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 arbitrary number of bonding interfaces.
check_linux_bonding is designed to be used with NRPE, i.e. run locally. Example:
$ ./check_linux_bonding Interface bond0 is up: mode=1 (active-backup), 2 slaves: eth0!, eth1
If something is wrong, the plugin will report it:
$ ./check_linux_bonding Bonding interface bond0 [mode=1 (active-backup)]: Slave eth1 is down
Active and primary slaves
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!
In the above example, eth0 is configured as the primary slave, and eth1 is the currently active slave.
Prefix alerts with service state
The option -s or --state can be used to prefix all alerts with its corresponding service state as reported by the plugin:
$ check_linux_bonding -s CRITICAL: Bonding interface bond1 [mode=1 (active-backup)] is down WARNING: Bonding interface bond0 [mode=4 (802.3ad)]: Slave eth2 is down
Alternatively, you can use the option -S or --short-state to get an abbreviated, one-letter service state:
$ check_linux_bonding -S C: Bonding interface bond1 [mode=1 (active-backup)] is down W: Bonding interface bond0 [mode=4 (802.3ad)]: Slave eth2 is down
The Nagios plugin development guideline suggests that this is good practice. I'm not a fan of this, but I've included these options for those who disagree.
Multiple line output, turn off escaping HTML tags
The output from check_linux_bonding contains multiple lines separated by HTML linebreaks (
) if run as a command within Nagios, via NRPE etc. If run from a console which has a TTY, i.e. if you log in via SSH or similar and run check_linux_bonding manually, the linebreaks will be regular linebreaks.
Nagios 3.x allows the following option in cgi.cfg:
# ESCAPE HTML TAGS # This option determines whether HTML tags in host and service # status output is escaped in the web interface. If enabled, # your plugin output will not be able to contain clickable links. escape_html_tags=1
The default, as seen above in the sample cgi.cfg from the distribution, is that HTML tags are escaped. My advice is to turn this off. If not, you will see output like this in your Nagios console:
CRITICAL: Bonding interface bond1 [mode=1 (active-backup)] is down<br />WARNING: Bonding interface bond0 [mode=4 (802.3ad)]: Slave eth2 is down
instead of this:
CRITICAL: Bonding interface bond1 [mode=1 (active-backup)] is down WARNING: Bonding interface bond0 [mode=4 (802.3ad)]: Slave eth2 is down
With Nagios 3.x, plugins are allowed to output multiple lines with regular linebreaks, but only the first line is shown in the web interface (status.cgi).
You may choose to blacklist one or more interfaces. This is done with the option -b or --blacklist, which can be specified multiple times. The argument can also be a file, in which the file is expected to contain a single line with the same syntax, i.e.:
check_linux_bonding -b bond1 -b eth1 check_linux_bonding -b bond1,eth1 check_linux_bonding -b /etc/check_linux_bonding.black
Exit value when no bonding interfaces are found
By default, the plugin will exit with an OK value if no bonding interfaces are found. This can be modified with the --no-bonding or -n option. Default behaviour:
$ ./check_linux_bonding OK: No bonding interfaces found
$ ./check_linux_bonding --no-bonding=warning WARNING: No bonding interfaces found
$ ./check_linux_bonding --no-bonding=critical CRITICAL: No bonding interfaces found
$ ./check_linux_bonding --no-bonding=unknown UNKNOWN: No bonding interfaces found
Full usage information
Usage output gathered with check_linux_bonding -h:
Usage: `check_linux_bonding [OPTION]...` OPTIONS: -t, --timeout Plugin timeout in seconds  -s, --state Prefix alerts with alert state -S, --short-state Prefix alerts with alert state abbreviated -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 (IEEE 802.3ad) 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 -V, --version Display version info
For more information and advanced options, see the manual page or URL: http://folk.uio.no/trondham/software/check_linux_bonding.html