|
|
|
@ -5,20 +5,32 @@ from flask import jsonify
|
|
|
|
|
def execute_cpu_full_script():
|
|
|
|
|
script_path = '/data/ww/py_sys_monitor/control/cpu_full.py'
|
|
|
|
|
try:
|
|
|
|
|
result = subprocess.run(['python3', script_path], capture_output=True, text=True, check=True)
|
|
|
|
|
result = subprocess.run(
|
|
|
|
|
['python3', script_path],
|
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
|
stderr=subprocess.PIPE,
|
|
|
|
|
text=True
|
|
|
|
|
)
|
|
|
|
|
output = result.stdout
|
|
|
|
|
# error = result.stderr
|
|
|
|
|
return jsonify({"message": "successfully", "output": output})
|
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
|
logging.info("")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
logging.info("执行跑满cpu脚本错误")
|
|
|
|
|
return jsonify({"message": "failed", "error": str(e.output)})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def execute_memory_full_script():
|
|
|
|
|
script_path = '/data/ww/py_sys_monitor/control/memory_full.py'
|
|
|
|
|
try:
|
|
|
|
|
result = subprocess.run(['python3', script_path], capture_output=True, text=True, check=True)
|
|
|
|
|
result = subprocess.run(
|
|
|
|
|
['python3', script_path],
|
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
|
stderr=subprocess.PIPE,
|
|
|
|
|
text=True
|
|
|
|
|
)
|
|
|
|
|
output = result.stdout
|
|
|
|
|
# error = result.stderr
|
|
|
|
|
return jsonify({"message": "successfully", "output": output})
|
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
|
logging.info("")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
logging.info("执行跑满memory脚本错误")
|
|
|
|
|
return jsonify({"message": "failed", "error": str(e.output)})
|