Browse Source

[DockerAPI] Add top and stats

andryyy 6 years ago
parent
commit
f796db0a65
1 changed files with 14 additions and 0 deletions
  1. 14 0
      data/Dockerfiles/dockerapi/server.py

+ 14 - 0
data/Dockerfiles/dockerapi/server.py

@@ -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: