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 (modifiable with the --no-bonding option). It is therefore safe to run this plugin on all your Linux machines:
$ ./check_linux_bonding OK: No bonding interfaces found
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.
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!
- -b, --blacklist string | file
Blacklist one or more interfaces. The option can be specified multiple times. If the argument is a file, 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
- -n, --no-bonding string
This option lets you specify the return value of the plugin if no bonding interfaces are found. The option expects “ok”, “warning”, “critical” or “unknown” as the argument. Default is “ok” if the option is not present.
- --slave-down string
This option lets you specify the return value of the plugin if a slave interface is down. The option expects “ok”, “warning”, “critical” or “unknown” as the argument. Default is “warning” if the option is not present.
- -t, --timeout seconds
The number of seconds after which the plugin will abort. Default timeout is 5 seconds if the option is not present.
- -s, --state
Prefix each alert with its corresponding service state (i.e. warning, critical etc.). This is useful in case of several alerts from the same monitored system.
- -S, --short-state
Same as the --state option above, except that the state is abbreviated to a single letter (W=warning, C=critical etc.).
Only relevant for IEEE 802.3ad type bonding. Turning on this option instructs the plugin to not issue a warning if the number of AD ports are not equal to the number of slaves. Usually you'll want the default behaviour, but if your 802.3ad bonding device is bound on more than one switch, you'll want to use this option to avoid false positives.
- --linebreak string
check_linux_bonding will sometimes report more than one line, e.g. if there are several alerts. If the script has a TTY, it will use regular linebreaks. If not (which is the case with NRPE) it will use HTML linebreaks. Sometimes it can be useful to control what the plugin uses as a line separator, and this option provides that control.
The argument is the exact string to be used as the line separator. There are two exceptions, i.e. two keywords that translates to the following:
REG: Regular linebreaks, i.e. “\n”.
HTML: HTML linebreaks, i.e. “<br/>”.
This is a rather special option that is normally not needed. The default behaviour should be sufficient for most users.
Sometimes the information in /sys is partly absent or deficient, and the plugin is unable to detect this discrepancy and reports errors. This usually happens with old Linux kernels and Xen domain-0 systems. This option exists as a workaround. If specified, this option will make the plugin ignore the /sys filesystem alltogether and use the /proc filesystem instead.
- -v, --verbose
Verbose output. Will report status on all bonding interfaces, regardless of their alert state.
- -h, --help
Display help message and exit.
- -V, --version
Print version info and exit.
The option -v or --verbose can be specified to display all bonding interfaces.
This plugin depends on sysfs and fallbacks to procfs. Without these filesystems the plugin will not find any bonding interfaces.
If no errors are discovered, a value of 0 (OK) is returned. An exit value of 1 (WARNING) signifies one or more non-critical errors, while 2 (CRITICAL) signifies one or more critical errors.
The exit value 3 (UNKNOWN) is reserved for errors within the script, or errors getting values sysfs or procfs.
Bugs and Limitations
None known at present.
The plugin is only compatible with the Linux operating system.
License and Copyright
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Trond Hasle Amundsen <firstname.lastname@example.org>