2

I found this script at https://github.com/Cosmologist/collectd-network-bandwidth-usage.

<Plugin exec>
    Exec user "/tmp/exec-network-bandwidth-usage.sh" "eth0"
</Plugin>

It runs a bash script that checks /sys/class/net/eth0/statistics/rx_bytes and tx_bytes.

#!/bin/bash

HOSTNAME="${COLLECTD_HOSTNAME:-`hostname -f`}"
INTERVAL="${COLLECTD_INTERVAL:-60}"

while sleep "$INTERVAL"; do
    RX=`cat /sys/class/net/$1/statistics/rx_bytes`
    TX=`cat /sys/class/net/$1/statistics/tx_bytes`

    echo "PUTVAL $HOSTNAME/network-bandwidth-usage/if_octets interval=$INTERVAL N:$RX:$TX"
done

My goal is to see how much MB's of traffic was transfered in a timespan. How reliable is using the data from /sys/class/net/eth0/statistics/rx_bytes like this to find out how much traffic our entire server farm is producing?

ujjain
  • 3,963
  • 15
  • 50
  • 88

1 Answers1

1

I´ve installed in a lot of my linux servers to monitor my traffic interface the vnstat command. It is very easy to install and you get with this great deal of information. https://www.howtoforge.com/tutorial/vnstat-network-monitoring-ubuntu/

I guess /sys/class/net/eth0/statistics are reliable but will have to be stored in a monitoring app to extract then useful information... With vnstat installed in our system you have all this information when you need it in the system itself.

I hope it can be useful

Kind regards

  • Yes, but you won't be able to centrally see how much data has been transferred over multiple servers. I ended up using a integral-graph in grafana/graphite over the bandwidth-usage graph. This is the result: http://i.imgur.com/4cc9yRv.png. It includes bamboo usage of our entire bamboo farm. – ujjain Aug 03 '16 at 10:35
  • Very good option! I use Pandora FMS montoring tool to get the vnstat information and then I can create other modules called syntethic modules. With this modules I can add all traffic from all servers and obtain a similar graph. – santimviejo Aug 04 '16 at 13:53