Commit 0991d182 authored by Mario Hock's avatar Mario Hock
Browse files

nicer output

rounding (also to KBytes/s)
actually look at bytes/s instead of packets/s
parent 7e218890
......@@ -108,19 +108,26 @@ def display_cpu(measurement):
## XXX TESTING
def desplay_network_traffic(measurement, nics = None):
divisor = 1000
rounding_digits = 2
unit = "KBytes"
if not nics:
nics = measurement.net_io.keys()
for nic in nics:
values = measurement.net_io[nic]
print( "[" + nic + "] Sending (bytes/s): " + str(values.ratio["packets_sent"]) +
", Receiving (bytes/s): " + str(values.ratio["packets_recv"]) )
sending = str( round(values.ratio["bytes_sent"] / divisor, rounding_digits) )
receiving = str( round(values.ratio["bytes_recv"] / divisor, rounding_digits) )
print( "[" + nic + "] Sending (" + unit + "/s): " + sending +
", Receiving (" + unit + "/s): " + receiving )
## XXX TESTING
def display(measurement):
nics = ("eth0", "wlan0")
nics = ("eth0", "wlan0", "lo")
display_cpu(measurement)
desplay_network_traffic( measurement, nics )
......@@ -141,11 +148,10 @@ def displayX(measurement):
## XXX TESTING
## XXX TESTING -- NOTE: takes unnecessary Readings!!
def test_loop():
for i in range(10):
display( measure() )
time.sleep(0.5)
for i in range(100):
display( measure(2.0) )
print
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment