Commit 62da7de4 authored by Mario Hock's avatar Mario Hock

Display top-2 CPU utilization types

instead of user/system
parent 99143f1c
......@@ -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
......
......@@ -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)
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