首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EnhanceIO Telegraf ` `filestat`‘plugin -超级GLOB模式不工作--让telegraf递归地查找所有文件

EnhanceIO Telegraf ` `filestat`‘plugin -超级GLOB模式不工作--让telegraf递归地查找所有文件
EN

Stack Overflow用户
提问于 2017-01-27 20:41:57
回答 1查看 343关注 0票数 0

Telegraf v1.0.1 (git: master 26acdc9231efde105510fe5df3da7519bc4f42f7)

Telegraf服务正在成功运行,sudo service telegraf status显示了telegraf is running [OK]

我正在使用Wavefront的基于SaaS的监控解决方案来显示Telegraf数据或设置其他各种事情(警报、仪表板)。它起作用了。

/etc/telegraf/telegraf.d/*.conf概述:安装Telegraf时,它在/etc/telegraf/telgraf.conf上创建其主配置文件,用户可以将其他配置放在(文件)下。

我有/etc/telegraf/telegraf.d/extra-inputs-plugins.conf,在这个文件中,我有以下内容(正如您看到的,它使用的是filestat输入插件),下面的配置工作如下:

代码语言:javascript
复制
## Telegraf filestat plugin
[[inputs.filestat]]
  files = ["/var/run/*/*.pid","/var/run/*.pid"]

在一些数据库服务器上,我已经安装了EnhanceIO (有关更多信息,请参见此处:https://github.com/stec-inc/EnhanceIO )

一旦安装了EnhanceIO,您将得到如下所示的文件夹结构:

代码语言:javascript
复制
ubuntu@MyTestCluster-1a-db2-i-0cf6u98b136b211ba:~$ find /proc/enhanceio
/proc/enhanceio
/proc/enhanceio/data_cache
/proc/enhanceio/data_cache/config
/proc/enhanceio/data_cache/io_hist
/proc/enhanceio/data_cache/errors
/proc/enhanceio/data_cache/stats
/proc/enhanceio/version

要将telegraf的filestat插件配置为捕捉/查找/proc/enhanceio/data_cache/config文件,我可以在配置中添加该文件或/proc/enhanceio/data_cache/* (但这样做,解决方案就不会具有可伸缩性,也就是说,如果我希望telegraf选择/proc文件夹下的所有文件,怎么办?)

插件文档/评论部分说:

代码语言:javascript
复制
  ## These accept standard unix glob matching rules, but with the addition of
  ## ** as a "super asterisk".

因此,我尝试使用以下配置来查找每个文件(递归):

代码语言:javascript
复制
[[inputs.filestat]]
  files = ["/var/run/*/*.pid","/var/run/*.pid","/proc/*"]

以上结果在我运行时产生了以下输出:$ telegraf --config-directory=/etc/telegraf -test|grep filestat|grep -v '/var/run/'|grep enhance (实际上/proc/enhanceio是一个文件夹)。

代码语言:javascript
复制
> filestat,host=MyTestCluster-1a-db2-i-0cf6u98b136b211ba,file=/proc/enhanceio exists=1i,size_bytes=0i 1485548956000000000

然后,我尝试使用**方法,但是我得到了NOTHING

代码语言:javascript
复制
[[inputs.filestat]]
  files = ["/var/run/*/*.pid","/var/run/*.pid","/proc/**"]

$ telegraf --config-directory=/etc/telegraf -test|grep filestat|grep -v '/var/run/'|grep enhance
2017/01/27 20:31:38 I! Using config file: /etc/telegraf/telegraf.conf
$

我尝试了几乎所有的模式(比如:/proc/enhanceio/*/*/proc/enhanceio/*/**/proc/enhanceio/**/*/proc/enhanceio/**/**),但它只是没有捕捉到/proc/enhanceio树下的任何文件。

为什么filestat插件的超级GLOB模式在我尝试上述模式时根本不起作用?

如何使filestat插件捕获/proc树下的所有文件?

PS:我知道如果我想在那个目录下捕获config文件(就在那个级别),给出/proc/enhanceio/data_cache/*就可以了。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-02-06 17:35:12

根据卡梅隆·斯帕尔对此的评论和测试,她无法用下面的例子再现上述情况,但我在帖子中提到的例子在捕捉超级全球模式方面也是有效的。

根据她的评论,似乎是:/proc is a very special "filesystem" that is actually a "file" mapping to particular kernel parameters and metrics. Glob and path matching may not work in this area as you might expect.

代码语言:javascript
复制
% ls -R /tmp/test
/tmp/test:
enhance/  foo.log

/tmp/test/enhance:
bar.log  nested/

/tmp/test/enhance/nested:
foo.file
then with this config:

[[inputs.filestat]]
  files = ["/tmp/test/**.log", "/tmp/test/**.file"]
  ## If true, read the entire file and calculate an md5 checksum.
  md5 = false
I was able to find all files

% telegraf --config ~/gd/ws/telegraf.conf --input-filter filestat --output-filter discard --test
* Plugin: inputs.filestat, Collection 1
> filestat,file=/tmp/test/enhance/bar.log,host=tyrion size_bytes=4i,exists=1i 1485988684000000000
> filestat,file=/tmp/test/foo.log,host=tyrion size_bytes=0i,exists=1i 1485988684000000000
> filestat,file=/tmp/test/enhance/nested/foo.file,host=tyrion exists=1i,size_bytes=0i 1485988684000000000
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41902685

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档