From 8049a8733933ef586d6d49279a291ba367b38625 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 1 Mar 2014 21:07:57 +0100 Subject: add discstats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- examples/plugin-test | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/plugin-test b/examples/plugin-test index d29b5a7..3fce9bc 100644 --- a/examples/plugin-test +++ b/examples/plugin-test @@ -11,6 +11,7 @@ from plugins.pacman import Pacman from plugins.uname import Uname from plugins.df import Discs from plugins.mem import Memory +from plugins.discstats import DiscStats OUTPUT, HEIGHT, YPOS, TOP = 0, 24, 24, True @@ -128,7 +129,23 @@ def redraw(): if use > 99: colour = '41;33' discs = 'df: %s : \033[%sm%.2f\033[0m%%' % (' '.join(discs), colour, use) - text = '%s │ %s │ %s │ %s │ %s │ %s │ %s │ %s │ %s\n%s' - text %= (time, uptime, idle, loadavg, users, uname, mem, swp, shm, discs) + discstats_ = DiscStats() + discstats = [] + for disc in discstats_.devices.keys(): + if disc.startswith('sd') or disc.startswith('hd'): + disc = discstats_.devices[disc] + discstats.append((disc.device, disc.io_current)) + def colourise(value): + colour = '39' + if value >= 1: colour = '32' + if value >= 3: colour = '33' + if value >= 5: colour = '31' + return '\033[%sm%i\033[0m' % (colour, value) + discstats.sort(key = lambda x : x[0]) + discstats = ['%s:%s' % (d[2:], colourise(i)) for d, i in discstats] + discstats = 'Disc stats: %s' % (' '.join(discstats)) + + text = '%s │ %s │ %s │ %s │ %s │ %s │ %s │ %s │ %s\n%s │ %s' + text %= (time, uptime, idle, loadavg, users, uname, mem, swp, shm, discs, discstats) bar.draw_coloured_text(0, 10, 0, 2, text) -- cgit v1.2.3-70-g09d2