lxb 8 months ago
parent
commit
9f4e8c7db3
  1. 17
      client.py
  2. 2
      server_config.json

17
client.py

@ -20,10 +20,13 @@ def get_gpus_info(error_dict):
gpu_name = gpu_name.replace('NVIDIA ', '').replace('GeForce ', '')
process_list = list()
for process_info in gpu_info['processes']:
cmd = process_info['command']
if 'full_command' in process_info:
cmd = ' '.join(process_info["full_command"])
process_list.append({
"user": process_info['username'],
"memory": process_info['gpu_memory_usage'],
"cmd": ' '.join(process_info["full_command"])
"cmd": cmd
})
# 加到list中
@ -37,7 +40,7 @@ def get_gpus_info(error_dict):
"process_list": process_list
})
except Exception as e:
error_dict['gpu'] = e
error_dict['memory'] = f'{e}'
return result_list
@ -86,7 +89,7 @@ def get_cpu_info(error_dict):
result_dict["core_occupy_list"] = psutil.cpu_percent(interval=None, percpu=True)
except Exception as e:
error_dict['cpu'] = e
error_dict['memory'] = f'{e}'
return result_dict
@ -104,7 +107,7 @@ def get_storages_info(error_dict, path_list):
}
result_list.append(tmp_res)
except Exception as e:
error_dict['storage'] = e
error_dict['memory'] = f'{e}'
return result_list
@ -116,7 +119,7 @@ def get_memory_info(error_dict):
result_dict["total"] = mem.total / 1024
result_dict["used"] = mem.used / 1024
except Exception as e:
error_dict['memory'] = e
error_dict['memory'] = f'{e}'
return result_dict
@ -125,7 +128,7 @@ last_network_stats = None
last_network_time = None
def get_networks_info(error_dict):
result_list = list()
# try:
try:
global last_network_stats
global last_network_time
current_stats = psutil.net_io_counters(pernic=True)
@ -156,6 +159,8 @@ def get_networks_info(error_dict):
# 记录信息下次用
last_network_stats = current_stats
last_network_time = time.time()
except Exception as e:
error_dict['memory'] = f'{e}'
return result_list

2
server_config.json

@ -1,5 +1,5 @@
{
"host": "127.0.0.1",
"host": "0.0.0.0",
"port": 15002,
"server_list":["76", "174", "233", "222"],
"note_dict":{

Loading…
Cancel
Save