process-exporter部署手册
作者:互联网
目录
process-exporter部署手册
来源
https://github.com/ncabatoff/process-exporter
说明
一款进程监控导出器
部署方式
二进制文件部署
下载地址:https://github.com/ncabatoff/process-exporter/releases/tag/v0.5.0
命令行常用的参数:
Usage of process-exporter:
-children
if a proc is tracked, track with it any children that aren't part of their own group (default true)
-config.path string
path to YAML config file
-debug
log debugging information to stdout
-man
print manual
-namemapping string
comma-separated list, alternating process name and capturing regex to apply to cmdline
-once-to-stdout-delay duration
Don't bind, just wait this much time, print the metrics once to stdout, and exit
-procfs string
path to read proc data from (default "/proc")
-procnames string
comma-separated list of process names to monitor
-recheck
recheck process names on each scrape
-threads
report on per-threadname metrics as well (default true)
-version
print version information and exit
-web.listen-address string
Address on which to expose metrics and web interface. (default ":9256")
-web.telemetry-path string
Path under which to expose metrics. (default "/metrics")
配置文件
配置模板如下:
process_names:
- matcher1
- matcher2
...
- matcherN
例如:监控所有的服务进程
process_names:
- name: "{{.Comm}}"
cmdline:
- '.+'
配置模板选项如下:
{{.Comm}} 包含原始可执行文件的basename,/proc//stat 中的换句话说,2nd 字段
{{.ExeBase}} 包含可执行文件的basename
{{.ExeFull}} 包含可执行文件的完全限定路径
{{.Username}} 包含有效用户的用户名
{{.Matches}} 映射包含应用命令行tlb所产生的所有匹配项
process_names中的每个项目都必须包含一个或多个选择器(comm,exe或cmdline), 如果存在多个选择器,则它们必须全部匹配。 每个选择器都是一个字符串列表,用于与进程的comm,argv [0]匹配;对于cmdline,则是一个适用于命令行的正则表达式。 cmdline regexp使用Go语法。
对于comm和exe,字符串列表是一个OR,这意味着与任何字符串匹配的任何进程都将添加到该项目的组中。
对于cmdline,正则表达式列表为AND,表示它们都必须匹配。 正则表达式中的任何捕获组都必须使用?P 选项为捕获分配一个名称,该名称用于填充.Matches。
例如:> ps -ef | grep redis
redis 771 1 0 Jun05 ? 00:45:49 /usr/bin/redis-server *:6379
可选配置项 | 举例 | 说明 |
---|---|---|
{{.Comm}} | groupname=“redis-server” | exe或者sh文件名称 |
{{.ExeBase}} | groupname=“redis-server *:6379” | / |
{{.ExeFull}} | groupname="/usr/bin/redis-server *:6379" | ps中的进程完成信息 |
{{.Username}} | groupname=“redis” | 使用进程所属的用户进行分组 |
{{.Matches}} | groupname=“map[:redis]” | 表示配置到关键字“redis” |
安装使用process-exporter
下载
wget https://github.com/ncabatoff/process-exporter/releases/download/v0.5.0/process-exporter-0.5.0.linux-amd64.tar.gz
解压
tar -zxvf process-exporter-0.5.0.linux-amd64.tar.gz
创建配置文件process-name.yaml 内容为
process_names:
- name: "{{.Matches}}"
cmdline:
- 'nginx'
- name: "{{.Matches}}"
cmdline:
- 'zombie'
重启服务
./process-exporter -config.path process-name.yaml &
查看数据:
http://localhost:9256/metrics
定义全部进程监控
vim conf.yaml
process_names:
- name: "{{.Comm}}"
cmdline:
- '.+'
常用进程监控项
总进程数
sum(namedprocess_namegroup_states)
总僵尸进程数
sum(namedprocess_namegroup_states{state="Zombie"})
exporter其他可自定义配置选项:
Usage of ./process-exporter:
-children
if a proc is tracked, track with it any children that aren't part of their own group (default true)
-config.path string
path to YAML config file
-debug
log debugging information to stdout
-man
print manual
-namemapping string
comma-seperated list, alternating process name and capturing regex to apply to cmdline
-once-to-stdout-delay duration
Don't bind, just wait this much time, print the metrics once to stdout, and exit
-procfs string
path to read proc data from (default "/proc")
-procnames string
comma-seperated list of process names to monitor
-recheck
recheck process names on each scrape
-web.listen-address string
Address on which to expose metrics and web interface. (default ":9256")
-web.telemetry-path string
Path under which to expose metrics. (default "/metrics")
标签:exporter,string,process,redis,手册,metrics,cmdline 来源: https://blog.csdn.net/qq_43021786/article/details/118852036