check_netio

Last update: June 21, 2019

This is a plugin to monitor network interfaces on Linux systems. The initial version was developed by Ian Yates. The plugin is currently maintained by Claudio Kuenzler.

The plugin needs to be executed on the same host as you want the interfaces monitored. A typical use case of this plugin is in combination with a remote plugin execution service (e.g. NRPE). The plugin displays performance data of the given interface as "Bytes", retrieved from the OS.

As of the current state, the plugin does not support thresholds.

Download

Download check_netio.sh

check_netio.sh

204 downloads so far...

Download plugin and save it in your Nagios/Monitoring plugin folder (usually /usr/lib/nagios/plugins, depends on your distribution). Afterwards adjust the permissions (usually chmod 755).

Community contributions welcome on GitHub repo.

Version history / Changelog

# 2007-09-06 (i.yates@uea.ac.uk) - Created
# 2007-09-06 (i.yates@uea.ac.uk)
# 2008-11-27 (i.yates@uea.ac.uk) - Added GPLv3 licence
# 2017-01-27 (www.claudiokuenzler.com) - Added validation checks and compatibility with CentOS/RHEL 7
# 2018-06-05 (www.claudiokuenzler.com) - Added validation checks and compatibility with Ubuntu 18.04
# 2018-08-14 (www.claudiokuenzler.com) - Set LANG to English for correct parsing
# 2018-12-21 (www.claudiokuenzler.com) - Use /proc/net/dev instead of ifconfig (use -l for legacy)
# 2018-12-21 (www.claudiokuenzler.com) - Remove verbose mode (it was never implemented anyway)
# 2018-12-21 (www.claudiokuenzler.com) - Change default exit code to UNKNOWN
# 2018-12-21 (www.claudiokuenzler.com) - Remove dependency to (nagios|monitoring)-plugins-common
# 2019-06-21 (www.claudiokuenzler.com) - Add interface error check (-e)

Requirements

  • In legacy mode (invoked with -l): ifconfig command must exist and be executable

Definition of the parameters

Parameter Description
-i* Name of the interface to check. Example: eth0
-l Use legacy mode (uses ifconfig command in the background)
-e Enable check of interface errors. The plugin will alert with a WARNING if errors were found. On the next run the plugin will return OK if the error count did not increase. If the error count increased since the last check, plugin will again alert with a WARNING.
-h Show help/usage

* mandatory parameter

Usage / running the plugin on the command line

Usage:

./check_netio.sh -i string [-l] [-e]

Example:

/usr/lib/nagios/plugins/check_netio -i enp5s0
NETIO OK - enp5s0: Receive 2023395071 Bytes, Transmit 4721736880 Bytes|NET_enp5s0_RX=2023395071B;;;; NET_enp5s0_TX=4721736880B;;;; NET_enp5s0_ERR_IN=0;;;; NET_enp5s0_ERR_OUT=0;;;;

Example with interface error check:

/usr/lib/nagios/plugins/check_netio -i enp5s0 -e
NETIO WARNING - Errors on enp5s0: 12 Receive errors (previous check: 7), 0 Transmit errors (previous check: 0)|NET_enp5s0_RX=1995757695B;;;; NET_enp5s0_TX=4720483095B;;;; NET_enp5s0_ERR_IN=12;;;; NET_enp5s0_ERR_OUT=0;;;;

Command definition (NRPE)

command[check_netio]=/usr/lib/nagios/plugins/check_netio.sh -i $ARG1$ -e

Service definition

Service definition in Nagios, Icinga 1.x, Shinken, Naemon

# Check network io of eth0
define service{
  use generic-service
  host_name mylinux1
  service_description NetIO eth0
  check_command check_nrpe!check_netio!-a "eth0"
}

Service object definition Icinga 2.x

# Check network io of eth0
object Service "NetIO eth0" {
  import "generic-service"
  host_name "mylinux1"
  check_command = "nrpe"
  vars.nrpe_command = "check_netio"
  vars.nrpe_arguments = ["eth0"]
}

Apply rule in Icinga 2.x

The next example is more interesting as it uses apply rules (a feature of Icinga 2.x). Let's assume we have a couple of Linux hosts already defined with custom attributes:

object Host "mylinuxserver" {
  import "generic-host"
  address = "192.168.44.67"
  vars.os = "Linux"
  vars.interfaces = [ "eth0" ]
}

Using these custom attributes (vars.os and vars.interfaces) we can now create an apply rule:

# Apply check_netio on Linux servers
apply Service "Network IO " for (interface in host.vars.interfaces) {
  import "generic-service"

  check_command = "nrpe"
  vars.nrpe_command = "check_netio"
  vars.nrpe_arguments = [ interface ]

  assign where host.address && host.vars.os == "Linux" && host.vars.interfaces
}

This "Network IO" service object will now be applied to all hosts which have the custom host attributes host.vars.os set to "Linux" and host.vars.server.interfaces is defined. As vars.interfaces is an array, you can define multiple interfaces.

Screenshots

check_netio grafana graph tx rx
check_netio in icinga2