提交 57367321 作者: martin

window版进程监控exporter

上级 711bbb9d
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="16">
<item index="0" class="java.lang.String" itemvalue="gensim" />
<item index="1" class="java.lang.String" itemvalue="jieba" />
<item index="2" class="java.lang.String" itemvalue="nltk" />
<item index="3" class="java.lang.String" itemvalue="scikit_learn" />
<item index="4" class="java.lang.String" itemvalue="symspellpy" />
<item index="5" class="java.lang.String" itemvalue="wordcloud" />
<item index="6" class="java.lang.String" itemvalue="setuptools" />
<item index="7" class="java.lang.String" itemvalue="numpy" />
<item index="8" class="java.lang.String" itemvalue="requests" />
<item index="9" class="java.lang.String" itemvalue="pandas" />
<item index="10" class="java.lang.String" itemvalue="umap" />
<item index="11" class="java.lang.String" itemvalue="sentence_transformers" />
<item index="12" class="java.lang.String" itemvalue="elasticsearch" />
<item index="13" class="java.lang.String" itemvalue="matplotlib" />
<item index="14" class="java.lang.String" itemvalue="keras" />
<item index="15" class="java.lang.String" itemvalue="concurrent_log_handler" />
</list>
</value>
</option>
</inspection_tool>
<inspection_tool class="SqlNoDataSourceInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SqlResolveInspection" enabled="false" level="ERROR" enabled_by_default="false" />
</profile>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/yunwei.iml" filepath="$PROJECT_DIR$/.idea/yunwei.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
('C:\\pyproject\\yunwei\\build\\m2\\m2.pkg',
{'BINARY': True,
'DATA': True,
'EXECUTABLE': True,
'EXTENSION': True,
'PYMODULE': True,
'PYSOURCE': True,
'PYZ': False,
'SPLASH': True,
'SYMLINK': False},
[('pyi-contents-directory _internal', '', 'OPTION'),
('PYZ-00.pyz', 'C:\\pyproject\\yunwei\\build\\m2\\PYZ-00.pyz', 'PYZ'),
('struct',
'C:\\pyproject\\yunwei\\build\\m2\\localpycs\\struct.pyc',
'PYMODULE'),
('pyimod01_archive',
'C:\\pyproject\\yunwei\\build\\m2\\localpycs\\pyimod01_archive.pyc',
'PYMODULE'),
('pyimod02_importers',
'C:\\pyproject\\yunwei\\build\\m2\\localpycs\\pyimod02_importers.pyc',
'PYMODULE'),
('pyimod03_ctypes',
'C:\\pyproject\\yunwei\\build\\m2\\localpycs\\pyimod03_ctypes.pyc',
'PYMODULE'),
('pyimod04_pywin32',
'C:\\pyproject\\yunwei\\build\\m2\\localpycs\\pyimod04_pywin32.pyc',
'PYMODULE'),
('pyiboot01_bootstrap',
'C:\\Python312\\Lib\\site-packages\\PyInstaller\\loader\\pyiboot01_bootstrap.py',
'PYSOURCE'),
('pyi_rth_inspect',
'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py',
'PYSOURCE'),
('m2', 'C:\\pyproject\\yunwei\\m2.py', 'PYSOURCE'),
('python312.dll', 'C:\\Python312\\python312.dll', 'BINARY'),
('_decimal.pyd', 'C:\\Python312\\DLLs\\_decimal.pyd', 'EXTENSION'),
('_hashlib.pyd', 'C:\\Python312\\DLLs\\_hashlib.pyd', 'EXTENSION'),
('_lzma.pyd', 'C:\\Python312\\DLLs\\_lzma.pyd', 'EXTENSION'),
('_bz2.pyd', 'C:\\Python312\\DLLs\\_bz2.pyd', 'EXTENSION'),
('unicodedata.pyd', 'C:\\Python312\\DLLs\\unicodedata.pyd', 'EXTENSION'),
('select.pyd', 'C:\\Python312\\DLLs\\select.pyd', 'EXTENSION'),
('_socket.pyd', 'C:\\Python312\\DLLs\\_socket.pyd', 'EXTENSION'),
('_wmi.pyd', 'C:\\Python312\\DLLs\\_wmi.pyd', 'EXTENSION'),
('_ssl.pyd', 'C:\\Python312\\DLLs\\_ssl.pyd', 'EXTENSION'),
('api-ms-win-crt-runtime-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-crt-runtime-l1-1-0.dll',
'BINARY'),
('api-ms-win-crt-stdio-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-crt-stdio-l1-1-0.dll',
'BINARY'),
('VCRUNTIME140.dll', 'C:\\Python312\\VCRUNTIME140.dll', 'BINARY'),
('api-ms-win-crt-time-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-crt-time-l1-1-0.dll',
'BINARY'),
('api-ms-win-crt-string-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-crt-string-l1-1-0.dll',
'BINARY'),
('api-ms-win-crt-heap-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-crt-heap-l1-1-0.dll',
'BINARY'),
('api-ms-win-crt-math-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-crt-math-l1-1-0.dll',
'BINARY'),
('api-ms-win-crt-process-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-crt-process-l1-1-0.dll',
'BINARY'),
('api-ms-win-crt-convert-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-crt-convert-l1-1-0.dll',
'BINARY'),
('api-ms-win-crt-environment-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-crt-environment-l1-1-0.dll',
'BINARY'),
('api-ms-win-crt-conio-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-crt-conio-l1-1-0.dll',
'BINARY'),
('api-ms-win-crt-locale-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-crt-locale-l1-1-0.dll',
'BINARY'),
('api-ms-win-crt-filesystem-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-crt-filesystem-l1-1-0.dll',
'BINARY'),
('libcrypto-3.dll', 'C:\\Python312\\DLLs\\libcrypto-3.dll', 'BINARY'),
('libssl-3.dll', 'C:\\Python312\\DLLs\\libssl-3.dll', 'BINARY'),
('ucrtbase.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\ucrtbase.dll',
'BINARY'),
('api-ms-win-crt-utility-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-crt-utility-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-util-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-util-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-processthreads-l1-1-1.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-processthreads-l1-1-1.dll',
'BINARY'),
('api-ms-win-core-console-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-console-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-debug-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-debug-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-string-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-string-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-timezone-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-timezone-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-file-l1-2-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-file-l1-2-0.dll',
'BINARY'),
('api-ms-win-core-synch-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-synch-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-rtlsupport-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-rtlsupport-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-errorhandling-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-errorhandling-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-file-l2-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-file-l2-1-0.dll',
'BINARY'),
('api-ms-win-core-file-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-file-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-handle-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-handle-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-synch-l1-2-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-synch-l1-2-0.dll',
'BINARY'),
('api-ms-win-core-processthreads-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-processthreads-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-namedpipe-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-namedpipe-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-localization-l1-2-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-localization-l1-2-0.dll',
'BINARY'),
('api-ms-win-core-datetime-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-datetime-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-memory-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-memory-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-interlocked-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-interlocked-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-processenvironment-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-processenvironment-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-heap-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-heap-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-libraryloader-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-libraryloader-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-sysinfo-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-sysinfo-l1-1-0.dll',
'BINARY'),
('api-ms-win-core-profile-l1-1-0.dll',
'C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance '
'Toolkit\\api-ms-win-core-profile-l1-1-0.dll',
'BINARY'),
('base_library.zip',
'C:\\pyproject\\yunwei\\build\\m2\\base_library.zip',
'DATA')],
'python312.dll',
False,
False,
False,
[],
None,
None,
None)
This file lists modules PyInstaller was not able to find. This does not
necessarily mean this module is required for running your program. Python and
Python 3rd-party packages include a lot of conditional or optional modules. For
example the module 'ntpath' only exists on Windows, whereas the module
'posixpath' only exists on Posix systems.
Types if import:
* top-level: imported at the top-level - look at these first
* conditional: imported within an if-statement
* delayed: imported within a function
* optional: imported within a try-except-statement
IMPORTANT: Do NOT post this list to the issue-tracker. Use it as a basis for
tracking down the missing module yourself. Thanks!
missing module named _sha512 - imported by random (optional)
missing module named pwd - imported by posixpath (delayed, conditional, optional), shutil (delayed, optional), tarfile (optional), pathlib (delayed, optional), subprocess (delayed, conditional, optional), http.server (delayed, optional), netrc (delayed, conditional), getpass (delayed)
missing module named grp - imported by shutil (delayed, optional), tarfile (optional), pathlib (delayed, optional), subprocess (delayed, conditional, optional)
missing module named posix - imported by posixpath (optional), shutil (conditional), importlib._bootstrap_external (conditional), os (conditional, optional)
missing module named resource - imported by posix (top-level), prometheus_client.process_collector (optional)
missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional)
excluded module named _frozen_importlib - imported by importlib (optional), importlib.abc (optional)
missing module named vms_lib - imported by platform (delayed, optional)
missing module named 'java.lang' - imported by platform (delayed, optional)
missing module named java - imported by platform (delayed)
missing module named _winreg - imported by platform (delayed, optional)
missing module named _scproxy - imported by urllib.request (conditional)
missing module named termios - imported by getpass (optional)
missing module named _posixsubprocess - imported by subprocess (conditional)
missing module named fcntl - imported by subprocess (optional)
This source diff could not be displayed because it is too large. You can view the blob instead.
File added
from subprocess import check_output
from time import sleep
from prometheus_client import start_http_server, Gauge
import argparse
def get_cmd_window_info():
cmd_output = check_output('tasklist /v /fo csv').decode('GBK')
lines = cmd_output.split('\n')[1:-1] # Skip header and empty line
cmd_info = []
for line in lines:
fields = line.strip().split('","')
image = fields[0][1:]
pid = int(fields[1])
mem_use = int(fields[4][:-2].replace(',', '')) * 1024
title = fields[8].split(':')[-1].strip('"').strip()
cmd_info.append({'image': image, 'pid': pid, 'mem_use': mem_use, 'title': title})
return cmd_info
if __name__ == '__main__':
print()
print('*' * 20, "Windows process exporter For Prometheus", '*' * 20)
print("You can directly start to use default port 8760,\nor add --port port_num as a start args to use port_num")
# 创建一个Gauge指标
window_memory_used_by_process = Gauge('window_memory_used_by_process', 'Window process Memory Used',
['title', 'pid', 'image'])
# 解析命令行参数
parser = argparse.ArgumentParser()
parser.add_argument('--port', type=int, default=8760, help='Port number to listen on')
args = parser.parse_args()
# 启动HTTP服务器,监听指定的端口,并添加基本身份验证
start_http_server(args.port)
while True:
# 获取cmd.exe程序启动的命令行窗口信息
cmd_window_info = get_cmd_window_info()
# 更新指标的值
window_memory_used_by_process._metrics.clear()
for info in cmd_window_info:
window_memory_used_by_process.labels(title=info['title'], pid=str(info['pid']),
image=str(info['image'])).set(
info['mem_use'])
# 每隔30秒更新一次指标的值
sleep(30)
# -*- mode: python ; coding: utf-8 -*-
a = Analysis(
['m2.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='m2',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论