I have a media PC (that is also a web test server on the LAN) that I want to reboot every so often as long as it is not in use. I have tests in place for the server using kodi, myth etc (its the display for kodi as well), however, I need to test if anything is using it over the network (file copying, developing websites, watching something etc).
I figure the easiest way to do this is find out how much data has been transferred over the network in the last 3mins or so. How can I do this from a bash script (.sh file run by cron)?
OK, solution found by using rx_bytes and tx_bytes (received and transmitted bytes, can also use packets or check for dropped packets, see: http://xmodulo.com/measure-packets-per-second-throughput-high-speed-network-interface.html)
The script:
Example of use (remember to throw in the amount of time in seconds):
This would check how many KB were sent/received over a 10 second period. Of course you can edit the script to include only R or T if you just want the sent or received value etc. This command will work from another .sh file or within the terminal, over SSH etc.