Merge pull request #573 from martindoublem/docker
[module] improvement of docker_ps by adding states
This commit is contained in:
commit
d90af8c257
1 changed files with 14 additions and 3 deletions
|
@ -21,14 +21,25 @@ import bumblebee.engine
|
||||||
|
|
||||||
class Module(bumblebee.engine.Module):
|
class Module(bumblebee.engine.Module):
|
||||||
def __init__(self, engine, config):
|
def __init__(self, engine, config):
|
||||||
widget = bumblebee.output.Widget(full_text=self.status)
|
widgets = bumblebee.output.Widget(full_text=self.status)
|
||||||
super(Module, self).__init__(engine, config, widget)
|
super(Module, self).__init__(engine, config, widgets)
|
||||||
self._status = self.status
|
self._status = self.status
|
||||||
|
self._state = self.state
|
||||||
|
|
||||||
def update(self, widgets):
|
def update(self, widgets):
|
||||||
self._status = self.status
|
self._status = self.status
|
||||||
|
self._state = self.state
|
||||||
|
|
||||||
def status(self, _):
|
def state(self, widget):
|
||||||
|
state = []
|
||||||
|
status = self.status(widget)
|
||||||
|
if status == "OK - 0":
|
||||||
|
state.append("warning")
|
||||||
|
elif status in ["n/a", "Daemon off"]:
|
||||||
|
state.append("critical")
|
||||||
|
return state
|
||||||
|
|
||||||
|
def status(self, widget):
|
||||||
try:
|
try:
|
||||||
cli = docker.DockerClient(base_url='unix://var/run/docker.sock')
|
cli = docker.DockerClient(base_url='unix://var/run/docker.sock')
|
||||||
cli.ping()
|
cli.ping()
|
||||||
|
|
Loading…
Reference in a new issue