pmonitor 1.1.9__py3-none-any.whl → 1.2.0__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
File without changes
monitor/monitor_pids.py CHANGED
@@ -7,6 +7,9 @@ import asyncio
7
7
  import platform
8
8
  import ctypes
9
9
  import os
10
+ import stat
11
+ import subprocess
12
+ import re
10
13
 
11
14
 
12
15
  class PidsPerf:
@@ -18,14 +21,40 @@ class PidsPerf:
18
21
 
19
22
  def get_mac_perf(self):
20
23
  current_pid = self.processUtil.find_main_process_pid(self.process_name)
24
+ dll_path = os.path.join(os.path.dirname(__file__), 'exec', 'GpuMonitor')
25
+ if os.path.exists(dll_path):
26
+ if not os.access(dll_path, os.X_OK):
27
+ try:
28
+ current_permissions = os.stat(dll_path).st_mode
29
+ os.chmod(dll_path, current_permissions | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)
30
+ except Exception as e:
31
+ raise e
21
32
  while True:
22
33
  minor_cpu_sum = 0
23
34
  minor_real_mem_sum = 0
24
35
  minor_mem_percent_sum = 0
25
36
  minor_thread_count_sum = 0
37
+ gpu_memory_usage_0 = 0
38
+ gpu_memory_percent_0 = 0
39
+ gpu_memory_usage_1 = 0
40
+ gpu_memory_percent_1 = 0
26
41
  current_pids = self.processUtil.get_children_pids(current_pid) # 获取所有子进程
27
42
  current_pids.add(current_pid) # 将主进程及子进程添加到list中
28
43
  pids_process = self.processUtil.get_pids_process(current_pids) # 获取所有进程
44
+
45
+ result = subprocess.run([self.gpu_tool], stdout=subprocess.PIPE, text=True)
46
+ for line in result.stdout.split('\n'):
47
+ pattern = r"GPU Name:(.*?),Device Percent:(.*?),Dedicated Usage:(\d+)"
48
+ matches = re.findall(pattern, line)
49
+ for match in matches:
50
+ gpu_name, device_percent, dedicated_usage = match
51
+ if 'driver' in gpu_name or 'Apple' in gpu_name:
52
+ gpu_memory_usage_0 = round(float(dedicated_usage) / 1024 / 1024, 2)
53
+ gpu_memory_percent_0 = round(float(device_percent), 2)
54
+ else:
55
+ gpu_memory_usage_1 = round(float(dedicated_usage) / 1024 / 1024, 2)
56
+ gpu_memory_percent_1 = round(float(device_percent), 2)
57
+
29
58
  for process in pids_process:
30
59
  try:
31
60
  cpu_percent = process.cpu_percent()
@@ -66,7 +95,9 @@ class PidsPerf:
66
95
  io_read_bytes = io_read_bytes_end - io_read_bytes_start # io read/byte
67
96
  io_write_bytes = io_write_bytes_end - io_write_bytes_start # io write/byte
68
97
  disk_data = {'io read': io_read_bytes, 'io write': io_write_bytes}
69
- data = {'main': main_data, 'other': minor_data, 'disk': disk_data}
98
+ gpu_data = {'gpu 0 memory usage': gpu_memory_usage_0, 'gpu 0 device Utilization': gpu_memory_percent_0,
99
+ 'gpu 1 memory usage': gpu_memory_usage_1, 'gpu 1 device Utilization': gpu_memory_percent_1}
100
+ data = {'main': main_data, 'other': minor_data, 'disk': disk_data, "gpu": gpu_data}
70
101
  json_data = json.dumps(data)
71
102
  print(json_data)
72
103
  sys.stdout.flush()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pmonitor
3
- Version: 1.1.9
3
+ Version: 1.2.0
4
4
  Summary: pc monitor
5
5
  Home-page: UNKNOWN
6
6
  Author: cfr
@@ -2,7 +2,7 @@ monitor/WinPidUtil.py,sha256=NGkit8UoDAW7dz1vrwsb50QFroO-0hZ44fd_fykJ3WM,8523
2
2
  monitor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  monitor/get_process_name.py,sha256=eUElEd6chW-gw416o3VZg3UZPi8ZCG9rcw8ayrpVcz4,3620
4
4
  monitor/monitor_mac.py,sha256=OoptTTXTZQupzBwgGOfKNjyYAKBxDy-wI3l6T7XVE8s,4651
5
- monitor/monitor_pids.py,sha256=lXeh4gQzAd6fEUk0ETGT4vEr4L1sx9TEHK-KN77uvLo,13951
5
+ monitor/monitor_pids.py,sha256=AYeIsaCp1LLKTI-Z4psP-o1Ol8xatY0K7wuvRFOsATI,15636
6
6
  monitor/monitor_win.py,sha256=xs5nzqqEPoDmJTegh3lQhVjjpPcOWnruWKK65ttqnTo,6161
7
7
  monitor/run_monitor.py,sha256=s9JSFu5olh3VhrEqj_CZ5l25nvBtd2cN0NhU9R2KOKM,1581
8
8
  monitor/sys_info.py,sha256=aNultuRoQuRYPkYo397xAXVDXP07Qx5JOHtYzNmEvuc,3208
@@ -22,8 +22,10 @@ monitor/DLL/sechost.dll,sha256=1mXCrgNDRBiZ2XZk7eTpDm4oPG-x9BW4uYUVkrfvBkk,69986
22
22
  monitor/DLL/ucrtbased.dll,sha256=vtmKFPEHyr2OXkrUOu3Qs1dlbKG1dxZ8ItKCkTTU5S4,2238056
23
23
  monitor/DLL/vcruntime140.dll,sha256=AsaqDm5iRBGp8ZsDYKeGWrFZCOJgJFEOXDipwINiw1o,119888
24
24
  monitor/DLL/vcruntime140_1.dll,sha256=fdmqAuJxxoym1fGNZR0joV1yWXFa9DMmV4993ifzdjc,49640
25
- pmonitor-1.1.9.dist-info/METADATA,sha256=mDPrQIcbWW059dbqobf5EsU1kzNDfyU1IYVpbxIQpRU,215
26
- pmonitor-1.1.9.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
27
- pmonitor-1.1.9.dist-info/entry_points.txt,sha256=vmlLEANgf2fZar9BeXYiKdF6GMJbVXip-SIZx5yPXDo,55
28
- pmonitor-1.1.9.dist-info/top_level.txt,sha256=tGkQDkVeyKgP5Rr7acpp0df83NBAnI8up0sGwRxuuQ4,8
29
- pmonitor-1.1.9.dist-info/RECORD,,
25
+ monitor/exec/GpuMonitor,sha256=vlkPrbj2ArTAO_OTxrk68l3UDMigUM-eG7y76Tmmd0k,111568
26
+ monitor/exec/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ pmonitor-1.2.0.dist-info/METADATA,sha256=ade--dYTc2kF8Vrjhh3PKhEPQaR4GjRx-V9WZco1kBs,215
28
+ pmonitor-1.2.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
29
+ pmonitor-1.2.0.dist-info/entry_points.txt,sha256=vmlLEANgf2fZar9BeXYiKdF6GMJbVXip-SIZx5yPXDo,55
30
+ pmonitor-1.2.0.dist-info/top_level.txt,sha256=tGkQDkVeyKgP5Rr7acpp0df83NBAnI8up0sGwRxuuQ4,8
31
+ pmonitor-1.2.0.dist-info/RECORD,,