pmonitor 1.1.8__tar.gz → 1.2.0__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 (36) hide show
  1. {pmonitor-1.1.8 → pmonitor-1.2.0}/PKG-INFO +1 -1
  2. pmonitor-1.2.0/monitor/DLL/GpuMonitorLib.dll +0 -0
  3. pmonitor-1.2.0/monitor/exec/GpuMonitor +0 -0
  4. pmonitor-1.2.0/monitor/exec/__init__.py +0 -0
  5. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/monitor_pids.py +32 -1
  6. {pmonitor-1.1.8 → pmonitor-1.2.0}/pmonitor.egg-info/PKG-INFO +1 -1
  7. {pmonitor-1.1.8 → pmonitor-1.2.0}/pmonitor.egg-info/SOURCES.txt +2 -0
  8. {pmonitor-1.1.8 → pmonitor-1.2.0}/setup.py +2 -2
  9. pmonitor-1.1.8/monitor/DLL/GpuMonitorLib.dll +0 -0
  10. {pmonitor-1.1.8 → pmonitor-1.2.0}/README.md +0 -0
  11. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/DLL/KernelBase.dll +0 -0
  12. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/DLL/__init__.py +0 -0
  13. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/DLL/advapi32.dll +0 -0
  14. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/DLL/bcrypt.dll +0 -0
  15. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/DLL/kernel.appcore.dll +0 -0
  16. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/DLL/kernel32.dll +0 -0
  17. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/DLL/msvcirt.dll +0 -0
  18. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/DLL/msvcp140.dll +0 -0
  19. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/DLL/ntdll.dll +0 -0
  20. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/DLL/pdh.dll +0 -0
  21. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/DLL/rpcrt4.dll +0 -0
  22. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/DLL/sechost.dll +0 -0
  23. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/DLL/ucrtbased.dll +0 -0
  24. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/DLL/vcruntime140.dll +0 -0
  25. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/DLL/vcruntime140_1.dll +0 -0
  26. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/WinPidUtil.py +0 -0
  27. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/__init__.py +0 -0
  28. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/get_process_name.py +0 -0
  29. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/monitor_mac.py +0 -0
  30. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/monitor_win.py +0 -0
  31. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/run_monitor.py +0 -0
  32. {pmonitor-1.1.8 → pmonitor-1.2.0}/monitor/sys_info.py +0 -0
  33. {pmonitor-1.1.8 → pmonitor-1.2.0}/pmonitor.egg-info/dependency_links.txt +0 -0
  34. {pmonitor-1.1.8 → pmonitor-1.2.0}/pmonitor.egg-info/entry_points.txt +0 -0
  35. {pmonitor-1.1.8 → pmonitor-1.2.0}/pmonitor.egg-info/top_level.txt +0 -0
  36. {pmonitor-1.1.8 → pmonitor-1.2.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.2
2
2
  Name: pmonitor
3
- Version: 1.1.8
3
+ Version: 1.2.0
4
4
  Summary: pc monitor
5
5
  Home-page: UNKNOWN
6
6
  Author: cfr
Binary file
File without changes
@@ -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: 1.2
2
2
  Name: pmonitor
3
- Version: 1.1.8
3
+ Version: 1.2.0
4
4
  Summary: pc monitor
5
5
  Home-page: UNKNOWN
6
6
  Author: cfr
@@ -24,6 +24,8 @@ monitor/DLL/sechost.dll
24
24
  monitor/DLL/ucrtbased.dll
25
25
  monitor/DLL/vcruntime140.dll
26
26
  monitor/DLL/vcruntime140_1.dll
27
+ monitor/exec/GpuMonitor
28
+ monitor/exec/__init__.py
27
29
  pmonitor.egg-info/PKG-INFO
28
30
  pmonitor.egg-info/SOURCES.txt
29
31
  pmonitor.egg-info/dependency_links.txt
@@ -5,7 +5,7 @@ with open('README.md', 'r') as f:
5
5
  long_description = f.read()
6
6
 
7
7
  setup(name='pmonitor',
8
- version='1.1.8',
8
+ version='1.2.0',
9
9
  description='pc monitor',
10
10
  long_description=long_description,
11
11
  author='cfr',
@@ -14,7 +14,7 @@ setup(name='pmonitor',
14
14
  license='MIT',
15
15
  packages=find_packages(),
16
16
  package_data={
17
- 'monitor': ['DLL/*'],
17
+ 'monitor': ['DLL/*', 'exec/*'],
18
18
  },
19
19
  platforms=['all'],
20
20
  classifiers=[],
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes