[DockerAPI] Add top and stats

master
andryyy 2018-10-27 13:25:18 +02:00
parent e04a3aed6a
commit f796db0a65
1 changed files with 14 additions and 0 deletions

View File

@ -67,6 +67,20 @@ class container_post(Resource):
except Exception as e:
return jsonify(type='danger', msg=str(e))
elif post_action == 'top':
try:
for container in docker_client.containers.list(all=True, filters={"id": container_id}):
return jsonify(type='success', msg=container.top())
except Exception as e:
return jsonify(type='danger', msg=str(e))
elif post_action == 'stats':
try:
for container in docker_client.containers.list(all=True, filters={"id": container_id}):
return jsonify(type='success', msg=container.stats(decode=True, stream=False))
except Exception as e:
return jsonify(type='danger', msg=str(e))
elif post_action == 'exec':
if not request.json or not 'cmd' in request.json: