added cpu, ram and version information

This commit is contained in:
DJ2LS 2021-07-25 16:12:22 +02:00 committed by GitHub
parent da535d6636
commit ba620ab847
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,7 +17,7 @@ import json
import subprocess
import os
import static
import psutil
#PORT = 3001
#TNCPROCESS = 0
#TNCSTARTED = False
@ -78,6 +78,7 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
try:
received_json = json.loads(data)
print(received_json)
except:
received_json = ''
@ -130,7 +131,7 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
if received_json["type"] == 'GET' and received_json["command"] == 'DAEMON_STATE':
data = {'COMMAND' : 'DAEMON_STATE', 'DAEMON_STATE' : [], 'INPUT_DEVICES': [], 'OUTPUT_DEVICES': []}
data = {'COMMAND' : 'DAEMON_STATE', 'DAEMON_STATE' : [], 'INPUT_DEVICES': [], 'OUTPUT_DEVICES': [],"CPU": str(psutil.cpu_percent()),"RAM": str(psutil.virtual_memory().percent), "VERSION": "0.1-prototype"}
if static.TNCSTARTED:
data["DAEMON_STATE"].append({"STATUS": "running"})