process-exporter简介
wget https://github.com/ncabatoff/process-exporter/releases/download/v0.7.5/process-exporter-0.7.5.linux-amd64.tar.gz tar xf process-exporter-0.7.5.linux-amd64.tar.gz -C /opt/process-exporter-0.7.5.linux-amd64 ln -s /opt/process-exporter-0.7.5.linux-amd64 /opt/process-exporter
- 包含原始可执行文件的基本名称,即第二个字段
/proc/<pid>/stat
[root@izx7dvghztbiorz process-exporter]# 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_names: - name: "{{.Comm}}" cmdline: - '.+'
process_names: - name: "{{.Matches}}" cmdline: - 'nginx' - name: "{{.Matches}}" cmdline: - 'zombie'
[root@ops targets]# cat /usr/lib/systemd/system/process-exporter.service [Unit] Description=process-exporter Exporter Wants=network-online.target After=network-online.target [Service] ExecStart=/opt/process-exporter/process-exporter -config.path=/opt/process-exporter/process-exporter.yaml StandardOutput=syslog StandardError=syslog SyslogIdentifier=process-exporter [Install]
systemctl start process-exporter.service systemctl enable process-exporter.service systemctl status process-exporter.service