check_netio

Last update: March 11, 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

70 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

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)
-h Show help/usage

* mandatory parameter

Usage / running the plugin on the command line

Usage:

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

Example:

/usr/lib/nagios/plugins/check_netio -i eth0
NETIO OK - eth0: RX=945587720, TX=7048311553|NET_eth0_RX=945587720B;;;; NET_eth0_TX=7048311553B;;;;

Command definition (NRPE)

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

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