pmonitor 1.1.7__tar.gz → 1.1.9__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 (34) hide show
  1. {pmonitor-1.1.7 → pmonitor-1.1.9}/PKG-INFO +1 -1
  2. pmonitor-1.1.9/monitor/DLL/GpuMonitorLib.dll +0 -0
  3. pmonitor-1.1.9/monitor/DLL/KernelBase.dll +0 -0
  4. pmonitor-1.1.9/monitor/DLL/advapi32.dll +0 -0
  5. pmonitor-1.1.9/monitor/DLL/bcrypt.dll +0 -0
  6. pmonitor-1.1.9/monitor/DLL/kernel.appcore.dll +0 -0
  7. pmonitor-1.1.9/monitor/DLL/kernel32.dll +0 -0
  8. pmonitor-1.1.9/monitor/DLL/msvcirt.dll +0 -0
  9. pmonitor-1.1.9/monitor/DLL/msvcp140.dll +0 -0
  10. pmonitor-1.1.9/monitor/DLL/ntdll.dll +0 -0
  11. pmonitor-1.1.9/monitor/DLL/pdh.dll +0 -0
  12. pmonitor-1.1.9/monitor/DLL/rpcrt4.dll +0 -0
  13. pmonitor-1.1.9/monitor/DLL/sechost.dll +0 -0
  14. pmonitor-1.1.9/monitor/DLL/ucrtbased.dll +0 -0
  15. pmonitor-1.1.9/monitor/DLL/vcruntime140.dll +0 -0
  16. pmonitor-1.1.9/monitor/DLL/vcruntime140_1.dll +0 -0
  17. pmonitor-1.1.9/monitor/__init__.py +0 -0
  18. {pmonitor-1.1.7 → pmonitor-1.1.9}/monitor/monitor_pids.py +61 -6
  19. {pmonitor-1.1.7 → pmonitor-1.1.9}/monitor/run_monitor.py +3 -18
  20. {pmonitor-1.1.7 → pmonitor-1.1.9}/pmonitor.egg-info/PKG-INFO +1 -1
  21. pmonitor-1.1.9/pmonitor.egg-info/SOURCES.txt +31 -0
  22. {pmonitor-1.1.7 → pmonitor-1.1.9}/setup.py +5 -2
  23. pmonitor-1.1.7/pmonitor.egg-info/SOURCES.txt +0 -15
  24. {pmonitor-1.1.7 → pmonitor-1.1.9}/README.md +0 -0
  25. {pmonitor-1.1.7/monitor → pmonitor-1.1.9/monitor/DLL}/__init__.py +0 -0
  26. {pmonitor-1.1.7 → pmonitor-1.1.9}/monitor/WinPidUtil.py +0 -0
  27. {pmonitor-1.1.7 → pmonitor-1.1.9}/monitor/get_process_name.py +0 -0
  28. {pmonitor-1.1.7 → pmonitor-1.1.9}/monitor/monitor_mac.py +0 -0
  29. {pmonitor-1.1.7 → pmonitor-1.1.9}/monitor/monitor_win.py +0 -0
  30. {pmonitor-1.1.7 → pmonitor-1.1.9}/monitor/sys_info.py +0 -0
  31. {pmonitor-1.1.7 → pmonitor-1.1.9}/pmonitor.egg-info/dependency_links.txt +0 -0
  32. {pmonitor-1.1.7 → pmonitor-1.1.9}/pmonitor.egg-info/entry_points.txt +0 -0
  33. {pmonitor-1.1.7 → pmonitor-1.1.9}/pmonitor.egg-info/top_level.txt +0 -0
  34. {pmonitor-1.1.7 → pmonitor-1.1.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.2
2
2
  Name: pmonitor
3
- Version: 1.1.7
3
+ Version: 1.1.9
4
4
  Summary: pc monitor
5
5
  Home-page: UNKNOWN
6
6
  Author: cfr
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
File without changes
@@ -6,6 +6,7 @@ import sys
6
6
  import asyncio
7
7
  import platform
8
8
  import ctypes
9
+ import os
9
10
 
10
11
 
11
12
  class PidsPerf:
@@ -85,8 +86,8 @@ class PidsPerf:
85
86
  return 0, 0
86
87
 
87
88
  def get_win_perf(self):
88
- from monitor.WinPidUtil import PidWinPerformance,FILETIME
89
- from ctypes import byref
89
+ from monitor.WinPidUtil import PidWinPerformance, FILETIME
90
+ from ctypes import CDLL, c_int, c_char_p, byref
90
91
  pidWinPerf = PidWinPerformance()
91
92
  system_time_pre = pidWinPerf.filetime_to_100nano_seconds(FILETIME())
92
93
  p_pid = self.processUtil.find_main_process_pid(self.process_name)
@@ -94,7 +95,11 @@ class PidsPerf:
94
95
  child_pids.add(p_pid) # app内所有pid
95
96
  process_cpu_times_pre = {pid: pidWinPerf.get_process_cpu_time(pid) for pid in child_pids}
96
97
  process_io_counters_pre = {pid: pidWinPerf.get_io_counters(pid) for pid in child_pids}
97
- monitor_interval_seconds = 1 # 监控间隔(秒)
98
+
99
+ dll_path = os.path.join(os.path.dirname(__file__), 'DLL', 'GpuMonitorLib.dll')
100
+ gpu_monitor_dll = CDLL(dll_path)
101
+ gpu_monitor_dll.GetGpuUtilizationByPid.argtypes = [c_int]
102
+ gpu_monitor_dll.GetGpuUtilizationByPid.restype = c_char_p
98
103
  while True:
99
104
  minor_cpu_sum = 0
100
105
  minor_workSet_mem_sum = 0
@@ -103,6 +108,10 @@ class PidsPerf:
103
108
  minor_thread_count_sum = 0
104
109
  minor_io_read_sum = 0
105
110
  minor_io_write_sum = 0
111
+ minor_gpu_dedicated_sum = 0 # (专用内存)
112
+ minor_gpu_system_sum = 0 # (共享内存)
113
+ minor_gpu_committed_sum = 0 # (总使用内存)
114
+ minor_gpu_percent_sum = 0 # (GPU内存占比)
106
115
 
107
116
  current_pids = self.processUtil.get_children_pids(p_pid) # 获取所有子进程
108
117
  current_pids.add(p_pid) # 将主进程及子进程添加到list中
@@ -146,6 +155,8 @@ class PidsPerf:
146
155
  pid].ReadTransferCount) / self.interval
