You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.2 KiB

import subprocess
import logging
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],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True
)
output = result.stdout
# error = result.stderr
return jsonify({"message": "successfully", "output": output})
except Exception as e:
logging.info(f'执行跑满cpu脚本错误 error: {e}')
return jsonify({"message": "failed", "error": str(e)})
def execute_memory_full_script():
script_path = '/data/ww/py_sys_monitor/control/memory_full.py'
try:
result = subprocess.run(
['python3', script_path],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True
)
output = result.stdout
# error = result.stderr
return jsonify({"message": "successfully", "output": output})
except Exception as e:
logging.info(f'执行跑满memory脚本错误 error: {e}')
return jsonify({"message": "failed", "error": str(e)})