pmonitor 1.4.2__tar.gz → 1.4.3__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.4.2 → pmonitor-1.4.3}/PKG-INFO +1 -1
  2. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/mac_gpu.py +16 -11
  3. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/monitor_pids.py +27 -12
  4. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/run_monitor.py +1 -1
  5. {pmonitor-1.4.2 → pmonitor-1.4.3}/pmonitor.egg-info/PKG-INFO +1 -1
  6. {pmonitor-1.4.2 → pmonitor-1.4.3}/setup.py +1 -1
  7. {pmonitor-1.4.2 → pmonitor-1.4.3}/README.md +0 -0
  8. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/DLL/GpuMonitorLib.dll +0 -0
  9. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/DLL/KernelBase.dll +0 -0
  10. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/DLL/__init__.py +0 -0
  11. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/DLL/advapi32.dll +0 -0
  12. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/DLL/bcrypt.dll +0 -0
  13. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/DLL/kernel.appcore.dll +0 -0
  14. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/DLL/kernel32.dll +0 -0
  15. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/DLL/msvcirt.dll +0 -0
  16. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/DLL/msvcp140.dll +0 -0
  17. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/DLL/ntdll.dll +0 -0
  18. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/DLL/pdh.dll +0 -0
  19. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/DLL/rpcrt4.dll +0 -0
  20. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/DLL/sechost.dll +0 -0
  21. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/DLL/ucrtbased.dll +0 -0
  22. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/DLL/vcruntime140.dll +0 -0
  23. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/DLL/vcruntime140_1.dll +0 -0
  24. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/WinPidUtil.py +0 -0
  25. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/__init__.py +0 -0
  26. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/exec/GpuMonitor +0 -0
  27. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/exec/__init__.py +0 -0
  28. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/get_process_name.py +0 -0
  29. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/monitor_mac.py +0 -0
  30. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/monitor_win.py +0 -0
  31. {pmonitor-1.4.2 → pmonitor-1.4.3}/monitor/sys_info.py +0 -0
  32. {pmonitor-1.4.2 → pmonitor-1.4.3}/pmonitor.egg-info/SOURCES.txt +0 -0
  33. {pmonitor-1.4.2 → pmonitor-1.4.3}/pmonitor.egg-info/dependency_links.txt +0 -0
  34. {pmonitor-1.4.2 → pmonitor-1.4.3}/pmonitor.egg-info/entry_points.txt +0 -0
  35. {pmonitor-1.4.2 → pmonitor-1.4.3}/pmonitor.egg-info/top_level.txt +0 -0
  36. {pmonitor-1.4.2 → pmonitor-1.4.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.2
2
2
  Name: pmonitor
3
- Version: 1.4.2
3
+ Version: 1.4.3
4
4
  Summary: pc monitor
5
5
  Home-page: UNKNOWN
6
6
  Author: cfr
@@ -36,21 +36,26 @@ if platform.system() != 'Windows':
36
36
  try:
37
37
  gpu_info = accelerator_performance_statistics()
38
38
  use_gpu_memory = 0
39
- device_usage = 0
40
- # print(f"gpu_info: {gpu_info['PerformanceStatistics']}")
39
+ total_gpu_memory = 0
40
+ free_gpu_memory = 0
41
41
  for key, value in gpu_info["PerformanceStatistics"].items():
42
- if key == "In use system memory":
43
- use_gpu_memory = int(value) / 1024 / 1024
44
- # print(f"{key}: {value}")
45
- elif key == "inUseSysMemoryBytes":
46
- use_gpu_memory = int(value) / 1024 / 1024
47
- # print(f"{key}: {value}")
48
- elif key == "Device Utilization %":
49
- device_usage = int(value)
42
+ if key == "In use system memory" or key == "gartUsedBytes":
43
+ use_gpu_memory = int(value)
44
+ elif key == "gartSizeBytes":
45
+ total_gpu_memory = int(value)
46
+ elif key == "gartFreeBytes":
47
+ free_gpu_memory = int(value)
48
+ elif key == "Alloc system memory":
49
+ total_gpu_memory = int(value)
50
50
  # print('device usage', device_usage)
51
51
  # use_gpu_memory = gpu_info["PerformanceStatistics"]["In use system memory"]
52
52
  # total_gpu_memory = gpu_info["PerformanceStatistics"]["Alloc system memory"]
53
53
  except Exception as e:
54
54
  print(f"Mac端在arm64平台通过接口获取Gpu Memory失败:{e}")
55
55
  use_gpu_memory = 0
56
- return use_gpu_memory, device_usage
56
+ total_gpu_memory = 0
57
+ free_gpu_memory = 0
58
+ if free_gpu_memory == 0:
59
+ free_gpu_memory = total_gpu_memory - use_gpu_memory
60
+ return round(use_gpu_memory / 1024 / 1024, 2), round(total_gpu_memory / 1024 / 1024, 2), round(
61
+ free_gpu_memory / 1024 / 1024, 2)
@@ -7,9 +7,7 @@ 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
  if platform.system() != 'Windows':
14
12
  from monitor.mac_gpu import get_gpu_memory
15
13
 
@@ -28,15 +26,18 @@ class PidsPerf:
28
26
  minor_real_mem_sum = 0
29
27
  minor_mem_percent_sum = 0
30
28
  minor_thread_count_sum = 0
31
- gpu_memory_usage_0 = 0
32
- gpu_memory_percent_0 = 0
33
- gpu_memory_usage_1 = 0
34
- gpu_memory_percent_1 = 0
29
+ gpu_memory_usage = 0
30
+ gpu_memory_total = 0
31
+ gpu_memory_free = 0
35
32
  current_pids = self.processUtil.get_children_pids(current_pid) # 获取所有子进程
36
33
  current_pids.add(current_pid) # 将主进程及子进程添加到list中
37
34
  pids_process = self.processUtil.get_pids_process(current_pids) # 获取所有进程
38
35
 
39
- gpu_memory_usage_0, gpu_memory_percent_0 = get_gpu_memory()
36
+ mem_info = psutil.virtual_memory()
37
+ mem_total = round(mem_info.total / 1024 / 1024, 2) # 总虚拟内存
38
+ mem_available = round(mem_info.available / 1024 / 1024, 2) # 剩余虚拟内存
39
+
40
+ gpu_memory_usage, gpu_memory_total, gpu_memory_free = get_gpu_memory()
40
41
  for process in pids_process:
41
42
  try:
42
43
  cpu_percent = process.cpu_percent()
@@ -77,9 +78,10 @@ class PidsPerf:
77
78
  io_read_bytes = io_read_bytes_end - io_read_bytes_start # io read/byte
78
79
  io_write_bytes = io_write_bytes_end - io_write_bytes_start # io write/byte
79
80
  disk_data = {'io read': io_read_bytes, 'io write': io_write_bytes}
80
- gpu_data = {'gpu 0 memory usage': gpu_memory_usage_0, 'gpu 0 device Utilization': gpu_memory_percent_0,
81
- 'gpu 1 memory usage': gpu_memory_usage_1, 'gpu 1 device Utilization': gpu_memory_percent_1}
82
- data = {'main': main_data, 'other': minor_data, 'disk': disk_data, "gpu": gpu_data}
81
+ gpu_data = {'gpu memory usage': gpu_memory_usage, 'gpu memory total': gpu_memory_total,
82
+ 'gpu memory free': gpu_memory_free}
83
+ data = {'main': main_data, 'other': minor_data, 'disk': disk_data, "gpu": gpu_data,
84
+ "memory_total": mem_total, "memory_available": mem_available}
83
85
  json_data = json.dumps(data)
84
86
  print(json_data)
85
87
  sys.stdout.flush()
@@ -101,6 +103,7 @@ class PidsPerf:
101
103
  def get_win_perf(self):
102
104
  from monitor.WinPidUtil import PidWinPerformance, FILETIME
103
105
  from ctypes import CDLL, c_int, c_char_p, byref
106
+ from PyLibreHardwareMonitor.computer import Computer
104
107
  pidWinPerf = PidWinPerformance()
105
108
  system_time_pre = pidWinPerf.filetime_to_100nano_seconds(FILETIME())
106
109
  p_pid = self.processUtil.find_main_process_pid(self.process_name)
@@ -114,6 +117,9 @@ class PidsPerf:
114
117
  gpu_monitor_dll = ctypes.CDLL(dll_path)
115
118
  gpu_monitor_dll.GetGPUDataForProcess.argtypes = [ctypes.c_ulong]
116
119
  gpu_monitor_dll.GetGPUDataForProcess.restype = ctypes.c_char_p
120
+ # 获取GPU物理内存
121
+ computer = Computer()
122
+ gpu_key = list(computer.gpu.keys())[0]
117
123
  while True:
118
124
  minor_cpu_sum = 0
119
125
  minor_workSet_mem_sum = 0
@@ -145,6 +151,7 @@ class PidsPerf:
145
151
  child_pids.add(p_pid) # app内所有pid
146
152
  child_pids = {pid for pid in child_pids if psutil.pid_exists(pid)} # 移除不存在的进程
147
153
 
154
+ small_data = computer.gpu[gpu_key]['SmallData'] # 获取GPU物理内存信息
148
155
  try:
149
156
  new_pids_cpu_time_pre = {pid: pidWinPerf.get_process_cpu_time(pid) for pid in child_pids if
150
157
  pid not in process_cpu_times_pre}
@@ -156,6 +163,8 @@ class PidsPerf:
156
163
 
157
164
  # print('----------------------------------------------------------')
158
165
  # print('pid', child_pids)
166
+ memory_total = round(psutil.virtual_memory().total / 1024 / 1024, 2)
167
+ memory_available = round(psutil.virtual_memory().available / 1024 / 1024, 2)
159
168
 
160
169
  for pid in child_pids:
161
170
  try:
@@ -241,8 +250,14 @@ class PidsPerf:
241
250
  'gpu_System': round(minor_gpu_system_sum, 2),
242
251
  'gpu_Committed': round(minor_gpu_committed_sum, 2),
243
252
  'gpu_Usage': round(minor_gpu_percent_sum, 2)}
