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
62da7de4
Commit
62da7de4
authored
Aug 18, 2014
by
Mario Hock
Browse files
Display top-2 CPU utilization types
instead of user/system
parent
99143f1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
curses_display.py
View file @
62da7de4
...
...
@@ -154,15 +154,21 @@ def display(measurement):
stdscr
.
addstr
(
y
,
1
,
'CPU{0}'
.
format
(
num
),
curses
.
color_pair
(
1
))
stdscr
.
addstr
(
y
,
LABEL_CPU_UTIL
,
'util: '
,
curses
.
color_pair
(
2
))
stdscr
.
addstr
(
y
,
LABEL_CPU_UTIL
+
26
,
'|'
,
curses
.
color_pair
(
2
))
stdscr
.
addstr
(
y
,
LABEL_CPU_USER
,
'
user
: '
,
curses
.
color_pair
(
2
))
stdscr
.
addstr
(
y
,
LABEL_CPU_SYSTEM
,
'system: '
,
curses
.
color_pair
(
2
))
#
stdscr.addstr(y, LABEL_CPU_USER, '
type
: ', curses.color_pair(2))
#
stdscr.addstr(y, LABEL_CPU_SYSTEM, 'system: ', curses.color_pair(2))
# CPU bar
_display_cpu_bar
(
y
,
LABEL_CPU_UTIL
+
6
,
cpu
)
# user/system
stdscr
.
addstr
(
y
,
LABEL_CPU_USER
+
6
,
'{0:.2%}'
.
format
(
cpu
.
user
/
100.0
),
curses
.
color_pair
(
3
))
stdscr
.
addstr
(
y
,
LABEL_CPU_SYSTEM
+
8
,
'{0:.2%}'
.
format
(
cpu
.
system
/
100.0
),
curses
.
color_pair
(
3
))
#stdscr.addstr(y, LABEL_CPU_USER+6, '{0:.2%}'.format( cpu.user/100.0 ), curses.color_pair(3))
#stdscr.addstr(y, LABEL_CPU_SYSTEM+8, '{0:.2%}'.format( cpu.system/100.0 ), curses.color_pair(3))
cpu_sorted
=
helpers
.
sort_named_tuple
(
cpu
)
stdscr
.
addstr
(
y
,
LABEL_CPU_USER
,
cpu_sorted
[
0
][
0
]
+
": "
,
curses
.
color_pair
(
4
))
stdscr
.
addstr
(
"{:.2%}"
.
format
(
cpu_sorted
[
0
][
1
]
/
100
),
curses
.
color_pair
(
3
))
stdscr
.
addstr
(
y
,
LABEL_CPU_SYSTEM
,
cpu_sorted
[
1
][
0
]
+
": "
,
curses
.
color_pair
(
4
))
stdscr
.
addstr
(
"{:.2%}"
.
format
(
cpu_sorted
[
1
][
1
]
/
100
),
curses
.
color_pair
(
3
))
num
+=
1
y
+=
1
...
...
helpers.py
View file @
62da7de4
...
...
@@ -4,6 +4,7 @@
from
collections
import
namedtuple
import
os
import
netifaces
import
operator
_ptime_cpu_perc_nt
=
None
...
...
@@ -176,3 +177,7 @@ def get_sysinfo():
ret
[
out_field
]
=
value
return
ret
def
sort_named_tuple
(
data
):
return
sorted
(
data
.
_asdict
().
items
()
,
key
=
operator
.
itemgetter
(
1
),
reverse
=
True
)
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