2016-10-31 12:16:23 +01:00
|
|
|
import bumblebee.module
|
|
|
|
import psutil
|
|
|
|
|
2016-10-31 16:08:03 +01:00
|
|
|
def description():
|
|
|
|
return "Displays CPU utilization across all CPUs."
|
|
|
|
|
2016-11-05 16:18:53 +01:00
|
|
|
def parameters():
|
|
|
|
return [
|
|
|
|
"cpu.warning: Warning threshold in % of disk usage (defaults to 70%)",
|
|
|
|
"cpu.critical: Critical threshold in % of disk usage (defaults to 80%)",
|
|
|
|
]
|
|
|
|
|
2016-10-31 12:16:23 +01:00
|
|
|
class Module(bumblebee.module.Module):
|
2016-11-05 14:26:02 +01:00
|
|
|
def __init__(self, output, config, alias):
|
|
|
|
super(Module, self).__init__(output, config, alias)
|
2016-10-31 12:16:23 +01:00
|
|
|
self._perc = psutil.cpu_percent(percpu=False)
|
|
|
|
|
2016-11-05 15:28:33 +01:00
|
|
|
output.add_callback(module=self.instance(), button=1, cmd="gnome-system-monitor")
|
2016-11-01 08:15:57 +01:00
|
|
|
|
2016-11-05 12:28:05 +01:00
|
|
|
def widgets(self):
|
2016-10-31 12:16:23 +01:00
|
|
|
self._perc = psutil.cpu_percent(percpu=False)
|
2016-11-05 13:12:30 +01:00
|
|
|
return bumblebee.output.Widget(self, "{:05.02f}%".format(self._perc))
|
2016-10-31 12:16:23 +01:00
|
|
|
|
2016-11-05 13:42:26 +01:00
|
|
|
def warning(self, widget):
|
2016-11-05 14:26:02 +01:00
|
|
|
return self._perc > self._config.parameter("warning", 70)
|
2016-10-31 12:16:23 +01:00
|
|
|
|
2016-11-05 13:42:26 +01:00
|
|
|
def critical(self, widget):
|
2016-11-05 14:26:02 +01:00
|
|
|
return self._perc > self._config.parameter("critical", 80)
|
2016-10-31 12:16:23 +01:00
|
|
|
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|