147
156
  write_bytes_sec = (io_counters.WriteTransferCount - process_io_counters_pre[
148
157
  pid].WriteTransferCount) / self.interval
158
+ gpu_info_json = gpu_monitor_dll.GetGpuUtilizationByPid(pid).decode()
159
+ gpu_info = json.loads(gpu_info_json)
149
160
  if process_cpu_time_post:
150
161
  # 计算CPU使用率
151
162
  cpu_usage = round((process_cpu_time_post - process_cpu_times_pre[pid]) / (
@@ -155,7 +166,29 @@ class PidsPerf:
155
166
  workSet_mem = round(memory_info.WorkingSetSize / 1024 / 1024, 2) # MB
156
167
  private_mem = round(memory_info.PrivateUsage / 1024 / 1024, 2) # MB
157
168
  if pid == p_pid:
158
- main_data = {'cpu': cpu_usage, 'private': private_mem, "workset": workSet_mem}
169
+ if gpu_info['GPUUtilizationPercent'] < 0:
170
+ gpu_Dedicated = 0
171
+ gpu_System = 0
172
+ gpu_Committed = 0
173
+ gpu_Usage = 0
174
+ # print('主进程pid:', gpu_info['ProcessID'], 'Dedicated:', 0,
175
+ # 'System:', 0,
176
+ # 'Committed:', 0, 'GPU Usage:',
177
+ # 0)
178
+ else:
179
+ gpu_Dedicated = gpu_info['GPUProcessMemoryLocalUsage']
180
+ gpu_System = gpu_info['GPUProcessMemorySharedUsage']
181
+ gpu_Committed = gpu_info['GPUProcessMemoryTotalCommitted']
182
+ gpu_Usage = gpu_info['GPUUtilizationPercent']
183
+ # print('主进程pid:', gpu_info['ProcessID'], 'Dedicated:',
184
+ # gpu_info['GPUProcessMemoryLocalUsage'],
185
+ # 'System:', gpu_info['GPUProcessMemorySharedUsage'],
186
+ # 'Committed:', gpu_info['GPUProcessMemoryTotalCommitted'], 'GPU Usage:',
187
+ # gpu_info['GPUUtilizationPercent'])
188
+ main_data = {'cpu': cpu_usage, 'private': private_mem, "workset": workSet_mem,
189
+ 'gpu_Dedicated': round(gpu_Dedicated, 2), 'gpu_System': round(gpu_System, 2),
190
+ 'gpu_Committed': round(gpu_Committed, 2), 'gpu_Usage': round(gpu_Usage, 2)}
191
+
159
192
  # print(
160
193
  # f'主进程数据:cpu:{cpu_usage},workSet:{workSet_mem},private:{private_mem},mem_percent:{mem_percent},thread_count:{thread_count}')
161
194
  else:
@@ -164,6 +197,25 @@ class PidsPerf:
164
197
  minor_private_mem_sum += private_mem # 子进程private内存
165
198
  minor_mem_percent_sum += mem_percent # 子进程内存使用率
166
199
  minor_thread_count_sum += thread_count # 子进程线程总数
200
+ if gpu_info['GPUUtilizationPercent'] < 0:
201
+ # print('子进程pid:', gpu_info['ProcessID'], 'Dedicated:', 0,
202
+ # 'System:', 0,
203
+ # 'Committed:', 0, 'GPU Usage:',
204
+ # 0)
205
+ minor_gpu_dedicated_sum += 0
206
+ minor_gpu_system_sum += 0
207
+ minor_gpu_committed_sum += 0
208
+ minor_gpu_percent_sum += 0
209
+ else:
210
+ # print('子进程pid:', gpu_info['ProcessID'], 'Dedicated:',
211
+ # gpu_info['GPUProcessMemoryLocalUsage'],
212
+ # 'System:', gpu_info['GPUProcessMemorySharedUsage'],
213
+ # 'Committed:', gpu_info['GPUProcessMemoryTotalCommitted'], 'GPU Usage:',
214
+ # gpu_info['GPUUtilizationPercent'])
215
+ minor_gpu_dedicated_sum += gpu_info['GPUProcessMemoryLocalUsage']
216
+ minor_gpu_system_sum += gpu_info['GPUProcessMemorySharedUsage']
217
+ minor_gpu_committed_sum += gpu_info['GPUProcessMemoryTotalCommitted']
218
+ minor_gpu_percent_sum += gpu_info['GPUUtilizationPercent']
167
219
  minor_io_read_sum += read_bytes_sec # 所有进程IO读取速率总数
168
220
  minor_io_write_sum += write_bytes_sec # 所有进程IO写入速率总数
169
221
 
@@ -174,7 +226,11 @@ class PidsPerf:
174
226
  other_data = {'cpu': minor_cpu_sum, 'private': round(float(minor_private_mem_sum), 2),
175
227
  'workset': round(float(minor_workSet_mem_sum), 2),
176
228
  'memory percent': round(float(minor_mem_percent_sum), 2),
177
- 'thread count': minor_thread_count_sum}
229
+ 'thread count': minor_thread_count_sum,
230
+ 'gpu_Dedicated': round(minor_gpu_dedicated_sum, 2),
231
+ 'gpu_System': round(minor_gpu_system_sum, 2),
232
+ 'gpu_Committed': round(minor_gpu_committed_sum, 2),
233
+ 'gpu_Usage': round(minor_gpu_percent_sum, 2)}
178
234
  data = {'main': main_data, 'other': other_data, 'disk': disk_data}
179
235
  json_data = json.dumps(data)
180
236
  print(json_data)
@@ -190,4 +246,3 @@ class PidsPerf:
190
246
  await asyncio.gather(self.get_win_perf())
191
247
  else:
192
248
  await asyncio.gather(self.get_mac_perf())
193
-
@@ -1,8 +1,7 @@
1
1
  import argparse
2
- import sys
3
2
 
4
3
  from monitor.sys_info import SysInfo
5
- from monitor. monitor_pids import *
4
+ from monitor.monitor_pids import *
6
5
  from monitor.get_process_name import *
7
6
  import asyncio
8
7
 
@@ -18,7 +17,6 @@ def main():
18
17
  if args.info:
19
18
  print(SysInfo().get_device_info())
20
19
  exit()
21
-
22
20
  process = None
23
21
  if args.name:
24
22
  process = args.name
@@ -29,6 +27,8 @@ def main():
29
27
  if args.time:
30
28
  interval = args.time
31
29
 
30
+ # process = 'ColorByte.exe'
31
+ # interval = 1
32
32
  process_name = ProcessName()
33
33
  if process is not None:
34
34
  print('监测进程<{}>,采集数据间隔<{}s>'.format(process, interval))
@@ -47,21 +47,6 @@ def main():
47
47
  print('开始监测进程<{}>,主进程pid<{}>'.format(process, pid))
48
48
  pidsPerf = PidsPerf(process, interval)
49
49
  asyncio.run(pidsPerf.start_perf())
50
- # if platform.system() == 'Windows':
51
- # monitor = WinPerformance(pid=int(pid))
52
- # else:
53
- # monitor = MacPerformance(pid=int(pid))
54
- # print(f'{" ".join(monitor.header)}')
55
- # while True:
56
- # try:
57
- # result = asyncio.run(monitor.get_all_monitor())
58
- # except Exception as e:
59
- # result = monitor.get_all_usage()
60
- # result.insert(0, time.strftime('%H:%M:%S'))
61
- # line = [str(item) for item in result]
62
- # info = " ".join(line)
63
- # print(info)
64
- # sys.stdout.flush()
65
50
 
66
51
 
67
52
  if __name__ == '__main__':
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.2
2
2
  Name: pmonitor
3
- Version: 1.1.7
3
+ Version: 1.1.9
4
4
  Summary: pc monitor
5
5
  Home-page: UNKNOWN
6
6
  Author: cfr
@@ -0,0 +1,31 @@
1
+ README.md
2
+ setup.py
3
+ monitor/WinPidUtil.py
4
+ monitor/__init__.py
5
+ monitor/get_process_name.py
6
+ monitor/monitor_mac.py
7
+ monitor/monitor_pids.py
8
+ monitor/monitor_win.py
9
+ monitor/run_monitor.py
10
+ monitor/sys_info.py
11
+ monitor/DLL/GpuMonitorLib.dll
12
+ monitor/DLL/KernelBase.dll
13
+ monitor/DLL/__init__.py
14
+ monitor/DLL/advapi32.dll
15
+ monitor/DLL/bcrypt.dll
16
+ monitor/DLL/kernel.appcore.dll
17
+ monitor/DLL/kernel32.dll
18
+ monitor/DLL/msvcirt.dll
19
+ monitor/DLL/msvcp140.dll
20
+ monitor/DLL/ntdll.dll
21
+ monitor/DLL/pdh.dll
22
+ monitor/DLL/rpcrt4.dll
23
+ monitor/DLL/sechost.dll
24
+ monitor/DLL/ucrtbased.dll
25
+ monitor/DLL/vcruntime140.dll
26
+ monitor/DLL/vcruntime140_1.dll
27
+ pmonitor.egg-info/PKG-INFO
28
+ pmonitor.egg-info/SOURCES.txt
29
+ pmonitor.egg-info/dependency_links.txt
30
+ pmonitor.egg-info/entry_points.txt
31
+ pmonitor.egg-info/top_level.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.7',
8
+ version='1.1.9',
9
9
  description='pc monitor',
10
10
  long_description=long_description,
11
11
  author='cfr',
@@ -13,6 +13,9 @@ setup(name='pmonitor',
13
13
  install_requires=[],
14
14
  license='MIT',
15
15
  packages=find_packages(),
16
+ package_data={
17
+ 'monitor': ['DLL/*'],
18
+ },
16
19
  platforms=['all'],
17
20
  classifiers=[],
18
21
  python_requires='>=3.6',
@@ -21,4 +24,4 @@ setup(name='pmonitor',
21
24
  'console_scripts': ['pmonitor=monitor.run_monitor:main'] # 增加命令行指令运行的参数设置
22
25
  },
23
26
 
24
- )
27
+ )
@@ -1,15 +0,0 @@
1
- README.md
2
- setup.py
3
- monitor/WinPidUtil.py
4
- monitor/__init__.py
5
- monitor/get_process_name.py
6
- monitor/monitor_mac.py
7
- monitor/monitor_pids.py
8
- monitor/monitor_win.py
9
- monitor/run_monitor.py
10
- monitor/sys_info.py
11
- pmonitor.egg-info/PKG-INFO
12
- pmonitor.egg-info/SOURCES.txt
13
- pmonitor.egg-info/dependency_links.txt
14
- pmonitor.egg-info/entry_points.txt
15
- pmonitor.egg-info/top_level.txt
File without changes
File without changes
File without changes
File without changes