Projet

Général

Profil

Révision 24825188

ID2482518826d56ff24c0f88ebce4930eae0efbd03
Parent d3a7b794
Enfant 1fa5558a

Ajouté par Olivier Mehani il y a presque 5 ans

[docker_] status: report and warn on unhealthy containers

Signed-off-by: Olivier Mehani <>

Voir les différences:

plugins/docker/docker_
189 189

  
190 190
def print_containers_status(client):
191 191
    running = []
192
    unhealthy = []
192 193
    paused = []
193 194
    created = []
194 195
    restarting = []
......
197 198
    dead = []
198 199
    for container in client.all_containers:
199 200
        if container.status == 'running':
200
            running.append(container)
201
            state = client.api.inspect_container(container.name)['State']
202
            if state.get('Health', {}).get('Status') == 'unhealthy':
203
                unhealthy.append(container)
204
            else:
205
                running.append(container)
201 206
        elif container.status == 'paused':
202 207
            paused.append(container)
203 208
        elif container.status == 'created':
......
212 217
            dead.append(container)
213 218
    print('running.value', len(running))
214 219
    print('running.extinfo', ', '.join(container_summary(c) for c in running))
220
    print('unhealthy.value', len(unhealthy))
221
    print('unhealthy.extinfo', ', '.join(container_summary(c) for c in unhealthy))
215 222
    print('paused.value', len(paused))
216 223
    print('paused.extinfo', ', '.join(container_summary(c) for c in paused))
217 224
    print('created.value', len(created))
......
353 360
                  "commands run in them with `docker container exec "
354 361
                  "[--detach|--interactive,--privileged,--tty] <NAME> <COMMAND>`"
355 362
                  )
363
            print("unhealthy.label UNHEALTHY")
364
            print("unhealthy.draw AREASTACK")
365
            print("unhealthy.warning 1")
366
            print("unhealthy.info Unhealthy containers can be restarted with "
367
                  "`docker container restart <NAME>`")
356 368
            print("paused.label PAUSED")
357 369
            print("paused.draw AREASTACK")
358 370
            print("paused.info Paused containers can be resumed with "

Formats disponibles : Unified diff