Linux – Recording network traffic peak per second every 5 Minutes

linuxmonitoringnetworking

I would like to monitor my peak network usages. I already use munin to monitor network traffic in a 5 minute sample. But as we have lot of peaks of http traffic which lasts only a few seconds I want to know the peak network usage per second in the last 5 minutes not the average.

At the moment I use iftop which is an easy to see the peak usage. But iftop can only run interactively. I use screen to get it running and can look into it on a regular basis.

How can I use iftop or a similar tool to just write out the peak network usage in the last 5 minutes every 5 minutes. I just need a file with lines like this:

2014-06-17 15:43:12 TX: 14,3 MBit/s RX: 16,2 MBit/s Sum: 29,6 MBit/s
2014-06-17 15:48:12 TX: 11,3 MBit/s RX: 12,2 MBit/s Sum: 22,3 MBit/s

and so on.

I tried ntop but it is quite a bit of overhead and I can't get the data easily into munin. And it does not write out peaks per 5 Minutes.

Does anybody know a tool or efficient script for this?

Best Answer

As of Munin 2.0 you can use a feature called supersampling to collect data points with 1-second resolution. The Munin polling interval still will be 5 minutes, the respective Munin plugin is responsible for actively collecting and storing the high-resolution data. There is a sample implementation - the multicpu1sec plugin which is recording mpstat data.

Now the graphs Munin presents you are a different story. Munin is using RRDtool for graphing, which in turn is able to use different consolidation functions (CF) to represent more than one data point into a single pixel of a graph. As of current, Munin is only able to graph average (AVG) data and there is no configurable support for other consolidation functions (minimum, maximum, total, last).

You might consider patching Munin accordingly - it does not look too hard to do. Alternatively, you might just invoke rrdtool graph with custom parameters and a different consolidation function as it suits your needs. Just look into your munin-cgi-graph.log to get a starting point for playing around. If you only need it on a case-to-case basis, you also might just zoom into the area of interest (which would need you to have dynamic graphs enabled in your Munin configuration) and look at the Min/Max values printed in the graphs' legend area.