Page 1 of 1

Monitoring/alerting for network interface problems

Posted: Mon Jan 04, 2016 9:07 pm
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?

Re: Monitoring/alerting for network interface problems

Posted: Tue Jan 05, 2016 9:22 am
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.

Re: Monitoring/alerting for network interface problems

Posted: Tue Jan 05, 2016 10:27 am
by rkennedy
Thanks @marcelst!

@gossmer does this help answer your question?

Re: Monitoring/alerting for network interface problems

Posted: Tue Jan 05, 2016 10:49 am
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.

Re: Monitoring/alerting for network interface problems

Posted: Tue Jan 05, 2016 10:53 am
by tmcdonald
Mind if we lock this up?

Re: Monitoring/alerting for network interface problems

Posted: Tue Jan 05, 2016 12:03 pm
by gossamer
Sounds good, thanks.