Bash script to collect network interface statistics (RX/TX)

During an Incident I was dealing with an issue that an amount of different *nix machines were receiving / transmitting data over the wrong interface.
Since we didn’t want to check every *nix machine manually to see which interface is used I wrote a simple bash script which collects necessary network interface statistics like received / transmitted bytes for every interface configured over time.

The script writes a log to a separate file with following format:

Wed Jan 21 14:58:13 CET 2015 NIC=eth7 RXbs=2807182787 TXbs=192412352

while NIC = Interface, RXbs = Received bytes per second and TXbs = Transmitted bytes per second.

We executed the script every minute by using the crontab and we collected and analyzed the log by using Splunk.