Monitoring/alerting for network interface problems

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
gossamer
Posts: 20
Joined: Wed Jul 13, 2011 9:56 pm

Monitoring/alerting for network interface problems

Post by gossamer »

Hi,
I have a fedora22 system running nagios-3.5.1 and would like to find a plugin that monitors network interfaces for "errors" or "collisions". Does something like that exist, or how difficult would it be to write it? For example:

Code: Select all

em1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 64.1.1.18  netmask 255.255.255.224  broadcast 64.1.1.31
        inet6 fe80::225:90ff:fe53:1da7  prefixlen 64  scopeid 0x20<link>
        ether 00:25:90:53:1d:a7  txqueuelen 1000  (Ethernet)
        RX packets 4603323  bytes 1512804813 (1.4 GiB)
        RX errors 0  dropped 262118  overruns 0  frame 0
        TX packets 4639159  bytes 2066388663 (1.9 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 20  memory 0xf7a00000-f7a20000 
I'd like to scan the output of "ifconfig em1" for the "collisions", "errors", and even "dropped" to determine if there's a problem with the network.

We just had a problem with our service provider where there were an increasing number of collisions affecting network performance, but it was very difficult to identify. I thought this would be a good way to receive early warning of such a problem.

Perhaps there's an easier way to find the collisions/errors? Maybe using ip?
User avatar
marcelst
Posts: 4
Joined: Tue Jan 05, 2016 8:51 am
Location: Netherlands
Contact:

Re: Monitoring/alerting for network interface problems

Post by marcelst »

You could write a simple bash script to do this and send the correct exit code to the NRPE client.
Like this:

Code: Select all

#!/bin/bash

if [[ -z $1 || -z $2 || -z $3 ]]
then
        echo "usage $0 interface warning alert"
        echo
        echo "example $0 eth0 1000 2000"
        exit
else
        echo -n
fi

COLLISION_COUNTER=`cat /sys/class/net/$1/statistics/collisions`

if [ $((COLLISION_COUNTER)) -lt $2 ]
then
        echo "OK - collisions $COLLISION_COUNTER"
        exit 0
fi

if [ $((COLLISION_COUNTER)) -ge $2 ] && [ $((COLLISION_COUNTER)) -lt $3 ]
then
        echo "Warning - collisions $COLLISION_COUNTER"
        exit 1
fi

echo "Alert - collisions $COLLISION_COUNTER"
exit 2
I wrote this for CentOS, so you might need to adjust the COLLISION_COUNTER variable for your distro.
IT is not for the faint of heart
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Monitoring/alerting for network interface problems

Post by rkennedy »

Thanks @marcelst!

@gossmer does this help answer your question?
Former Nagios Employee
gossamer
Posts: 20
Joined: Wed Jul 13, 2011 9:56 pm

Re: Monitoring/alerting for network interface problems

Post by gossamer »

Yes, perfect. Somehow I knew the info would be in /sys, but don't know why it didn't occur to me now.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Monitoring/alerting for network interface problems

Post by tmcdonald »

Mind if we lock this up?
Former Nagios employee
gossamer
Posts: 20
Joined: Wed Jul 13, 2011 9:56 pm

Re: Monitoring/alerting for network interface problems

Post by gossamer »

Sounds good, thanks.
Locked