From bc080dad11cafeee1462ac6507f2ee4c12890e9f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 1 Mar 2014 12:12:11 +0100 Subject: add uptime and idle time in seconds format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/plugins/uptime.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/uptime.py b/src/plugins/uptime.py index 198e1c2..d2a418b 100644 --- a/src/plugins/uptime.py +++ b/src/plugins/uptime.py @@ -22,6 +22,9 @@ class Uptime: ''' The current uptime of the machine and how long it has been idle + @variable uptime_seconds:float Total uptime + @variable total_idle_seconds:float Total processor idle time + @variable average_idle_seconds:float Average processor idle time @variable uptime:(days:int, hours:int, minutes:int, seconds:float) Total uptime @variable total_idle:(days:int, hours:int, minutes:int, seconds:float) Total processor idle time @variable average_idle:(days:int, hours:int, minutes:int, seconds:float) Average processor idle time @@ -51,9 +54,13 @@ class Uptime: Uptime.cpu_count = filter(lambda line : 'processor' in line, Uptime.cpu_count) Uptime.cpu_count = len(list(Uptime.cpu_count)) - self.uptime = Uptime.split_time(uptime) - self.total_idle = Uptime.split_time(idle) - self.average_idle = Uptime.split_time(idle / Uptime.cpu_count) + self.uptime_seconds = uptime + self.total_idle_seconds = idle + self.average_idle_seconds = idle / Uptime.cpu_count + + self.uptime = Uptime.split_time(self.uptime_seconds) + self.total_idle = Uptime.split_time(self.total_idle_seconds) + self.average_idle = Uptime.split_time(self.average_idle_seconds) @staticmethod -- cgit v1.2.3-70-g09d2