monitoring plugin check_netio

Last update: October 02, 2023

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 shows performance data related to the selected interface (Bytes in/out, Errors in/out, Drops in/out) and optional system wide tcp related statistics, retrieved from the OS.

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

Commercial support

If you are looking for commercial support for this monitoring plugin, need customized modifications or in general customized monitoring plugins, contact us at Infiniroot.com.

Download

Download check_netio.sh

check_netio.sh

2282 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 (claudiokuenzler.com) - Added validation checks and compatibility with CentOS/RHEL 7
# 2018-06-05 (claudiokuenzler.com) - Added validation checks and compatibility with Ubuntu 18.04
# 2018-08-14 (claudiokuenzler.com) - Set LANG to English for correct parsing
# 2018-12-21 (claudiokuenzler.com) - Use /proc/net/dev instead of ifconfig (use -l for legacy)
# 2018-12-21 (claudiokuenzler.com) - Remove verbose mode (it was never implemented anyway)
# 2018-12-21 (claudiokuenzler.com) - Change default exit code to UNKNOWN
# 2018-12-21 (claudiokuenzler.com) - Remove dependency to (nagios|monitoring)-plugins-common
# 2019-06-21 (claudiokuenzler.com) - 1.4: Add interface error check (-e)
# 2020-02-12 (claudiokuenzler.com) - 1.5: Add interface drops to performance data, add tcp stats option (-t)
# 2020-02-13 (claudiokuenzler.com) - 1.5.1: Bugfix issue-6
# 2020-09-04 (claudiokuenzler.com) - 1.5.2: Bugfix issue-9
# 2020-09-04 (claudiokuenzler.com) - 1.6: Allow regular expression lookup for tcp statistics
# 2023-10-02 (claudiokuenzler.com) - 1.7: Detect interface operational status, alert when down

Requirements

  • In legacy mode (invoked with -l), the 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.
-t Enable additional tcp related statistics in the plugin performance data. These stats are retrieved from /proc/net/netstat and are system-wide statistics (not bound to a specific interface).
-r Awaits a comma-separated list of strings. These given strings will be matched as regular expression against the tcp statistics (invoked with -t). TCP statistics not matching the list will not appear in the performance data output..
-h Show help/usage

* mandatory parameter

Usage / running the plugin on the command line

Usage:

./check_netio.sh -i string [-l] [-e] [-t] [-r "list,of,strings"]

Example:

/usr/lib/nagios/plugins/check_netio.sh -i enp5s0
CHECK_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.sh -i enp5s0 -e
CHECK_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;;;;

Example with additional tcp stats:

