2012-01-10 04:57:02 |
Will Elwood |
description |
I noticed my network usage status disappeared recently, tracked it down to the way /proc/net/dev is parsed.
Test data:
<pre>
lo:907096306 125825857 0 0 0 0 0 0 907096306 125825857 0 0 0 0 0 0
eth1:858630703 130597790 0 0 0 0 0 31982 1819919816 140249010 0 0 0 0 0 0
eth0:1661706230 120880636 0 0 0 0 0 0 203288241 59658728 0 0 1 0 0 0
</pre>
The current code that reads in a loop into variables is caught out by the lack of space to separate the interface and the first number (receive bytes). I've had a go at fixing it using grep, cut and awk instead. Also updated ec2_cost to match (but don't have any way to test) and removed the unused OIFS and tx1 variables in network, hope that's alright. |
I noticed my network usage status disappeared recently, tracked it down to the way /proc/net/dev is parsed.
Test data:
lo:907096306 125825857 0 0 0 0 0 0 907096306 125825857 0 0 0 0 0 0
eth1:858630703 130597790 0 0 0 0 0 31982 1819919816 140249010 0 0 0 0 0 0
eth0:1661706230 120880636 0 0 0 0 0 0 203288241 59658728 0 0 1 0 0 0
The current code that reads in a loop into variables is caught out by the lack of space to separate the interface and the first number (receive bytes). I've had a go at fixing it using grep, cut and awk instead. Also updated ec2_cost to match (but don't have any way to test) and removed the unused OIFS and tx1 variables in network, hope that's alright. |
|