pmonitor 1.4.1__tar.gz → 1.4.3__tar.gz
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.
- {pmonitor-1.4.1 → pmonitor-1.4.3}/PKG-INFO +1 -1
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/mac_gpu.py +16 -11
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/monitor_pids.py +29 -13
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/run_monitor.py +1 -1
- {pmonitor-1.4.1 → pmonitor-1.4.3}/pmonitor.egg-info/PKG-INFO +1 -1
- {pmonitor-1.4.1 → pmonitor-1.4.3}/setup.py +1 -1
- {pmonitor-1.4.1 → pmonitor-1.4.3}/README.md +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/DLL/GpuMonitorLib.dll +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/DLL/KernelBase.dll +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/DLL/__init__.py +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/DLL/advapi32.dll +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/DLL/bcrypt.dll +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/DLL/kernel.appcore.dll +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/DLL/kernel32.dll +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/DLL/msvcirt.dll +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/DLL/msvcp140.dll +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/DLL/ntdll.dll +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/DLL/pdh.dll +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/DLL/rpcrt4.dll +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/DLL/sechost.dll +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/DLL/ucrtbased.dll +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/DLL/vcruntime140.dll +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/DLL/vcruntime140_1.dll +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/WinPidUtil.py +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/__init__.py +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/exec/GpuMonitor +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/exec/__init__.py +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/get_process_name.py +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/monitor_mac.py +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/monitor_win.py +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/monitor/sys_info.py +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/pmonitor.egg-info/SOURCES.txt +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/pmonitor.egg-info/dependency_links.txt +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/pmonitor.egg-info/entry_points.txt +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/pmonitor.egg-info/top_level.txt +0 -0
- {pmonitor-1.4.1 → pmonitor-1.4.3}/setup.cfg +0 -0
|
@@ -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)
|
|
@@ -7,10 +7,9 @@ import asyncio
|
|
|
7
7
|
import platform
|
|
8
8
|
import ctypes
|
|
9
9
|
import os
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import
|
|
13
|
-
from monitor.mac_gpu import get_gpu_memory
|
|
10
|
+
|
|
11
|
+
if platform.system() != 'Windows':
|
|
12
|
+
from monitor.mac_gpu import get_gpu_memory
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
class PidsPerf:
|
|
@@ -27,15 +26,18 @@ class PidsPerf:
|
|
|
27
26
|
minor_real_mem_sum = 0
|
|
28
27
|
minor_mem_percent_sum = 0
|
|
29
28
|
minor_thread_count_sum = 0
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
gpu_memory_percent_1 = 0
|
|
29
|
+
gpu_memory_usage = 0
|
|
30
|
+
gpu_memory_total = 0
|
|
31
|
+
gpu_memory_free = 0
|
|
34
32
|
current_pids = self.processUtil.get_children_pids(current_pid) # 获取所有子进程
|
|
35
33
|
current_pids.add(current_pid) # 将主进程及子进程添加到list中
|
|
36
34
|
pids_process = self.processUtil.get_pids_process(current_pids) # 获取所有进程
|
|
37
35
|
|
|
38
|
-
|
|
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()
|
|
39
41
|
for process in pids_process:
|
|
40
42
|
try:
|
|
41
43
|
cpu_percent = process.cpu_percent()
|
|
@@ -76,9 +78,10 @@ class PidsPerf:
|
|
|
76
78
|
io_read_bytes = io_read_bytes_end - io_read_bytes_start # io read/byte
|
|
77
79
|
io_write_bytes = io_write_bytes_end - io_write_bytes_start # io write/byte
|
|
78
80
|
disk_data = {'io read': io_read_bytes, 'io write': io_write_bytes}
|
|
79
|
-
gpu_data = {'gpu
|
|
80
|
-
'gpu
|
|
81
|
-
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}
|
|
82
85
|
json_data = json.dumps(data)
|
|
83
86
|
print(json_data)
|
|
84
87
|
sys.stdout.flush()
|
|
@@ -100,6 +103,7 @@ class PidsPerf:
|
|
|
100
103
|
def get_win_perf(self):
|
|
101
104
|
from monitor.WinPidUtil import PidWinPerformance, FILETIME
|
|
102
105
|
from ctypes import CDLL, c_int, c_char_p, byref
|
|
106
|
+
from PyLibreHardwareMonitor.computer import Computer
|
|
103
107
|
pidWinPerf = PidWinPerformance()
|
|
104
108
|
system_time_pre = pidWinPerf.filetime_to_100nano_seconds(FILETIME())
|
|
105
109
|
p_pid = self.processUtil.find_main_process_pid(self.process_name)
|
|
@@ -113,6 +117,9 @@ class PidsPerf:
|
|
|
113
117
|
gpu_monitor_dll = ctypes.CDLL(dll_path)
|
|
114
118
|
gpu_monitor_dll.GetGPUDataForProcess.argtypes = [ctypes.c_ulong]
|
|
115
119
|
gpu_monitor_dll.GetGPUDataForProcess.restype = ctypes.c_char_p
|
|
120
|
+
# 获取GPU物理内存
|
|
121
|
+
computer = Computer()
|
|
122
|
+
gpu_key = list(computer.gpu.keys())[0]
|
|
116
123
|
while True:
|
|
117
124
|
minor_cpu_sum = 0
|
|
118
125
|
minor_workSet_mem_sum = 0
|
|
@@ -144,6 +151,7 @@ class PidsPerf:
|
|
|
144
151
|
child_pids.add(p_pid) # app内所有pid
|
|
145
152
|
child_pids = {pid for pid in child_pids if psutil.pid_exists(pid)} # 移除不存在的进程
|
|
146
153
|
|
|
154
|
+
small_data = computer.gpu[gpu_key]['SmallData'] # 获取GPU物理内存信息
|
|
147
155
|
try:
|
|
148
156
|
new_pids_cpu_time_pre = {pid: pidWinPerf.get_process_cpu_time(pid) for pid in child_pids if
|
|
149
157
|
pid not in process_cpu_times_pre}
|
|
@@ -155,6 +163,8 @@ class PidsPerf:
|
|
|
155
163
|
|
|
156
164
|
# print('----------------------------------------------------------')
|
|
157
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)
|
|
158
168
|
|
|
159
169
|
for pid in child_pids:
|
|
160
170
|
try:
|
|
@@ -240,8 +250,14 @@ class PidsPerf:
|
|
|
240
250
|
'gpu_System': round(minor_gpu_system_sum, 2),
|
|
241
251
|
'gpu_Committed': round(minor_gpu_committed_sum, 2),
|
|
242
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']}
|
|
243
256
|
try:
|
|
244
|
-
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}
|
|
245
261
|
json_data = json.dumps(data)
|
|
246
262
|
print(json_data)
|
|
247
263
|
except UnboundLocalError:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|