1
0
mirror of https://github.com/newnius/YAO-agent.git synced 2025-12-15 13:56:44 +00:00

update agent, add more metrics

This commit is contained in:
2019-04-24 15:14:01 +08:00
parent b910e3131e
commit 4a6cd8e8a0
6 changed files with 57 additions and 14 deletions

View File

@@ -114,6 +114,26 @@ class MyHandler(BaseHTTPRequestHandler):
container.stop()
msg = {"code": 0}
self.send_response(200)
self.send_header('Content-type', 'application/json')
self.end_headers()
self.wfile.write(bytes(json.dumps(msg), "utf-8"))
elif self.path == "/remove":
form = cgi.FieldStorage(
fp=self.rfile,
headers=self.headers,
environ={
'REQUEST_METHOD': 'POST',
'CONTENT_TYPE': self.headers['Content-Type'],
})
container_id = form["id"].value
client = docker.from_env()
container = client.containers.get(container_id)
container.remove(force=True)
msg = {"code": 0}
self.send_response(200)
self.send_header('Content-type', 'application/json')
self.end_headers()