From f31c0e492d3ba903d08e83ba08153b8b23fdf2cd Mon Sep 17 00:00:00 2001 From: Tobi-wan Kenobi Date: Fri, 25 Nov 2016 21:45:30 +0100 Subject: [PATCH] [modules] Add initial version of a load module Add a load module that shows 1/5/15 minute load average and allows the user to set warning and critical thresholds on the 1 minute average. fixes #9 --- bumblebee/modules/load.py | 37 ++++++++++++++++++++++++++++++++ screenshots/load.png | Bin 0 -> 1956 bytes themes/default.json | 3 +++ themes/gruvbox-powerline.json | 3 +++ themes/powerline.json | 3 +++ themes/solarized-powerline.json | 3 +++ themes/solarized.json | 3 +++ 7 files changed, 52 insertions(+) create mode 100644 bumblebee/modules/load.py create mode 100644 screenshots/load.png diff --git a/bumblebee/modules/load.py b/bumblebee/modules/load.py new file mode 100644 index 0000000..fba5dbd --- /dev/null +++ b/bumblebee/modules/load.py @@ -0,0 +1,37 @@ +import bumblebee.module +import multiprocessing +import os + +def description(): + return "Displays system load." + +def parameters(): + return [ + "load.warning: Warning threshold for the one-minute load average (defaults to 70% of the number of CPUs)", + "load.critical: Critical threshold for the one-minute load average (defaults 80% of the number of CPUs)" + ] + +class Module(bumblebee.module.Module): + def __init__(self, output, config, alias): + super(Module, self).__init__(output, config, alias) + self._cpus = 1 + try: + self._cpus = multiprocessing.cpu_count() + except multiprocessing.NotImplementedError as e: + pass + + output.add_callback(module=self.instance(), button=1, cmd="gnome-system-monitor") + + def widgets(self): + self._load = os.getloadavg() + + return bumblebee.output.Widget(self, "{:.02f}/{:.02f}/{:.02f}".format( + self._load[0], self._load[1], self._load[2])) + + def warning(self, widget): + return self._load[0] > self._config.parameter("warning", self._cpus*0.7) + + def critical(self, widget): + return self._load[0] > self._config.parameter("critical", self._cpus*0.8) + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/screenshots/load.png b/screenshots/load.png new file mode 100644 index 0000000000000000000000000000000000000000..8ed7bd66fc289a3bc96ec977d059d3287d07b5d2 GIT binary patch literal 1956 zcmV;V2V3}wP)RK`l)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