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.

14 lines
373 B

from flask import Blueprint, jsonify
import psutil
cpu_bp = Blueprint('cpu', __name__)
@cpu_bp.route('/cpu', methods=['GET'])
def get_cpu():
cpu_times = psutil.cpu_times_percent(interval=1, percpu=False)
return jsonify({
'user': cpu_times.user,
'system': cpu_times.system,
'idle': cpu_times.idle,
'iowait': cpu_times.iowait,
})