I'm trying to create a simple monitoring system that will show a graph of sales that is linked entirely to data of bandwidth, CPU and Memory stats as they relate to sales. So if I sale 1 widget per 5 seconds, that will be contingent upon my bandwidth etc being above a certain threshold. So I've formulated a way to do the graph but I'm just having a time getting the stats. I can use any of a number of monitoring systems but I just need 1 line for bandwidth, CPU Usage, and Memory Usage once per second. I made a python script that gets all the IP information from all interfaces. But for if I had a script I could run from terminal that simply output a single line I could just pipe that to a file and then access the file to run my real time graph.
So for network I can use:
$ ifconfig
I pipe it into a json file for easy reference.
I can use:
$ free -m
for memory which I suppose I can pipe into a file as well
Then I could use:
$ cat /proc/loadavg
for CPU and again pipe that.
Is there an easier way to do this? So that I receive a single line for each command and can easily (more importantly quickly) send that information via Javascript or HTML5 FileReader to the graphing solution?