I am writing a CRON/PHP script that will check the server stats every 5 minutes (CPU/RAM/SSD) and log the info to the database. This way I will be able to see server usage over different periods of time.
I am curious also to see how much bandwidth is used at what time in a day. I'd like to have a counter which would always increase. Then I could read the file every 5 minutes and calculate the difference.
The alternative solution I am using now is:
bwm-ng -o plain -u bytes -T sum -c 1 -t $(( 1000 * 5 * 60 ))
However, the problem with the latter is that it takes 5 minutes to return the result. Therefore, can anyone suggest how to approach the issue with the file that stores data usage all the time?