Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CPUnetLOG
CPUnetLOG
Commits
71c64c14
Commit
71c64c14
authored
Jul 30, 2014
by
Mario Hock
Browse files
fixed "units"
consistently use Bits/s and display MBits/s
parent
439eee81
Changes
2
Hide whitespace changes
Inline
Side-by-side
curses_display.py
View file @
71c64c14
...
...
@@ -19,9 +19,9 @@ stdscr = None
## some "constants"/preferences
nics
=
None
nic_speeds
=
None
divisor
=
1000
divisor
=
1000
000.0
rounding_digits
=
2
unit
=
"
KByte
s"
unit
=
"
MBit
s"
...
...
@@ -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
...
...
helpers.py
View file @
71c64c14
...
...
@@ -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
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment