From 660bd52e744ff3d88a33e6969a60b0045b365a86 Mon Sep 17 00:00:00 2001 From: Nicolas Hennion Date: Sat, 24 Nov 2012 14:50:36 +0100 Subject: [PATCH] Color on extended CPU info --- glances/glances.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/glances/glances.py b/glances/glances.py index 06452841..e80a328f 100755 --- a/glances/glances.py +++ b/glances/glances.py @@ -1266,6 +1266,9 @@ class glancesScreen: def __getCpuColor(self, current=0, max=100): return self.__getColor(current, max) + def __getExtCpuColor(self, current=0, max=100): + return self.__getColor2(current, max) + def __getLoadAlert(self, current=0, core=1): # If current < CAREFUL*core of max then alert = OK # If current > CAREFUL*core of max then alert = CAREFUL @@ -1578,13 +1581,15 @@ class glancesScreen: "%.1f" % cpu['idle'], 8) try: self.term_window.addnstr(self.cpu_y + 2, self.cpu_x + 27, - "%.1f" % cpu['iowait'], 8) + "%.1f" % cpu['iowait'], 8, + self.__getExtCpuColor(cpu['iowait'])) except: self.term_window.addnstr(self.cpu_y + 2, self.cpu_x + 27, "N/A", 8) try: self.term_window.addnstr(self.cpu_y + 3, self.cpu_x + 27, - "%.1f" % cpu['irq'], 8) + "%.1f" % cpu['irq'], 8, + self.__getExtCpuColor(cpu['irq'])) except: self.term_window.addnstr(self.cpu_y + 3, self.cpu_x + 27, "N/A", 8) @@ -2553,6 +2558,11 @@ class GlancesInstance(): self.__update__() return json.dumps(stats.getMemSwap()) + def getNow(self): + # Update and return current date/hour + self.__update__() + return json.dumps(stats.getNow()) + class GlancesServer(): """