pmonitor 1.4.2__py3-none-any.whl → 1.4.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- monitor/mac_gpu.py +16 -11
- monitor/monitor_pids.py +27 -12
- monitor/run_monitor.py +1 -1
- {pmonitor-1.4.2.dist-info → pmonitor-1.4.3.dist-info}/METADATA +1 -1
- {pmonitor-1.4.2.dist-info → pmonitor-1.4.3.dist-info}/RECORD +8 -8
- {pmonitor-1.4.2.dist-info → pmonitor-1.4.3.dist-info}/WHEEL +0 -0
- {pmonitor-1.4.2.dist-info → pmonitor-1.4.3.dist-info}/entry_points.txt +0 -0
- {pmonitor-1.4.2.dist-info → pmonitor-1.4.3.dist-info}/top_level.txt +0 -0
monitor/mac_gpu.py
CHANGED
|
@@ -36,21 +36,26 @@ if platform.system() != 'Windows':
|
|
|
36
36
|
try:
|
|
37
37
|
gpu_info = accelerator_performance_statistics()
|
|
38
38
|
use_gpu_memory = 0
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
total_gpu_memory = 0
|
|
40
|
+
free_gpu_memory = 0
|
|
41
41
|
for key, value in gpu_info["PerformanceStatistics"].items():
|
|
42
|
-
if key == "In use system memory":
|
|
43
|
-
use_gpu_memory = int(value)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
elif key == "
|
|
49
|
-
|
|
42
|
+
if key == "In use system memory" or key == "gartUsedBytes":
|
|
43
|
+
use_gpu_memory = int(value)
|
|
44
|
+
elif key == "gartSizeBytes":
|
|
45
|
+
total_gpu_memory = int(value)
|
|
46
|
+
elif key == "gartFreeBytes":
|
|
47
|
+
free_gpu_memory = int(value)
|
|
48
|
+
elif key == "Alloc system memory":
|
|
49
|
+
total_gpu_memory = int(value)
|
|
50
50
|
# print('device usage', device_usage)
|
|
51
51
|
# use_gpu_memory = gpu_info["PerformanceStatistics"]["In use system memory"]
|
|
52
52
|
# total_gpu_memory = gpu_info["PerformanceStatistics"]["Alloc system memory"]
|
|
53
53
|
except Exception as e:
|
|
54
54
|
print(f"Mac端在arm64平台通过接口获取Gpu Memory失败:{e}")
|
|
55
55
|
use_gpu_memory = 0
|
|
56
|
-
|
|
56
|
+
total_gpu_memory = 0
|
|
57
|
+
free_gpu_memory = 0
|
|
58
|
+
if free_gpu_memory == 0:
|
|
59
|
+
free_gpu_memory = total_gpu_memory - use_gpu_memory
|
|
60
|
+
return round(use_gpu_memory / 1024 / 1024, 2), round(total_gpu_memory / 1024 / 1024, 2), round(
|
|
61
|
+
free_gpu_memory / 1024 / 1024, 2)
|
monitor/monitor_pids.py
CHANGED
|
@@ -7,9 +7,7 @@ import asyncio
|
|
|
7
7
|
import platform
|
|
8
8
|
import ctypes
|
|
9
9
|
import os
|
|
10
|
-
|
|
11
|
-
import subprocess
|
|
12
|
-
import re
|
|
10
|
+
|
|
13
11
|
if platform.system() != 'Windows':
|
|
14
12
|
from monitor.mac_gpu import get_gpu_memory
|
|
15
13
|
|
|
@@ -28,15 +26,18 @@ class PidsPerf:
|
|
|
28
26
|
minor_real_mem_sum = 0
|
|
29
27
|
minor_mem_percent_sum = 0
|
|
30
28
|
minor_thread_count_sum = 0
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
gpu_memory_percent_1 = 0
|
|
29
|
+
gpu_memory_usage = 0
|
|
30
|
+
gpu_memory_total = 0
|
|
31
|
+
gpu_memory_free = 0
|
|
35
32
|
current_pids = self.processUtil.get_children_pids(current_pid) # 获取所有子进程
|
|
36
33
|
current_pids.add(current_pid) # 将主进程及子进程添加到list中
|
|
37
34
|
pids_process = self.processUtil.get_pids_process(current_pids) # 获取所有进程
|
|
38
35
|
|
|
39
|
-
|
|
36
|
+
mem_info = psutil.virtual_memory()
|
|
37
|
+
mem_total = round(mem_info.total / 1024 / 1024, 2) # 总虚拟内存
|
|
38
|
+
mem_available = round(mem_info.available / 1024 / 1024, 2) # 剩余虚拟内存
|
|
39
|
+
|
|
40
|
+
gpu_memory_usage, gpu_memory_total, gpu_memory_free = get_gpu_memory()
|
|
40
41
|
for process in pids_process:
|
|
41
42
|
try:
|
|
42
43
|
cpu_percent = process.cpu_percent()
|
|
@@ -77,9 +78,10 @@ class PidsPerf:
|
|
|
77
78
|
io_read_bytes = io_read_bytes_end - io_read_bytes_start # io read/byte
|
|
78
79
|
io_write_bytes = io_write_bytes_end - io_write_bytes_start # io write/byte
|
|
79
80
|
disk_data = {'io read': io_read_bytes, 'io write': io_write_bytes}
|
|
80
|
-
gpu_data = {'gpu
|
|
81
|
-
'gpu
|
|
82
|
-
data = {'main': main_data, 'other': minor_data, 'disk': disk_data, "gpu": gpu_data
|
|
81
|
+
gpu_data = {'gpu memory usage': gpu_memory_usage, 'gpu memory total': gpu_memory_total,
|
|
82
|
+
'gpu memory free': gpu_memory_free}
|
|
83
|
+
data = {'main': main_data, 'other': minor_data, 'disk': disk_data, "gpu": gpu_data,
|
|
84
|
+
"memory_total": mem_total, "memory_available": mem_available}
|
|
83
85
|
json_data = json.dumps(data)
|
|
84
86
|
print(json_data)
|
|
85
87
|
sys.stdout.flush()
|
|
@@ -101,6 +103,7 @@ class PidsPerf:
|
|
|
101
103
|
def get_win_perf(self):
|
|
102
104
|
from monitor.WinPidUtil import PidWinPerformance, FILETIME
|
|
103
105
|
from ctypes import CDLL, c_int, c_char_p, byref
|
|
106
|
+
from PyLibreHardwareMonitor.computer import Computer
|
|
104
107
|
pidWinPerf = PidWinPerformance()
|
|
105
108
|
system_time_pre = pidWinPerf.filetime_to_100nano_seconds(FILETIME())
|
|
106
109
|
p_pid = self.processUtil.find_main_process_pid(self.process_name)
|
|
@@ -114,6 +117,9 @@ class PidsPerf:
|
|
|
114
117
|
gpu_monitor_dll = ctypes.CDLL(dll_path)
|
|
115
118
|
gpu_monitor_dll.GetGPUDataForProcess.argtypes = [ctypes.c_ulong]
|
|
116
119
|
gpu_monitor_dll.GetGPUDataForProcess.restype = ctypes.c_char_p
|
|
120
|
+
# 获取GPU物理内存
|
|
121
|
+
computer = Computer()
|
|
122
|
+
gpu_key = list(computer.gpu.keys())[0]
|
|
117
123
|
while True:
|
|
118
124
|
minor_cpu_sum = 0
|
|
119
125
|
minor_workSet_mem_sum = 0
|
|
@@ -145,6 +151,7 @@ class PidsPerf:
|
|
|
145
151
|
child_pids.add(p_pid) # app内所有pid
|
|
146
152
|
child_pids = {pid for pid in child_pids if psutil.pid_exists(pid)} # 移除不存在的进程
|
|
147
153
|
|
|
154
|
+
small_data = computer.gpu[gpu_key]['SmallData'] # 获取GPU物理内存信息
|
|
148
155
|
try:
|
|
149
156
|
new_pids_cpu_time_pre = {pid: pidWinPerf.get_process_cpu_time(pid) for pid in child_pids if
|
|
150
157
|
pid not in process_cpu_times_pre}
|
|
@@ -156,6 +163,8 @@ class PidsPerf:
|
|
|
156
163
|
|
|
157
164
|
# print('----------------------------------------------------------')
|
|
158
165
|
# print('pid', child_pids)
|
|
166
|
+
memory_total = round(psutil.virtual_memory().total / 1024 / 1024, 2)
|
|
167
|
+
memory_available = round(psutil.virtual_memory().available / 1024 / 1024, 2)
|
|
159
168
|
|
|
160
169
|
for pid in child_pids:
|
|
161
170
|
try:
|
|
@@ -241,8 +250,14 @@ class PidsPerf:
|
|
|
241
250
|
'gpu_System': round(minor_gpu_system_sum, 2),
|
|
242
251
|
'gpu_Committed': round(minor_gpu_committed_sum, 2),
|
|
243
252
|
'gpu_Usage': round(minor_gpu_percent_sum, 2)}
|
|
253
|
+
gpu_data = {'gpu memory usage': small_data['GPU Memory Used'],
|
|
254
|
+
'gpu memory total': small_data['GPU Memory Total'],
|
|
255
|
+
'gpu memory free': small_data['GPU Memory Free']}
|
|
244
256
|
try:
|
|
245
|
-
data = {'main': main_data, 'other': other_data, 'disk': disk_data
|
|
257
|
+
data = {'main': main_data, 'other': other_data, 'disk': disk_data,
|
|
258
|
+
'gpu': gpu_data,
|
|
259
|
+
'memory_total': memory_total,
|
|
260
|
+
'memory_available': memory_available}
|
|
246
261
|
json_data = json.dumps(data)
|
|
247
262
|
print(json_data)
|
|
248
263
|
except UnboundLocalError:
|
monitor/run_monitor.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
monitor/WinPidUtil.py,sha256=0vu2cqcQRrBTb5t_9HOmUoOfbe9KRrI-cyDlJX9bcrw,8753
|
|
2
2
|
monitor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
monitor/get_process_name.py,sha256=HxePo2gdrTo2Ukg4DTnYzUMdczVWywCeLCXQ-RRWyu8,3913
|
|
4
|
-
monitor/mac_gpu.py,sha256=
|
|
4
|
+
monitor/mac_gpu.py,sha256=kQDPMW04lIYPBbJw772Jh1OQxj-D4JNmdjJlP6BuR4w,2320
|
|
5
5
|
monitor/monitor_mac.py,sha256=OoptTTXTZQupzBwgGOfKNjyYAKBxDy-wI3l6T7XVE8s,4651
|
|
6
|
-
monitor/monitor_pids.py,sha256=
|
|
6
|
+
monitor/monitor_pids.py,sha256=yvUOIuwMw5stDxOVSY2vu72CzxZzmL6qCYsF9vw3VY8,15580
|
|
7
7
|
monitor/monitor_win.py,sha256=xs5nzqqEPoDmJTegh3lQhVjjpPcOWnruWKK65ttqnTo,6161
|
|
8
|
-
monitor/run_monitor.py,sha256=
|
|
8
|
+
monitor/run_monitor.py,sha256=s9JSFu5olh3VhrEqj_CZ5l25nvBtd2cN0NhU9R2KOKM,1581
|
|
9
9
|
monitor/sys_info.py,sha256=aNultuRoQuRYPkYo397xAXVDXP07Qx5JOHtYzNmEvuc,3208
|
|
10
10
|
monitor/DLL/GpuMonitorLib.dll,sha256=xbH4eyDvnv2g6go1fvUt6qQd7qA9n6piP8My4XubLPQ,66560
|
|
11
11
|
monitor/DLL/KernelBase.dll,sha256=MSJ2WSh-2Lk6yFVLX_a8G2EnNuaOtJGpfg-Vw9HY_go,3860744
|
|
@@ -24,8 +24,8 @@ monitor/DLL/ucrtbased.dll,sha256=vtmKFPEHyr2OXkrUOu3Qs1dlbKG1dxZ8ItKCkTTU5S4,223
|
|
|
24
24
|
monitor/DLL/vcruntime140.dll,sha256=AsaqDm5iRBGp8ZsDYKeGWrFZCOJgJFEOXDipwINiw1o,119888
|
|
25
25
|
monitor/DLL/vcruntime140_1.dll,sha256=fdmqAuJxxoym1fGNZR0joV1yWXFa9DMmV4993ifzdjc,49640
|
|
26
26
|
monitor/exec/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
-
pmonitor-1.4.
|
|
28
|
-
pmonitor-1.4.
|
|
29
|
-
pmonitor-1.4.
|
|
30
|
-
pmonitor-1.4.
|
|
31
|
-
pmonitor-1.4.
|
|
27
|
+
pmonitor-1.4.3.dist-info/METADATA,sha256=fqc-_49ex8Sv1XfkptmGPMP67m5BT0pt28YhTSV-fJI,215
|
|
28
|
+
pmonitor-1.4.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
29
|
+
pmonitor-1.4.3.dist-info/entry_points.txt,sha256=vmlLEANgf2fZar9BeXYiKdF6GMJbVXip-SIZx5yPXDo,55
|
|
30
|
+
pmonitor-1.4.3.dist-info/top_level.txt,sha256=tGkQDkVeyKgP5Rr7acpp0df83NBAnI8up0sGwRxuuQ4,8
|
|
31
|
+
pmonitor-1.4.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|