pmonitor 1.5.0__py3-none-any.whl → 1.5.2__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/DLL/GpuMonitorLib.dll +0 -0
- monitor/DLL/LibreHardwareMonitorLib.dll +0 -0
- monitor/monitor_mac_vmmap.py +6 -6
- monitor/monitor_pids.py +8 -35
- pmonitor-1.5.2.dist-info/METADATA +21 -0
- {pmonitor-1.5.0.dist-info → pmonitor-1.5.2.dist-info}/RECORD +9 -8
- {pmonitor-1.5.0.dist-info → pmonitor-1.5.2.dist-info}/WHEEL +1 -1
- {pmonitor-1.5.0.dist-info → pmonitor-1.5.2.dist-info}/entry_points.txt +0 -1
- pmonitor-1.5.0.dist-info/METADATA +0 -16
- {pmonitor-1.5.0.dist-info → pmonitor-1.5.2.dist-info}/top_level.txt +0 -0
monitor/DLL/GpuMonitorLib.dll
CHANGED
|
Binary file
|
|
Binary file
|
monitor/monitor_mac_vmmap.py
CHANGED
|
@@ -34,21 +34,21 @@ class VmMapMemory:
|
|
|
34
34
|
def _convert_to_mb(self, mem_str):
|
|
35
35
|
"""
|
|
36
36
|
将内存字符串转换为 MB
|
|
37
|
-
支持格式: 123, 123K, 123M, 123G
|
|
37
|
+
支持格式: 123, 123K, 123M, 123G, 12G+, 12G-
|
|
38
38
|
"""
|
|
39
39
|
# 移除逗号(如果存在)
|
|
40
40
|
mem_str = mem_str.replace(',', '')
|
|
41
41
|
|
|
42
42
|
# 检查单位并转换
|
|
43
43
|
if 'G' in mem_str:
|
|
44
|
-
return float(mem_str.replace('G', '')) * 1024
|
|
44
|
+
return float(mem_str.replace('G', '').rstrip('+-')) * 1024
|
|
45
45
|
elif 'M' in mem_str:
|
|
46
|
-
return float(mem_str.replace('M', ''))
|
|
46
|
+
return float(mem_str.replace('M', '').rstrip('+-'))
|
|
47
47
|
elif 'K' in mem_str:
|
|
48
|
-
return float(mem_str.replace('K', '')) / 1024
|
|
48
|
+
return float(mem_str.replace('K', '').rstrip('+-')) / 1024
|
|
49
49
|
else:
|
|
50
50
|
# 假设为字节
|
|
51
|
-
return float(mem_str) / (1024 * 1024)
|
|
51
|
+
return float(mem_str.rstrip('+-')) / (1024 * 1024)
|
|
52
52
|
|
|
53
53
|
def _monitor_memory(self):
|
|
54
54
|
"""线程函数:实时监控内存使用"""
|
|
@@ -73,7 +73,7 @@ class VmMapMemory:
|
|
|
73
73
|
break
|
|
74
74
|
|
|
75
75
|
# 匹配 PID 和内存行 (例如: "12345 123.4M")
|
|
76
|
-
match = re.match(r'^\s*(\d+)\s+([\d,.]+[KMG]?)\s*$', line.strip())
|
|
76
|
+
match = re.match(r'^\s*(\d+)\s+([\d,.]+[KMG][+-]?)\s*$', line.strip())
|
|
77
77
|
if match:
|
|
78
78
|
pid = match.group(1)
|
|
79
79
|
mem_str = match.group(2)
|
monitor/monitor_pids.py
CHANGED
|
@@ -9,8 +9,6 @@ import ctypes
|
|
|
9
9
|
import os
|
|
10
10
|
from PyLibreHardwareMonitor.computer import Computer
|
|
11
11
|
|
|
12
|
-
from monitor.monitor_mac_vmmap import VmMapMemory
|
|
13
|
-
|
|
14
12
|
if platform.system() != 'Windows':
|
|
15
13
|
from monitor.mac_gpu import get_gpu_memory
|
|
16
14
|
|
|
@@ -22,13 +20,9 @@ class PidsPerf:
|
|
|
22
20
|
self.interval = interval
|
|
23
21
|
self.processUtil = ProcessName()
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
def get_mac_perf(self):
|
|
26
24
|
current_pid = self.processUtil.find_main_process_pid(self.process_name)
|
|
27
|
-
vm = VmMapMemory()
|
|
28
|
-
next_time = time.time() # 初始化下一次执行的时间点
|
|
29
|
-
first_iteration = True # 标志变量,用于跳过第一次循环
|
|
30
25
|
while True:
|
|
31
|
-
start_time = time.time() # 记录循环开始时间
|
|
32
26
|
minor_cpu_sum = 0
|
|
33
27
|
minor_real_mem_sum = 0
|
|
34
28
|
minor_mem_percent_sum = 0
|
|
@@ -45,20 +39,12 @@ class PidsPerf:
|
|
|
45
39
|
mem_available = round(mem_info.available / 1024 / 1024, 2) # 剩余虚拟内存
|
|
46
40
|
|
|
47
41
|
gpu_memory_usage, gpu_memory_total, gpu_memory_free = get_gpu_memory()
|
|
48
|
-
# 使用 asyncio.gather 并发获取内存数据
|
|
49
|
-
vm.update_pids(current_pids)
|
|
50
|
-
|
|
51
|
-
if first_iteration:
|
|
52
|
-
first_iteration = False # 第一次循环后将标志置为 False
|
|
53
|
-
await asyncio.sleep(self.interval / 1000) # 等待一段时间以确保数据稳定
|
|
54
|
-
continue # 跳过第一次循环
|
|
55
|
-
|
|
56
42
|
for process in pids_process:
|
|
57
43
|
try:
|
|
58
44
|
cpu_percent = process.cpu_percent()
|
|
45
|
+
process_memory = process.memory_info()
|
|
59
46
|
mem_percent = u'%.2f' % (process.memory_percent()) # 内存利用率
|
|
60
|
-
|
|
61
|
-
real_mem = vm_memory_data.get(str(process.pid), 0) # 默认值为 0(如果未找到对应 PID)
|
|
47
|
+
real_mem = round(process_memory.rss / 1024 / 1024, 2) # 实际内存
|
|
62
48
|
thread_count = process.num_threads() # 线程总数
|
|
63
49
|
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
|
|
64
50
|
cpu_percent = 0
|
|
@@ -88,7 +74,7 @@ class PidsPerf:
|
|
|
88
74
|
# minor_thread_count_sum)
|
|
89
75
|
# 获取磁盘IO
|
|
90
76
|
io_read_bytes_start, io_write_bytes_start = self.get_disk_usage()
|
|
91
|
-
time.sleep(
|
|
77
|
+
time.sleep(self.interval)
|
|
92
78
|
io_read_bytes_end, io_write_bytes_end = self.get_disk_usage() # io read/write
|
|
93
79
|
io_read_bytes = io_read_bytes_end - io_read_bytes_start # io read/byte
|
|
94
80
|
io_write_bytes = io_write_bytes_end - io_write_bytes_start # io write/byte
|
|
@@ -99,13 +85,6 @@ class PidsPerf:
|
|
|
99
85
|
"memory_total": mem_total, "memory_available": mem_available}
|
|
100
86
|
json_data = json.dumps(data)
|
|
101
87
|
print(json_data)
|
|
102
|
-
# 精确控制间隔
|
|
103
|
-
next_time += self.interval
|
|
104
|
-
sleep_time = next_time - time.time()
|
|
105
|
-
if sleep_time > 0:
|
|
106
|
-
await asyncio.sleep(sleep_time)
|
|
107
|
-
else:
|
|
108
|
-
next_time = time.time() # 如果超时,重置时间点
|
|
109
88
|
sys.stdout.flush()
|
|
110
89
|
|
|
111
90
|
def get_disk_usage(self):
|
|
@@ -141,7 +120,6 @@ class PidsPerf:
|
|
|
141
120
|
# 获取GPU物理内存
|
|
142
121
|
computer = Computer()
|
|
143
122
|
gpu_key = list(computer.gpu.keys())[0]
|
|
144
|
-
next_time = time.time() # 初始化下一次执行的时间点
|
|
145
123
|
while True:
|
|
146
124
|
minor_cpu_sum = 0
|
|
147
125
|
minor_workSet_mem_sum = 0
|
|
@@ -232,7 +210,6 @@ class PidsPerf:
|
|
|
232
210
|
# 'Committed:', main_gpu_committed_sum, 'GPU Usage:',
|
|
233
211
|
# main_gpu_percent_sum)
|
|
234
212
|
main_data = {'cpu': cpu_usage, 'private': private_mem, "workset": workSet_mem,
|
|
235
|
-
'thread count': thread_count,
|
|
236
213
|
'gpu_Dedicated': round(float(main_gpu_dedicated_sum), 2),
|
|
237
214
|
'gpu_System': round(float(main_gpu_system_sum), 2),
|
|
238
215
|
'gpu_Committed': round(float(main_gpu_committed_sum), 2),
|
|
@@ -267,7 +244,7 @@ class PidsPerf:
|
|
|
267
244
|
disk_data = {'io read': minor_io_read_sum, 'io write': minor_io_write_sum}
|
|
268
245
|
other_data = {'cpu': minor_cpu_sum, 'private': round(float(minor_private_mem_sum), 2),
|
|
269
246
|
'workset': round(float(minor_workSet_mem_sum), 2),
|
|
270
|
-
|
|
247
|
+
'memory percent': round(float(minor_mem_percent_sum), 2),
|
|
271
248
|
'thread count': minor_thread_count_sum,
|
|
272
249
|
'gpu_Dedicated': round(minor_gpu_dedicated_sum, 2),
|
|
273
250
|
'gpu_System': round(minor_gpu_system_sum, 2),
|
|
@@ -293,13 +270,9 @@ class PidsPerf:
|
|
|
293
270
|
sys.stdout.flush()
|
|
294
271
|
# 更新系统时间
|
|
295
272
|
system_time_pre = system_time_post
|
|
296
|
-
#
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
if sleep_time > 0:
|
|
300
|
-
time.sleep(sleep_time)
|
|
301
|
-
else:
|
|
302
|
-
next_time = time.time() # 如果超时,重置时间点v
|
|
273
|
+
# 等待以确保大约每秒更新一次
|
|
274
|
+
elapsed = time.time() - start_time
|
|
275
|
+
time.sleep(max(0, self.interval - elapsed))
|
|
303
276
|
|
|
304
277
|
async def start_perf(self):
|
|
305
278
|
if platform.system() == 'Windows':
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pmonitor
|
|
3
|
+
Version: 1.5.2
|
|
4
|
+
Summary: pc monitor
|
|
5
|
+
Author: cfr
|
|
6
|
+
Author-email: 1354592998@qq.com
|
|
7
|
+
License: MIT
|
|
8
|
+
Platform: all
|
|
9
|
+
Requires-Python: >=3.6
|
|
10
|
+
Requires-Dist: PyLibreHardwareMonitor>=1.2.2
|
|
11
|
+
Requires-Dist: psutil>=5.9.8
|
|
12
|
+
Dynamic: author
|
|
13
|
+
Dynamic: author-email
|
|
14
|
+
Dynamic: description
|
|
15
|
+
Dynamic: license
|
|
16
|
+
Dynamic: platform
|
|
17
|
+
Dynamic: requires-dist
|
|
18
|
+
Dynamic: requires-python
|
|
19
|
+
Dynamic: summary
|
|
20
|
+
|
|
21
|
+
pc application get monitor
|
|
@@ -3,13 +3,14 @@ monitor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
3
3
|
monitor/get_process_name.py,sha256=HxePo2gdrTo2Ukg4DTnYzUMdczVWywCeLCXQ-RRWyu8,3913
|
|
4
4
|
monitor/mac_gpu.py,sha256=kQDPMW04lIYPBbJw772Jh1OQxj-D4JNmdjJlP6BuR4w,2320
|
|
5
5
|
monitor/monitor_mac.py,sha256=OoptTTXTZQupzBwgGOfKNjyYAKBxDy-wI3l6T7XVE8s,4651
|
|
6
|
-
monitor/monitor_mac_vmmap.py,sha256=
|
|
7
|
-
monitor/monitor_pids.py,sha256=
|
|
6
|
+
monitor/monitor_mac_vmmap.py,sha256=2ZLhig5ymY6XU7bZGnHM9VIK-d5DAqWOFItIfv7KDPE,3819
|
|
7
|
+
monitor/monitor_pids.py,sha256=DftMSexy87lHIiSJoVJDxNQLXcfHpZg4jNwsJRc4hjw,15968
|
|
8
8
|
monitor/monitor_win.py,sha256=xs5nzqqEPoDmJTegh3lQhVjjpPcOWnruWKK65ttqnTo,6161
|
|
9
9
|
monitor/run_monitor.py,sha256=HDQXHIx47ZRN4Gp0PTr0yWKVM28n8A7-NaO--_pdgso,1577
|
|
10
10
|
monitor/sys_info.py,sha256=aNultuRoQuRYPkYo397xAXVDXP07Qx5JOHtYzNmEvuc,3208
|
|
11
|
-
monitor/DLL/GpuMonitorLib.dll,sha256=
|
|
11
|
+
monitor/DLL/GpuMonitorLib.dll,sha256=k9mDKscV2DioEb_00r1occVj7Y6lwYGKfPq4Gl7MsOE,69632
|
|
12
12
|
monitor/DLL/KernelBase.dll,sha256=MSJ2WSh-2Lk6yFVLX_a8G2EnNuaOtJGpfg-Vw9HY_go,3860744
|
|
13
|
+
monitor/DLL/LibreHardwareMonitorLib.dll,sha256=XSzcprSY4xSH3i5DhngO6mYtVmC3GJvu9-0X9UKwPbU,790528
|
|
13
14
|
monitor/DLL/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
15
|
monitor/DLL/advapi32.dll,sha256=vJ0GuBFvanFrmj45Sp4N3W80qGdmJYy0VBdleZPSA2A,737040
|
|
15
16
|
monitor/DLL/bcrypt.dll,sha256=MIiXQo4a8vPhAAGSfYgUErxMBU6hmb38iwg9vc-CXlA,175000
|
|
@@ -24,8 +25,8 @@ monitor/DLL/sechost.dll,sha256=1mXCrgNDRBiZ2XZk7eTpDm4oPG-x9BW4uYUVkrfvBkk,69986
|
|
|
24
25
|
monitor/DLL/ucrtbased.dll,sha256=vtmKFPEHyr2OXkrUOu3Qs1dlbKG1dxZ8ItKCkTTU5S4,2238056
|
|
25
26
|
monitor/DLL/vcruntime140.dll,sha256=AsaqDm5iRBGp8ZsDYKeGWrFZCOJgJFEOXDipwINiw1o,119888
|
|
26
27
|
monitor/DLL/vcruntime140_1.dll,sha256=fdmqAuJxxoym1fGNZR0joV1yWXFa9DMmV4993ifzdjc,49640
|
|
27
|
-
pmonitor-1.5.
|
|
28
|
-
pmonitor-1.5.
|
|
29
|
-
pmonitor-1.5.
|
|
30
|
-
pmonitor-1.5.
|
|
31
|
-
pmonitor-1.5.
|
|
28
|
+
pmonitor-1.5.2.dist-info/METADATA,sha256=ppCC12Qt8JYHdv7t6_j_UB7LsOlPnsP9ekkzrY1N0xM,427
|
|
29
|
+
pmonitor-1.5.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
30
|
+
pmonitor-1.5.2.dist-info/entry_points.txt,sha256=RiT4cQ3f8vsU3HSGbQrMROCHMi7eOFzdh-k0g7TzoFE,54
|
|
31
|
+
pmonitor-1.5.2.dist-info/top_level.txt,sha256=tGkQDkVeyKgP5Rr7acpp0df83NBAnI8up0sGwRxuuQ4,8
|
|
32
|
+
pmonitor-1.5.2.dist-info/RECORD,,
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: pmonitor
|
|
3
|
-
Version: 1.5.0
|
|
4
|
-
Summary: pc monitor
|
|
5
|
-
Home-page: UNKNOWN
|
|
6
|
-
Author: cfr
|
|
7
|
-
Author-email: 1354592998@qq.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Platform: all
|
|
10
|
-
Requires-Python: >=3.6
|
|
11
|
-
Requires-Dist: PyLibreHardwareMonitor >=1.2.2
|
|
12
|
-
Requires-Dist: psutil >=5.9.8
|
|
13
|
-
|
|
14
|
-
pc application get monitor
|
|
15
|
-
|
|
16
|
-
|
|
File without changes
|