Telegraf无法在Telegraf之外的任何其他进程上收集procstat文件描述符指标

时间:2019-05-23 19:33:19

标签: permissions file-descriptor telegraf-plugins procstat

在运行procstat时,有人知道解决整个telegraf用户权限问题的方法吗? (我的目标是为几个流程/服务获取打开的文件描述符) 当我运行它时,influx不会收集我正在寻找的文件描述符信息pgrep_serviceprocess_num_fds

telegraf配置:

[[inputs.filestat]]
  files = ["/var/run/*/*.pid","/var/run/*.pid"]
[[inputs.procstat]]
  user = "root"
  #pid_file = "/var/run/grafana/grafana-server.pid"
  #systemd_unit = "sshd.service"
  prefix = "pgrep_serviceprocess"
[[outputs.influxdb]]
  url = "http://localhost:8086"
  database = "file"

telegraf用户身份运行时,它实际上无法收集任何数据:

[root@grafana ~]# sudo -u telegraf bash -c 'telegraf -test -config /etc/telegraf/telegraf.d/file.conf' | grep sshd | sed 's/,/\n/g'
2019-05-23T19:26:43Z I! Starting Telegraf 1.10.3
> procstat
host=grafana.bugfocus.com
process_name=sshd
user=root pgrep_serviceprocess_cpu_time_guest=0
pgrep_serviceprocess_cpu_time_guest_nice=0
pgrep_serviceprocess_cpu_time_idle=0
pgrep_serviceprocess_cpu_time_iowait=0
pgrep_serviceprocess_cpu_time_irq=0
pgrep_serviceprocess_cpu_time_nice=0
pgrep_serviceprocess_cpu_time_soft_irq=0
pgrep_serviceprocess_cpu_time_steal=0
pgrep_serviceprocess_cpu_time_stolen=0
pgrep_serviceprocess_cpu_time_system=0.01
pgrep_serviceprocess_cpu_time_user=0.01
pgrep_serviceprocess_cpu_usage=0
pgrep_serviceprocess_involuntary_context_switches=9i
pgrep_serviceprocess_memory_data=0i
pgrep_serviceprocess_memory_locked=0i
pgrep_serviceprocess_memory_rss=4456448i
pgrep_serviceprocess_memory_stack=0i
pgrep_serviceprocess_memory_swap=0i
pgrep_serviceprocess_memory_vms=115462144i
pgrep_serviceprocess_num_threads=1i
pgrep_serviceprocess_voluntary_context_switches=46i
pid=4399i 1558639604000000000

telegraf用户的身份运行root,我得到的pgrep_serviceprocess_num_fds指标还不错。但是,当然,当运行telegraf时,它将以telegraf用户身份运行。对于我来说,这很奇怪,因为procstat模块实际上对收集文件描述符数据毫无用处。除非您以root用户身份运行Telegraf(不好)或添加ACL magic。

[root@grafana ~]# telegraf -test -config /etc/telegraf/telegraf.d/file.conf | grep sshd | sed 's/,/\n/g'
2019-05-23T19:28:46Z I! Starting Telegraf 1.10.3
> procstat
host=grafana.bugfocus.com
process_name=sshd
user=root pgrep_serviceprocess_cpu_time=0i
pgrep_serviceprocess_cpu_time_guest=0
pgrep_serviceprocess_cpu_time_guest_nice=0
pgrep_serviceprocess_cpu_time_idle=0
pgrep_serviceprocess_cpu_time_iowait=0
pgrep_serviceprocess_cpu_time_irq=0
pgrep_serviceprocess_cpu_time_nice=0
pgrep_serviceprocess_cpu_time_soft_irq=0
pgrep_serviceprocess_cpu_time_steal=0
pgrep_serviceprocess_cpu_time_stolen=0
pgrep_serviceprocess_cpu_time_system=0.01
pgrep_serviceprocess_cpu_time_user=0.01
pgrep_serviceprocess_cpu_usage=0
pgrep_serviceprocess_involuntary_context_switches=9i
pgrep_serviceprocess_memory_data=643072i
pgrep_serviceprocess_memory_locked=0i
pgrep_serviceprocess_memory_rss=4456448i
pgrep_serviceprocess_memory_stack=135168i
pgrep_serviceprocess_memory_swap=0i
pgrep_serviceprocess_memory_vms=115462144i
pgrep_serviceprocess_nice_priority=20i
pgrep_serviceprocess_num_fds=5i
pgrep_serviceprocess_num_threads=1i
pgrep_serviceprocess_read_bytes=5218304i
pgrep_serviceprocess_read_count=36691i
pgrep_serviceprocess_realtime_priority=0i
pgrep_serviceprocess_rlimit_cpu_time_hard=2147483647i
pgrep_serviceprocess_rlimit_cpu_time_soft=2147483647i
pgrep_serviceprocess_rlimit_file_locks_hard=2147483647i
pgrep_serviceprocess_rlimit_file_locks_soft=2147483647i
pgrep_serviceprocess_rlimit_memory_data_hard=2147483647i
pgrep_serviceprocess_rlimit_memory_data_soft=2147483647i
pgrep_serviceprocess_rlimit_memory_locked_hard=65536i
pgrep_serviceprocess_rlimit_memory_locked_soft=65536i
pgrep_serviceprocess_rlimit_memory_rss_hard=2147483647i
pgrep_serviceprocess_rlimit_memory_rss_soft=2147483647i
pgrep_serviceprocess_rlimit_memory_stack_hard=2147483647i
pgrep_serviceprocess_rlimit_memory_stack_soft=8388608i
pgrep_serviceprocess_rlimit_memory_vms_hard=2147483647i
pgrep_serviceprocess_rlimit_memory_vms_soft=2147483647i
pgrep_serviceprocess_rlimit_nice_priority_hard=0i
pgrep_serviceprocess_rlimit_nice_priority_soft=0i
pgrep_serviceprocess_rlimit_num_fds_hard=4096i
pgrep_serviceprocess_rlimit_num_fds_soft=1024i
pgrep_serviceprocess_rlimit_realtime_priority_hard=0i
pgrep_serviceprocess_rlimit_realtime_priority_soft=0i
pgrep_serviceprocess_rlimit_signals_pending_hard=14968i
pgrep_serviceprocess_rlimit_signals_pending_soft=14968i
pgrep_serviceprocess_signals_pending=0i
pgrep_serviceprocess_voluntary_context_switches=46i
pgrep_serviceprocess_write_bytes=4374528i
pgrep_serviceprocess_write_count=7509i
pid=4399i 1558639727000000000

0 个答案:

没有答案