When using logstash with kibana this is easy to setup
What we did is log the total traffic to a log file with the following bash script.
LOGPATH="systemstatus.log"
timestamp() {
date +"%Y-%m-%dT%T.%N"
}
while ( sleep 60 ) ; do
#clear log file
truncate -s 0 $LOGPATH
#log timstamp and type of log line
echo -n "$(timestamp) linux::systemstatus::network " >> $LOGPATH
#remove tabs and spaces from grep result
grep "eth" /proc/net/dev |head -n1|sed -e 's/^[ \t]*//'| sed -n 's/ \+/ /gp' >> $LOGPATH
Done
Nxlog exports the log to logstash and kibana.
In logstash the string is parsed to individual values
Kibana makes the traffic visible in a derivative histogram (this shows the difference from 1 value to the next)
This gives us a nice overal graph of the used bandwidth. On top of this we also log the CPU, Disk and Memory usage of the server.
Note: we parse the whole log line from /proc/net/dev into seperate values just in case we want to monitor on lost packeges or errors