/usr/lib/nagios/plugins/check_netio.sh -i eth0 -t
CHECK_NETIO OK - eth0: Receive 23284649421956 Bytes, Transmit 24036117884475 Bytes|NET_eth0_RX=23284649421956B;;;; NET_eth0_TX=24036117884475B;;;; NET_eth0_ERR_RX=0;;;; NET_eth0_ERR_TX=0;;;; NET_eth0_DROP_RX=236;;;; NET_eth0_DROP_TX=0;;;; SyncookiesSent=0;;;; SyncookiesRecv=0;;;; SyncookiesFailed=10708;;;; EmbryonicRsts=11;;;; PruneCalled=1132207;;;; RcvPruned=57163;;;; OfoPruned=210;;;; OutOfWindowIcmps=1756;;;; LockDroppedIcmps=0;;;; ArpFilter=0;;;; TW=8844650;;;; TWRecycled=0;;;; TWKilled=3966390849;;;; PAWSPassive=265;;;; PAWSActive=0;;;; PAWSEstab=69;;;; DelayedACKs=145526473;;;; DelayedACKLocked=86600;;;; DelayedACKLost=15639;;;; ListenOverflows=0;;;; ListenDrops=0;;;; TCPPrequeued=2257462558;;;; TCPDirectCopyFromBacklog=1634542275;;;; TCPDirectCopyFromPrequeue=910314455124;;;; TCPPrequeueDropped=0;;;; TCPHPHits=6748083892;;;; TCPHPHitsToUser=77529122;;;; TCPPureAcks=18521820705;;;; TCPHPAcks=2042634393;;;; TCPRenoRecovery=0;;;; TCPSackRecovery=23122;;;; TCPSACKReneging=157;;;; TCPFACKReorder=9886;;;; TCPSACKReorder=5568;;;; TCPRenoReorder=0;;;; TCPTSReorder=18825;;;; TCPFullUndo=19886;;;; TCPPartialUndo=95443;;;; TCPDSACKUndo=94;;;; TCPLossUndo=532376;;;; TCPLoss=6206;;;; TCPLostRetransmit=117;;;; TCPRenoFailures=0;;;; TCPSackFailures=629;;;; TCPLossFailures=241;;;; TCPFastRetrans=78667;;;; TCPForwardRetrans=3195;;;; TCPSlowStartRetrans=11752;;;; TCPTimeouts=795630;;;; TCPRenoRecoveryFail=0;;;; TCPSackRecoveryFail=105;;;; TCPSchedulerFailed=19;;;; TCPRcvCollapsed=11304426;;;; TCPDSACKOldSent=15653;;;; TCPDSACKOfoSent=4;;;; TCPDSACKRecv=30684;;;; TCPDSACKOfoRecv=2;;;; TCPAbortOnData=1363337089;;;; TCPAbortOnClose=104580;;;; TCPAbortOnMemory=0;;;; TCPAbortOnTimeout=11042;;;; TCPAbortOnLinger=0;;;; TCPAbortFailed=0;;;; TCPMemoryPressures=0;;;; TCPSACKDiscard=0;;;; TCPDSACKIgnoredOld=1;;;; TCPDSACKIgnoredNoUndo=23213;;;; TCPSpuriousRTOs=34;;;; TCPMD5NotFound=0;;;; TCPMD5Unexpected=0;;;; TCPSackShifted=39551;;;; TCPSackMerged=28792;;;; TCPSackShiftFallback=197072;;;; TCPBacklogDrop=1682;;;; TCPMinTTLDrop=0;;;; TCPOFOQueue=209658;;;; TCPOFODrop=22478;;;; TCPOFOMerge=4;;;; TCPChallengeACK=50266;;;; TCPSYNChallenge=49967;;;; BusyPollRxPackets=0;;;; TCPFromZeroWindowAdv=138540;;;; TCPToZeroWindowAdv=138540;;;; TCPWantZeroWindowAdv=3576590;;;; TCPACKSkippedSynRecv=0;;;; TCPACKSkippedPAWS=1;;;; TCPACKSkippedSeq=98514;;;; TCPACKSkippedFinWait2=0;;;; TCPACKSkippedTimeWait=0;;;; TCPACKSkippedChallenge=14;;;;

Example with tcp stats and regular expression list only showing tcp statistics matching lost and drop:

/usr/lib/nagios/plugins/check_netio.sh -i eth0 -t -r "lost,drop"
CHECK_NETIO OK - eth0: Receive 27643984493 Bytes, Transmit 13167948141 Bytes|NET_eth0_RX=27643984493B;;;; NET_eth0_TX=13167948141B;;;; NET_eth0_ERR_RX=0;;;; NET_eth0_ERR_TX=0;;;; NET_eth0_DROP_RX=0;;;; NET_eth0_DROP_TX=0;;;; LockDroppedIcmps=0;;;; DelayedACKLost=5654;;;; ListenDrops=0;;;; TCPLostRetransmit=2;;;; TCPBacklogDrop=0;;;; PFMemallocDrop=0;;;; TCPMinTTLDrop=0;;;; TCPDeferAcceptDrop=0;;;; TCPReqQFullDrop=0;;;; TCPOFODrop=0;;;;

Example where a network interface is DOWN:

/usr/lib/nagios/plugins/check_netio.sh -i ens35
CHECK_NETIO CRITICAL - Interface ens35 is down

Command definition (NRPE)

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

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"
}

# Check network io of eth0 with TCP stats of lost and drop
define service{
  use generic-service
  host_name mylinux1
  service_description NetIO eth0
  check_command check_nrpe!check_netio_regex!-a "eth0" "lost,drop"
}

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"]
}

# Check network io of eth0 with TCP stats of lost and drop
object Service "NetIO eth0" {
  import "generic-service"
  host_name "mylinux1"
  check_command = "nrpe"
  vars.nrpe_command = "check_netio_regex"
  vars.nrpe_arguments = ["eth0", "lost,drop"]
}

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
RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder