categraf procstat进程监控返回值不对

Viewed 229

使用pgrep -f 进程名 可以有返回值, 在procstat中配置了search_cmdline_substring = "进程名" 但是最后输出值却不是0

5 Answers

procstat_lookup_count 指标是采集到进程的数量

应该不是, 我这个环境同时监控nginx, nging的进程数目多于1个返回值就是0

exec 和cmdline的作用是不一样的,如果你运行的nginx有参数,exec会采集不到PID,所以是0

# executable name (ie, pgrep <search_exec_substring>)

search_exec_substring = "nginx"

# pattern as argument for pgrep (ie, pgrep -f <search_cmdline_substring>)

search_cmdline_substring = "n9e server"

有命令行参数用 search_cmdline_substring
没有命令行参数用 search_exec_substring
procstat_lookup_count 在代码里确实是匹配到的PID列表长度

procstat_lookup_count这个指标的结果为0说明没有匹配到对应字符串的进程,你这个不是0说明匹配到了呀

不是的, 你再去你自己环境试试

可以ps aux | grep 你填search_cmdline_substring的进程名 | grep -v grep 看是不是只能搜到一个进程,如果你进程名那个字段还能搜到别的进程,那个结果就是搜到的进程数,就会大于1

好像不是返回进程数目的, 我这个同时监控了nginx的进程, nignx的进程数目多于1个但是返回值是0 ,

看看你的nginx是用什么用户运行的?categraf是用哪个用户运行的?是不是没有权限采集

procstat_lookup_count 是通过过滤条件匹配到的进程的数量