[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

@ -38,10 +38,6 @@ class Module(bumblebee.engine.Module):
self._perc = 100.0*self._used/self._size
def state(self, widget):
if self._perc > float(self.parameter("critical", 90)):
return "critical"
if self._perc > float(self.parameter("warning", 80)):
return "warning"
return None
return self.threshold_state(self._perc, 80, 90)
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4