[modules] critical/warning threshold refactoring

Quite a lot of modules use the "if higher X -> critical, if higher Y ->
warning" idiom now, so extracted that into a common function for reuse.

see #23
This commit is contained in:
Tobi-wan Kenobi 2016-12-11 08:25:54 +01:00
parent edfccd2d31
commit 23d7d53fca
5 changed files with 14 additions and 22 deletions

View file

@ -35,9 +35,6 @@ class Module(bumblebee.engine.Module):
self._load = os.getloadavg()
def state(self, widget):
if self._load[0] > float(self.parameter("critical", self._cpus*0.8)):
return "critical"
if self._load[0] > float(self.parameter("warning", self._cpus*0.7)):
return "warning"
return self.threshold_state(self._load[0], self._cpus*0.7, self._cpus*0.8)
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4