I thought, wouldn't it be nice to have a continuously-updating display of how much bandwidth each server is using? And I wondered how to get the pix to tell me how much was going through, broken down by server. I can get the total going through the pix (I do that already, to keep an eye on saturation of my line), but per server? I couldn't see how.
And then I thought of ifconfig. When you run that on a server, it gives you lots of information about the interfaces, including a cumulative total of bytes received and transmitted.
So, I wrote a dozen-line program which loops round a list of servers, uses ssh to remotely run ifconfig, and parses the results to a line that is:
servername, epoch time, bytes rx, bytes tx
and it writes that to a file. I found, in doing that, that different versions of ifconfig have a slightly different output format, but that was easy to overcome.
Cron runs the program once per minute. Of course, that won't be *exactly* a minute, but that wont matter.
Then I have another program that reads the file, and works out the time interval between two takes (which will be roughly a minute, but not exactly), and hence the bytes per second.
Then the program chews through what it's read, and spits out a png file for each server, over a perod of one day, one week and one month. So for six servers, that's 18 graphs. The program is only 90 lines, I was quite surprised.
Still to do ... testing the above. Converting the png to suitable framebuffers, so that I can just blurt it to the screen in a rolling display, server by server. I've ordered another LCD monitor, to go in the server farm (costing £18, Ebay), and the display will be on that, as well as on the monitors that I currently use to display, outside temperature, time and the number of server alerts outstanding.
Of course, what I'm *really* doing here, is finding a way to avoid working on the pix.
Post a Comment