flashcatcloud / categraf

one-stop telemetry collector for nightingale
https://flashcat.cloud/docs/
MIT License
824 stars 253 forks source link

v0.3.70 收集多进程后,CPU占用高 #982

Open jc1981 opened 3 months ago

jc1981 commented 3 months ago

我使用的版本 ./categraf --version v0.3.70-beda1a1c68e37273f26697f374cc1e9085eb4d76

现对php-fpm进程监控,配置如下

php-fpm

[[instances]] search_cmdline_substring = "php-fpm" gather_more_metrics = [ "cpu", "mem" ]

我的php-fpm进程默认开启120个,机器的配置为2C4G的服务器

开启php-fpm进程监控后,categraf 进程长期占用率在 100%,偿试关了CPU或内存的收集,占用没有显示的改善; 我改php-fpm进程改为 20后,categraf 占用的CPU 大概在20%左右;

服务器上也部署了旧版的 n9e-collector 2.7.2 也对php-fpm进行监控,CPU等,没有太多的占用;

categraf 在收集进程这方面是否还有优化的空间

jc1981 commented 3 months ago

我安装了旧版本的3.60 好像没这个问题,我先用旧版的categraf 吧

kongfei605 commented 3 months ago

我安装了旧版本的3.60 好像没这个问题,我先用旧版的categraf 吧

用了正则提取?

zzmark commented 3 months ago

0.3.61 引入的 md5 ,https://github.com/flashcatcloud/categraf/pull/887 此功能对于 php-fpm 这种一下子上百的进程,消耗很大 这个功能没有做开关,有性能问题先回退到0.3.60使用。

下图版本 0.3.70,测试条件

php-fpm 进程数600
./categraf --debug --test --inputs procstat > /dev/null &
interval = 5

image

@kongfei605 @jc1981

kongfei605 commented 3 months ago

看来只是之前的PR 导致的, 感谢 @zzmark

zzmark commented 3 months ago

看来只是之前的PR 导致的, 感谢 @zzmark

修正起来倒是挺简单。在Gather里加个局部cache让文件不要重复计算md5就行

顺手测了下,需要的话我提个pr

kongfei605 commented 3 months ago

看来只是之前的PR 导致的, 感谢 @zzmark

修正起来倒是挺简单。在Gather里加个局部cache让文件不要重复计算md5就行

顺手测了下,需要的话我提个pr

欢迎,除了主动清理,cache过期时间的设置值得思考。

zzmark commented 3 months ago

欢迎,除了主动清理,cache过期时间的设置值得思考。

PR: https://github.com/flashcatcloud/categraf/pull/985

Gather 刮取内可用的 cache,这样不需要考虑过期时间和清理。 每次Gather,同个 exe 只计算一次 md5Sum。

kongfei605 commented 3 months ago

v0.3.71 已经修复了 @jc1981