[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:
parent
edfccd2d31
commit
23d7d53fca
5 changed files with 14 additions and 22 deletions
|
@ -28,10 +28,6 @@ class Module(bumblebee.engine.Module):
|
|||
self._utilization = psutil.cpu_percent(percpu=False)
|
||||
|
||||
def state(self, widget):
|
||||
if self._utilization > int(self.parameter("critical", 80)):
|
||||
return "critical"
|
||||
if self._utilization > int(self.parameter("warning", 70)):
|
||||
return "warning"
|
||||
return None
|
||||
return self.threshold_state(self._utilization, 70, 80)
|
||||
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue