NAME
Monitoring::Sneck::Checks::interface - checks network interfaces are up, at speed, and not erroring
VERSION
Version 0.0.1
SYNOPSIS
uplink|perl:interface -i em0 -s 1000 -F -m 9000
nics|perl:interface -a -e 0 -E 10
bond|perl:interface -i bond0 -i eth0 -i eth1 -s 10000 -r 1 -R 100
DESCRIPTION
Checks each interface is up, which is CRITICAL if not, and optionally that it is at a speed, at full duplex, and has a MTU, each WARNING if not, as a link that came up at 100 Mb/s or half duplex works, just badly.
Errors and drops are checked as a rate, per second, since the last run, with the counters kept in a state file, see "read_state" in Monitoring::Sneck::Checks::base. So the first run, or one after the counters reset, has no rate and is not checked for them. They are only kept and checked if one of --errors-warning, --errors-critical, --drops-warning, or --drops-critical is given, so nothing else needs the state file.
On Linux, everything is read from /sys/class/net, and --all is every interface backed by a device, so not lo, bridges, VLANs, and the like. On FreeBSD it comes from ifconfig and netstat -I, and --all is ifconfig -l ether. Other OSes are UNKNOWN.
OPTIONS
- -i, --interface :: A interface. May be given more than once.
- -a, --all :: Every interface backed by a device on Linux, or every Ethernet one, as listed by ifconfig -l ether, on FreeBSD.
- -x, --ignore :: A interface for --all to leave out, such as a unused port. May be given more than once.
- -s, --speed :: The Mb/s it must be at least.
- -F, --full-duplex :: It must be at full duplex.
- -m, --mtu :: The MTU it must have.
- -e, --errors-warning :: Range of errors per second.
- -E, --errors-critical :: Range of errors per second.
- -r, --drops-warning :: Range of drops per second.
- -R, --drops-critical :: Range of drops per second.
One of --interface or --all must be given.
METHODS
check
Does the check.
interface_status
Works out the status of a interface, as said under "DESCRIPTION", adding its perfdata.
- name :: The interface.
- info :: Hash ref of up, 1 or 0, speed, in Mb/s, duplex, full or half, mtu, errors, and drops, the counters, any undef if not known.
Returns the code and what to say about it.
rates_wanted
Returns 1 if any of --errors-warning, --errors-critical, --drops-warning, or --drops-critical was given, so the rates are to be kept and checked, else 0.
rates
Works out the errors and drops per second since the last run, and saves the counters for the next.
- name :: The interface.
- info :: As for "interface_status".
Returns a hash ref of errors and drops, each undef if there is no rate yet. Dies if the state can not be kept.
all
Returns the interfaces --all covers, see DESCRIPTION.
linux_info
Returns what is known about a interface from /sys/class/net, as taken by "interface_status", or undef if it is not there.
freebsd_info
Returns what is known about a interface from ifconfig and netstat -I, as taken by "interface_status", or undef if it is not there.