telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

pgrep pattern matching in procstats.go not working due to improper flag

Open mhiller opened this issue 10 years ago • 5 comments

Bug report

pattern matching does not work on rhel6 w/ pgrep version 3.2.8 due to -f flag not being valid in this version pattern matching is implied.

A solution might be to give an optional override for all pgrep command. This would also be valuable for those that might need to add sudo to pgrep in order for it to work in their environment.

Relevant telegraf.conf:

System info:

telegraf version 0.13.2 OS = rhel 6.3/rhel7 pgrep version - pgrep (procps version 3.2.8)

[Include Telegraf version, operating system name, and other relevant details]

Steps to reproduce:

  1. enable pattern matching .. any pattern will do
  2. check /var/log/telegraf/telegraf.log procstat getting process, exe: [] pidfile: [] pattern: [*] user: [] Failed to execute /usr/bin/pgrep. Error: 'exit status 2'

Expected behavior:

pattern matching works

Actual behavior:

pattern matching does not work and exit code 2 is throw because -f is not valid in this version of pgrep. pattern is implied

mhiller avatar Sep 07 '16 18:09 mhiller

RHEL 6.3 is more than 4 years old....is there a reason you are not upgrading?

sparrc avatar Sep 07 '16 19:09 sparrc

yes infrastructures with 2000+ servers dont update as new versions come out. they do it ether as needed, on support cycle or by attrition. Were ending the last of our rhel5.* boxes now and started on rhel7

mhiller avatar Sep 07 '16 19:09 mhiller

~~so what option does pgrep 3.2.8 take for searching for pattern matching? does it support pattern matching?~~

sparrc avatar Sep 07 '16 19:09 sparrc

it does. it an implied field. I also think being able to define whether sudo is used to execute the command is beneficial. (given the other user permission related tickets). So perhaps a reasonable feature would be to define the path to pgrep yourself . maybe something like

pgrep_command = 'sudo -i -u user /usr/bin/pgrep'

mhiller avatar Sep 07 '16 19:09 mhiller

If you are still having trouble with this, you can use pid_finder = "native".

danielnelson avatar May 29 '20 21:05 danielnelson