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