首页 文章

Telegraf - inputs.procstat procstat插件 - 使用命令行模式或用户名

提问于
浏览
0

使用: Telegraf v1.0.1 或更高版本

Telegraf procstat插件的文档:https://github.com/influxdata/telegraf/tree/master/plugins/inputs/procstat

Documentation 下,它说:

procstat插件可用于监视单个进程使用其/ proc数据的系统资源使用情况 .

该插件将根据PID及其进程名称标记进程 .

进程可以通过pid文件,可执行文件名,命令行模式匹配或用户名(按此顺序或优先级)指定 . 当提供可执行文件名以获取pid时,Procstat插件将使用pgrep .

我的自定义配置文件:
/etc/telegraf/telegraf.d/my_custom_process_service-telegraf.conf 包含:

[[inputs.procstat]]
  exe = "."
  prefix = "service_process"

[[inputs.procstat]]
  pid_file = "/var/run/jenkins/jenkins.pid"
  prefix = "service_process"

上述配置根据语法正常工作 .

Question:

文档说明了如何使用 exepid_file ,但它没有举例说明如何使用 command line pattern matchingusername . 如果您知道如何使用它,我可以得到一些例子吗?

1 回答

  • 3

    在源文件中找到此信息:https://github.com/influxdata/telegraf/blob/master/plugins/inputs/procstat/procstat.go(在变量 var sampleConfig = 下)

    ## Must specify one of: pid_file, exe, or pattern
      ## PID file to monitor process
      pid_file = "/var/run/nginx.pid"
    
      ## executable name (ie, pgrep <exe>)
      # exe = "nginx"
      ## pattern as argument for pgrep (ie, pgrep -f <pattern>)
    
      # pattern = "nginx"
      ## user as argument for pgrep (ie, pgrep -u <user>)
      # user = "nginx"
    
      ## override for process_name
      ## This is optional; default is sourced from /proc/<pid>/status
      # process_name = "bar"
    
      ## Field name prefix
      prefix = ""
    
    
      ## comment this out if you want raw cpu_time stats
      fielddrop = ["cpu_time_*"]
    
      ## This is optional; moves pid into a tag instead of a field
      pid_tag = false
    

相关问题