pmonitor 1.5.0__tar.gz → 1.5.2__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.
Files changed (40) hide show
  1. pmonitor-1.5.2/PKG-INFO +21 -0
  2. pmonitor-1.5.2/monitor/DLL/GpuMonitorLib.dll +0 -0
  3. pmonitor-1.5.2/monitor/DLL/LibreHardwareMonitorLib.dll +0 -0
  4. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/monitor_mac_vmmap.py +6 -6
  5. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/monitor_pids.py +8 -35
  6. pmonitor-1.5.2/pmonitor.egg-info/PKG-INFO +21 -0
  7. {pmonitor-1.5.0 → pmonitor-1.5.2}/pmonitor.egg-info/SOURCES.txt +1 -0
  8. {pmonitor-1.5.0 → pmonitor-1.5.2}/pmonitor.egg-info/entry_points.txt +0 -1
  9. {pmonitor-1.5.0 → pmonitor-1.5.2}/setup.py +2 -3
  10. pmonitor-1.5.0/PKG-INFO +0 -11
  11. pmonitor-1.5.0/monitor/DLL/GpuMonitorLib.dll +0 -0
  12. pmonitor-1.5.0/pmonitor.egg-info/PKG-INFO +0 -11
  13. {pmonitor-1.5.0 → pmonitor-1.5.2}/README.md +0 -0
  14. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/DLL/KernelBase.dll +0 -0
  15. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/DLL/__init__.py +0 -0
  16. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/DLL/advapi32.dll +0 -0
  17. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/DLL/bcrypt.dll +0 -0
  18. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/DLL/kernel.appcore.dll +0 -0
  19. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/DLL/kernel32.dll +0 -0
  20. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/DLL/msvcirt.dll +0 -0
  21. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/DLL/msvcp140.dll +0 -0
  22. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/DLL/ntdll.dll +0 -0
  23. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/DLL/pdh.dll +0 -0
  24. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/DLL/rpcrt4.dll +0 -0
  25. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/DLL/sechost.dll +0 -0
  26. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/DLL/ucrtbased.dll +0 -0
  27. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/DLL/vcruntime140.dll +0 -0
  28. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/DLL/vcruntime140_1.dll +0 -0
  29. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/WinPidUtil.py +0 -0
  30. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/__init__.py +0 -0
  31. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/get_process_name.py +0 -0
  32. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/mac_gpu.py +0 -0
  33. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/monitor_mac.py +0 -0
  34. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/monitor_win.py +0 -0
  35. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/run_monitor.py +0 -0
  36. {pmonitor-1.5.0 → pmonitor-1.5.2}/monitor/sys_info.py +0 -0
  37. {pmonitor-1.5.0 → pmonitor-1.5.2}/pmonitor.egg-info/dependency_links.txt +0 -0
  38. {pmonitor-1.5.0 → pmonitor-1.5.2}/pmonitor.egg-info/requires.txt +0 -0
  39. {pmonitor-1.5.0 → pmonitor-1.5.2}/pmonitor.egg-info/top_level.txt +0 -0
  40. {pmonitor-1.5.0 → pmonitor-1.5.2}/setup.cfg +0 -0
@@ -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
@@ -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)
@@ -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
- 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
@@ -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
- vm_memory_data = json.loads(vm.get_current_json())
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(0.1)
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
- # 'memory percent': round(float(minor_mem_percent_sum), 2),
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
- 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
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
@@ -12,6 +12,7 @@ monitor/run_monitor.py
12
12
  monitor/sys_info.py
13
13
  monitor/DLL/GpuMonitorLib.dll
14
14
  monitor/DLL/KernelBase.dll
15
+ monitor/DLL/LibreHardwareMonitorLib.dll
15
16
  monitor/DLL/__init__.py
16
17
  monitor/DLL/advapi32.dll
17
18
  monitor/DLL/bcrypt.dll
@@ -1,3 +1,2 @@
1
1
  [console_scripts]
2
2
  pmonitor = monitor.run_monitor:main
3
-
@@ -1,11 +1,10 @@
1
- from distutils.core import setup
2
- from setuptools import find_packages
1
+ from setuptools import setup, find_packages
3
2
 
4
3
  with open('README.md', 'r') as f:
5
4
  long_description = f.read()
6
5
 
7
6
  setup(name='pmonitor',
8
- version='1.5.0',
7
+ version='1.5.2',
9
8
  description='pc monitor',
10
9
  long_description=long_description,
11
10
  author='cfr',
pmonitor-1.5.0/PKG-INFO DELETED
@@ -1,11 +0,0 @@
1
- Metadata-Version: 1.2
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
- Description: pc application get monitor
10
- Platform: all
11
- Requires-Python: >=3.6
@@ -1,11 +0,0 @@
1
- Metadata-Version: 1.2
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
- Description: pc application get monitor
10
- Platform: all
11
- Requires-Python: >=3.6
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes