Commit 71c64c14 authored by Mario Hock's avatar Mario Hock
Browse files

fixed "units"

consistently use Bits/s and display MBits/s
parent 439eee81
......@@ -19,9 +19,9 @@ stdscr = None
## some "constants"/preferences
nics = None
nic_speeds = None
divisor = 1000
divisor = 1000000.0
rounding_digits = 2
unit = "KBytes"
unit = "MBits"
......@@ -116,21 +116,21 @@ def display(measurement):
for nic in active_nics:
values = measurement.net_io[nic]
_send = values.ratio["bytes_sent"]
_recv = values.ratio["bytes_recv"]
_send = values.ratio["bytes_sent"] * 8 # Bits/s
_recv = values.ratio["bytes_recv"] * 8 # Bits/s
sending = _format_net_speed( _send )
send_percent = _send/nic_speeds[nic] ## FIXME / ??
send_ratio = _send/nic_speeds[nic]
receiving = _format_net_speed( _recv )
receive_percent = _recv/nic_speeds[nic] ## FIXME / ??
receive_ratio = _recv/nic_speeds[nic]
sum_sending += _send
sum_receiving += _recv
stdscr.addstr(y, 1, '{0}'.format(nic), curses.color_pair(1))
stdscr.addstr(y, 20, 'Sent:', curses.color_pair(2))
stdscr.addstr(y, 26, '{0} {1}/s ({2:.2%})'.format(sending, unit, send_percent), curses.color_pair(3))
stdscr.addstr(y, 26, '{0} {1}/s ({2:.2%})'.format(sending, unit, send_ratio), curses.color_pair(3))
stdscr.addstr(y, 50, 'Received:', curses.color_pair(2))
stdscr.addstr(y, 60, '{0} {1}/s ({2:.2%})'.format(receiving,unit, receive_percent), curses.color_pair(3))
stdscr.addstr(y, 60, '{0} {1}/s ({2:.2%})'.format(receiving,unit, receive_ratio), curses.color_pair(3))
y += 1
......
......@@ -95,7 +95,7 @@ def get_nic_speeds():
for nic in get_nics():
try:
with open("/sys/class/net/" + nic + "/speed", "r") as f:
speed = int( f.read().strip() )
speed = int( f.read().strip() ) * 1000 * 1000
ret[nic] = speed
except OSError:
......
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