253
+ gpu_data = {'gpu memory usage': small_data['GPU Memory Used'],
254
+ 'gpu memory total': small_data['GPU Memory Total'],
255
+ 'gpu memory free': small_data['GPU Memory Free']}
244
256
  try:
245
- data = {'main': main_data, 'other': other_data, 'disk': disk_data}
257
+ data = {'main': main_data, 'other': other_data, 'disk': disk_data,
258
+ 'gpu': gpu_data,
259
+ 'memory_total': memory_total,
260
+ 'memory_available': memory_available}
246
261
  json_data = json.dumps(data)
247
262
  print(json_data)
248
263
  except UnboundLocalError:
@@ -27,7 +27,7 @@ def main():
27
27
  if args.time:
28
28
  interval = args.time
29
29
 
30
- # process = 'pixcake.exe'
30
+ # process = 'ColorByte.exe'
31
31
  # interval = 1
32
32
  process_name = ProcessName()
33
33
  if process is not None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.2
2
2
  Name: pmonitor
3
- Version: 1.4.2
3
+ Version: 1.4.3
4
4
  Summary: pc monitor
5
5
  Home-page: UNKNOWN
6
6
  Author: cfr
@@ -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.4.2',
8
+ version='1.4.3',
9
9
  description='pc monitor',
10
10
  long_description=long_description,
11
11
  author='cfr',
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes