aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-03-01 12:12:11 +0100
committerMattias Andrée <maandree@operamail.com>2014-03-01 12:12:11 +0100
commitbc080dad11cafeee1462ac6507f2ee4c12890e9f (patch)
treeb9de9ec1cbd5aafac5513d3f044377d5f7a740c5
parentm (diff)
downloadxpybar-bc080dad11cafeee1462ac6507f2ee4c12890e9f.tar.gz
xpybar-bc080dad11cafeee1462ac6507f2ee4c12890e9f.tar.bz2
xpybar-bc080dad11cafeee1462ac6507f2ee4c12890e9f.tar.xz
add uptime and idle time in seconds format
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--examples/plugin-test3
-rw-r--r--src/plugins/uptime.py13
2 files changed, 12 insertions, 4 deletions
diff --git a/examples/plugin-test b/examples/plugin-test
index c78ae83..145fcec 100644
--- a/examples/plugin-test
+++ b/examples/plugin-test
@@ -21,10 +21,11 @@ def redraw():
uptime_ = Uptime()
uptime = '%id %02i:%02i:%0.2f' % uptime_.uptime
+ prc_idle = uptime_.average_idle_seconds / uptime_.uptime_seconds
tot_idle = '%id %02i:%02i:%0.2f' % uptime_.total_idle
avg_idle = '%id %02i:%02i:%0.2f' % uptime_.average_idle
uptime = 'Uptime: %s' % (uptime)
- idle = 'Idle time: %s : %s' % (avg_idle, tot_idle)
+ idle = 'Idle time: %s : %s : %1.2f%%' % (avg_idle, tot_idle, prc_idle * 100)
loadavg_ = AverageLoad()
avg_5 = int(loadavg_.avg_5_min * 100)
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