pmonitor 1.5.1__py3-none-any.whl → 1.5.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.
Binary file
Binary file
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,16 +20,13 @@ class PidsPerf:
22
20
  self.interval = interval
23
21
  self.processUtil = ProcessName()
24
22
 
25
- async def get_mac_perf(self):
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
29
+ minor_vss_mem_sum = 0
35
30
  minor_thread_count_sum = 0
36
31
  gpu_memory_usage = 0
37
32
  gpu_memory_total = 0
@@ -45,50 +40,46 @@ class PidsPerf:
45
40
  mem_available = round(mem_info.available / 1024 / 1024, 2) # 剩余虚拟内存
46
41
 
47
42
  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
43
  for process in pids_process:
57
44
  try:
58
45
  cpu_percent = process.cpu_percent()
46
+ process_memory = process.memory_info()
59
47
  mem_percent = u'%.2f' % (process.memory_percent()) # 内存利用率
60
- vm_memory_data = json.loads(vm.get_current_json())
61
- real_mem = vm_memory_data.get(str(process.pid), 0) # 默认值为 0(如果未找到对应 PID)
48
+ real_mem = round(process_memory.rss / 1024 / 1024, 2) # 实际内存
49
+ vss_mem = round(process_memory.vms / 1024 / 1024, 2) # 虚拟内存
62
50
  thread_count = process.num_threads() # 线程总数
63
51
  except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
64
52
  cpu_percent = 0
65
53
  mem_percent = 0
66
54
  real_mem = 0
67
55
  thread_count = 0
56
+ vss_mem = 0
68
57
 
69
58
  # 将性能数据保存到对应PID的数据列表中
70
59
  if process.pid == current_pid: # 主进程数据处理
71
60
  main_cpu = cpu_percent
72
61
  main_real_mem = real_mem
73
62
  main_mem_percent = round(float(mem_percent), 2)
63
+ main_vss_mem = vss_mem
74
64
  main_thread_count = thread_count
75
65
  main_data = {'cpu': main_cpu, 'memory': main_real_mem, 'memory percent': main_mem_percent,
76
- 'thread count': main_thread_count}
66
+ 'thread count': main_thread_count, 'vss memory': main_vss_mem}
77
67
  # print('主进程', pid_name, main_cpu, main_real_mem, main_mem_percent, main_thread_count)
78
68
  else: # 子进程数据处理
79
69
  minor_cpu_sum += cpu_percent
80
70
  minor_real_mem_sum += real_mem
71
+ minor_vss_mem_sum += vss_mem
81
72
  minor_mem_percent_sum += float(mem_percent)
82
73
  minor_thread_count_sum += thread_count
83
74
  # pid_data[process.pid].append((cpu_percent, real_mem, mem_percent, thread_count))
84
75
  minor_data = {'cpu': round(float(minor_cpu_sum), 2), 'memory': round(float(minor_real_mem_sum), 2),
85
76
  'memory percent': round(float(minor_mem_percent_sum), 2),
86
- 'thread count': minor_thread_count_sum}
77
+ 'thread count': minor_thread_count_sum, 'vss memory': minor_vss_mem_sum}
87
78
  # print('其他子进程', pid_name, minor_cpu_sum, minor_real_mem_sum, minor_mem_percent_sum,
88
79
  # minor_thread_count_sum)
89
80
  # 获取磁盘IO
90
81
  io_read_bytes_start, io_write_bytes_start = self.get_disk_usage()
91
- time.sleep(0.1)
82
+ time.sleep(self.interval)
92
83
  io_read_bytes_end, io_write_bytes_end = self.get_disk_usage() # io read/write
93
84
  io_read_bytes = io_read_bytes_end - io_read_bytes_start # io read/byte
94
85
  io_write_bytes = io_write_bytes_end - io_write_bytes_start # io write/byte
@@ -99,13 +90,6 @@ class PidsPerf:
99
90
  "memory_total": mem_total, "memory_available": mem_available}
100
91
  json_data = json.dumps(data)
101
92
  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
93
  sys.stdout.flush()
110
94
 
111
95
  def get_disk_usage(self):
@@ -141,12 +125,12 @@ class PidsPerf:
141
125
  # 获取GPU物理内存
142
126
  computer = Computer()
143
127
  gpu_key = list(computer.gpu.keys())[0]
144
- next_time = time.time() # 初始化下一次执行的时间点
145
128
  while True:
146
129
  minor_cpu_sum = 0
147
130
  minor_workSet_mem_sum = 0
148
131
  minor_private_mem_sum = 0
149
132
  minor_mem_percent_sum = 0
133
+ minor_vss_mem_sum = 0
150
134
  minor_thread_count_sum = 0
151
135
  minor_io_read_sum = 0
152
136
  minor_io_write_sum = 0
@@ -192,12 +176,14 @@ class PidsPerf:
192
176
  try:
193
177
  process = psutil.Process(pid)
194
178
  pid_name = process.name()
179
+ mem_vss = round(process.memory_info().vms / 1024 / 1024, 2)
195
180
  mem_percent = round(process.memory_percent(), 2)
196
181
  thread_count = process.num_threads()
197
182
  except (psutil.AccessDenied, psutil.NoSuchProcess, psutil.ZombieProcess):
198
183
  # print('pid is not found')
199
184
  mem_percent = 0
200
185
  thread_count = 0
186
+ mem_vss = 0
201
187
  process_cpu_time_post = pidWinPerf.get_process_cpu_time(pid)
202
188
  memory_info = pidWinPerf.get_process_memory(pid)
203
189
  io_counters = pidWinPerf.get_io_counters(pid)
@@ -232,7 +218,9 @@ class PidsPerf:
232
218
  # 'Committed:', main_gpu_committed_sum, 'GPU Usage:',
233
219
  # main_gpu_percent_sum)
234
220
  main_data = {'cpu': cpu_usage, 'private': private_mem, "workset": workSet_mem,
235
- 'thread count': thread_count,
221
+ "vss memory": mem_vss,
222
+ "mem percent": mem_percent,
223
+ "thread count": thread_count,
236
224
  'gpu_Dedicated': round(float(main_gpu_dedicated_sum), 2),
237
225
  'gpu_System': round(float(main_gpu_system_sum), 2),
238
226
  'gpu_Committed': round(float(main_gpu_committed_sum), 2),
@@ -242,6 +230,7 @@ class PidsPerf:
242
230
  # f'主进程数据:cpu:{cpu_usage},workSet:{workSet_mem},private:{private_mem},mem_percent:{mem_percent},thread_count:{thread_count}')
243
231
  else:
244
232
  minor_cpu_sum += cpu_usage # 子进程总
233
+ minor_vss_mem_sum += mem_vss # 子进程vss内存
245
234
  minor_workSet_mem_sum += workSet_mem # 子进程workSet内存
246
235
  minor_private_mem_sum += private_mem # 子进程private内存
247
236
  minor_mem_percent_sum += mem_percent # 子进程内存使用率
@@ -267,7 +256,8 @@ class PidsPerf:
267
256
  disk_data = {'io read': minor_io_read_sum, 'io write': minor_io_write_sum}
268
257
  other_data = {'cpu': minor_cpu_sum, 'private': round(float(minor_private_mem_sum), 2),
269
258
  'workset': round(float(minor_workSet_mem_sum), 2),
270
- # 'memory percent': round(float(minor_mem_percent_sum), 2),
259
+ 'vss memory': minor_vss_mem_sum,
260
+ 'memory percent': round(float(minor_mem_percent_sum), 2),
271
261
  'thread count': minor_thread_count_sum,
272
262
  'gpu_Dedicated': round(minor_gpu_dedicated_sum, 2),
273
263
  'gpu_System': round(minor_gpu_system_sum, 2),
@@ -293,13 +283,9 @@ class PidsPerf:
293
283
  sys.stdout.flush()
294
284
  # 更新系统时间
295
285
  system_time_pre = system_time_post
296
- # 精确控制间隔
297
- next_time += self.interval
298
- sleep_time = next_time - time.time()
299
- if sleep_time > 0:
300
- time.sleep(sleep_time)
301
- else:
302
- next_time = time.time() # 如果超时,重置时间点v
286
+ # 等待以确保大约每秒更新一次
287
+ elapsed = time.time() - start_time
288
+ time.sleep(max(0, self.interval - elapsed))
303
289
 
304
290
  async def start_perf(self):
305
291
  if platform.system() == 'Windows':
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.4
2
+ Name: pmonitor
3
+ Version: 1.5.3
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
@@ -4,12 +4,13 @@ monitor/get_process_name.py,sha256=HxePo2gdrTo2Ukg4DTnYzUMdczVWywCeLCXQ-RRWyu8,3
4
4
  monitor/mac_gpu.py,sha256=kQDPMW04lIYPBbJw772Jh1OQxj-D4JNmdjJlP6BuR4w,2320
5
5
  monitor/monitor_mac.py,sha256=OoptTTXTZQupzBwgGOfKNjyYAKBxDy-wI3l6T7XVE8s,4651
6
6
  monitor/monitor_mac_vmmap.py,sha256=2ZLhig5ymY6XU7bZGnHM9VIK-d5DAqWOFItIfv7KDPE,3819
7
- monitor/monitor_pids.py,sha256=kIy8oHIN-OwSDqWHTEUlCFpqCdsvGWmX9gtU0cb0W40,17228
7
+ monitor/monitor_pids.py,sha256=uiTMxIof2RSFw4-U_S93QD9svjZ3EXFXCgkvrznZ58E,16748
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=xbH4eyDvnv2g6go1fvUt6qQd7qA9n6piP8My4XubLPQ,66560
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.1.dist-info/METADATA,sha256=0rOJ_53nLLmDwB9iy9rttIwYzAtr_rgSHRgE-cyYkYA,291
28
- pmonitor-1.5.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
29
- pmonitor-1.5.1.dist-info/entry_points.txt,sha256=vmlLEANgf2fZar9BeXYiKdF6GMJbVXip-SIZx5yPXDo,55
30
- pmonitor-1.5.1.dist-info/top_level.txt,sha256=tGkQDkVeyKgP5Rr7acpp0df83NBAnI8up0sGwRxuuQ4,8
31
- pmonitor-1.5.1.dist-info/RECORD,,
28
+ pmonitor-1.5.3.dist-info/METADATA,sha256=G56Yi9S-u98Oog0LP9F6z9xwEVqo1ANH_Vnxwx_n2j8,427
29
+ pmonitor-1.5.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
30
+ pmonitor-1.5.3.dist-info/entry_points.txt,sha256=RiT4cQ3f8vsU3HSGbQrMROCHMi7eOFzdh-k0g7TzoFE,54
31
+ pmonitor-1.5.3.dist-info/top_level.txt,sha256=tGkQDkVeyKgP5Rr7acpp0df83NBAnI8up0sGwRxuuQ4,8
32
+ pmonitor-1.5.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,3 +1,2 @@
1
1
  [console_scripts]
2
2
  pmonitor = monitor.run_monitor:main
3
-
@@ -1,16 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: pmonitor
3
- Version: 1.5.1
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
-