mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 14:16:00 +00:00
[docker_] status: report and warn on unhealthy containers
Signed-off-by: Olivier Mehani <shtrom@ssji.net>
This commit is contained in:
parent
d3a7b794bc
commit
2482518826
1 changed files with 13 additions and 1 deletions
|
@ -189,6 +189,7 @@ def container_attributes(container, *args):
|
||||||
|
|
||||||
def print_containers_status(client):
|
def print_containers_status(client):
|
||||||
running = []
|
running = []
|
||||||
|
unhealthy = []
|
||||||
paused = []
|
paused = []
|
||||||
created = []
|
created = []
|
||||||
restarting = []
|
restarting = []
|
||||||
|
@ -197,7 +198,11 @@ def print_containers_status(client):
|
||||||
dead = []
|
dead = []
|
||||||
for container in client.all_containers:
|
for container in client.all_containers:
|
||||||
if container.status == 'running':
|
if container.status == 'running':
|
||||||
running.append(container)
|
state = client.api.inspect_container(container.name)['State']
|
||||||
|
if state.get('Health', {}).get('Status') == 'unhealthy':
|
||||||
|
unhealthy.append(container)
|
||||||
|
else:
|
||||||
|
running.append(container)
|
||||||
elif container.status == 'paused':
|
elif container.status == 'paused':
|
||||||
paused.append(container)
|
paused.append(container)
|
||||||
elif container.status == 'created':
|
elif container.status == 'created':
|
||||||
|
@ -212,6 +217,8 @@ def print_containers_status(client):
|
||||||
dead.append(container)
|
dead.append(container)
|
||||||
print('running.value', len(running))
|
print('running.value', len(running))
|
||||||
print('running.extinfo', ', '.join(container_summary(c) for c in running))
|
print('running.extinfo', ', '.join(container_summary(c) for c in running))
|
||||||
|
print('unhealthy.value', len(unhealthy))
|
||||||
|
print('unhealthy.extinfo', ', '.join(container_summary(c) for c in unhealthy))
|
||||||
print('paused.value', len(paused))
|
print('paused.value', len(paused))
|
||||||
print('paused.extinfo', ', '.join(container_summary(c) for c in paused))
|
print('paused.extinfo', ', '.join(container_summary(c) for c in paused))
|
||||||
print('created.value', len(created))
|
print('created.value', len(created))
|
||||||
|
@ -353,6 +360,11 @@ def main():
|
||||||
"commands run in them with `docker container exec "
|
"commands run in them with `docker container exec "
|
||||||
"[--detach|--interactive,--privileged,--tty] <NAME> <COMMAND>`"
|
"[--detach|--interactive,--privileged,--tty] <NAME> <COMMAND>`"
|
||||||
)
|
)
|
||||||
|
print("unhealthy.label UNHEALTHY")
|
||||||
|
print("unhealthy.draw AREASTACK")
|
||||||
|
print("unhealthy.warning 1")
|
||||||
|
print("unhealthy.info Unhealthy containers can be restarted with "
|
||||||
|
"`docker container restart <NAME>`")
|
||||||
print("paused.label PAUSED")
|
print("paused.label PAUSED")
|
||||||
print("paused.draw AREASTACK")
|
print("paused.draw AREASTACK")
|
||||||
print("paused.info Paused containers can be resumed with "
|
print("paused.info Paused containers can be resumed with "
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue