pgrep pattern matching in procstats.go not working due to improper flag
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:
- enable pattern matching .. any pattern will do
- 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
RHEL 6.3 is more than 4 years old....is there a reason you are not upgrading?
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
~~so what option does pgrep 3.2.8 take for searching for pattern matching? does it support pattern matching?~~
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'
If you are still having trouble with this, you can use pid_finder = "native".