3 changed files with 105 additions and 1 deletions
@ -0,0 +1,47 @@ |
|||
import os |
|||
import json |
|||
import time |
|||
import psutil |
|||
|
|||
# region get data |
|||
|
|||
def get_gpus_info(): |
|||
# todo |
|||
pass |
|||
|
|||
def get_cpus_info(): |
|||
# cpu_usage_per_core = psutil.cpu_percent(interval=1, percpu=True) |
|||
# for i, usage in enumerate(cpu_usage_per_core): |
|||
# print(f"CPU核心 {i} 使用率: {usage}%") |
|||
|
|||
# print(psutil.sensors_temperatures()) |
|||
# 获取逻辑核心数(超线程技术下的线程数) |
|||
logical_cores = psutil.cpu_count() |
|||
print(f"Logical cores: {logical_cores}") |
|||
|
|||
# 获取物理核心数(实际的CPU核心数) |
|||
physical_cores = psutil.cpu_count(logical=False) |
|||
print(f"Physical cores: {physical_cores}") |
|||
|
|||
def get_storages_info(): |
|||
# todo |
|||
pass |
|||
|
|||
def get_memory_info(): |
|||
# todo |
|||
pass |
|||
|
|||
def get_networks_info(): |
|||
# todo |
|||
pass |
|||
|
|||
# endregion |
|||
|
|||
def main(): |
|||
get_cpus_info() |
|||
# cpu_usage_per_core = get_cpus_info() |
|||
# for i, usage in enumerate(cpu_usage_per_core): |
|||
# print(f"CPU核心 {i} 使用率: {usage}%") |
|||
|
|||
if __name__ == '__main__': |
|||
main() |
@ -0,0 +1,57 @@ |
|||
{ |
|||
"update_time_stamp": "1673082950", |
|||
"error_dict":{ |
|||
"gpu": "some error", |
|||
"cpu": "some error" |
|||
}, |
|||
"gpu_list":[ |
|||
{ |
|||
"idx": 0, |
|||
"name": "RTX 3090", |
|||
"temperature": 100, |
|||
"used_memory": 1000, |
|||
"total_memory": 10240, |
|||
"utilization": 34, |
|||
"process_list":[ |
|||
{ |
|||
"user": "lxb", |
|||
"memory": 100, |
|||
"cmd": "python run.py" |
|||
} |
|||
] |
|||
} |
|||
], |
|||
"cpu_list":[ |
|||
{ |
|||
"idx": 0, |
|||
"name": "i5 6500", |
|||
"temperature": 50, |
|||
"core_avg_occupy": 31.25, |
|||
"core_occupy_list":[ |
|||
12, |
|||
23, |
|||
0, |
|||
90 |
|||
] |
|||
} |
|||
], |
|||
"storage_list":[ |
|||
{ |
|||
"path": "/media/F", |
|||
"available": 211108624, |
|||
"total": 5813178480 |
|||
} |
|||
], |
|||
"memory":{ |
|||
"total": 1935468, |
|||
"used": 1382196 |
|||
}, |
|||
"network_list":[ |
|||
{ |
|||
"name": "eth0", |
|||
"default": true, |
|||
"in": 67.8, |
|||
"out": 12.3 |
|||
} |
|||
] |
|||
} |
Loading…
Reference in new issue