-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inputs.exec is not working,but test is working #4465
Comments
Why not use the [[inputs.procstat]]
## executable name (ie, pgrep <exe>)
# exe = "pm"
## pattern as argument for pgrep (ie, pgrep -f <pattern>)
pattern = "pm " I believe you can use a processor to selectively ignore fields/tags that you don't feel like you want. |
Advice to try procstat is good, but read on if you want to debug why the script is failing. It looks like it is working when you run with You should be able to more closely replicate the environment like so:
I'm going to guess the issue is that you can't write to the current directory |
@glinton Thank you, but the procstat input plugin can monitor one process only ? We want to monitor multiple processes. |
@danielnelson Thank you~ And I try this, but test ok .
|
By defining |
The home directory for the telegraf/scripts/post-install.sh Line 32 in 6e245b5
What does is the output of these commands?
|
@danielnelson |
Hmm, well I'm not sure why you don't get something like this:
But the fix should be simple, use the tmp directory for scratch space and don't echo if the values are not found.:
You should probably try using procstat too like @glinton suggested. |
@danielnelson Thank you ! I will try using procstat to monitor multiple processes. |
We find that procstat write to influxdb one process data per second, but we want to monitor processes "java -Dmumble.app.name=pm-cp" and "java -Dmumble.app.name=pm-sc", and so on. Each process data is not continuous , the more process, the more interval .
1532681396000000000 24279 java |
Set [[inputs.procstat]]
pattern = "pm-cp"
[[inputs.procstat]]
pattern = "pm-sc" If the number of processes is completely dynamic then we don't have a good solution for telling them apart right now. |
Relevant telegraf.conf:
[[inputs.exec]]
commands = [
"/data/telegraf/top2influxdb.sh"
]
[Include Telegraf version, operating system name, and other relevant details]
Steps to reproduce:
[centos telegraf]$ telegraf --config-directory=/etc/telegraf --test --input-filter=exec
2018/07/25 14:48:58 I! Using config file: /etc/telegraf/telegraf.conf
2018-07-25T06:50:58Z E! Error in plugin [inputs.exec]: metric parsing error, reason: [missing field value], buffer: [multi_proc,tag=tagvalue pm_cpu%!=(MISSING),pm_mem%!=(MISSING)], index: [38]
write to influxdb failed!
Expected behavior:
write to influxdb
Actual behavior:
write to influxdb failed!
the script top2influxdb.sh:
pm_pid=
ps -ef|grep "pm "|grep -v grep|awk '{print $2}'
top -n 1 -d 1 -b|grep java > total_top
pm_cpu_percent=
awk '$1 == "'$pm_pid'" { print $9}' total_top
pm_mem_percent=
awk '$1 == "'$pm_pid'" { print $10}' total_top
echo "multi_proc,tag=tagvalue pm_cpu%=$pm_cpu_percent,pm_mem%=$pm_mem_percent"
[centos telegraf]$ sh top2influxdb.sh
multi_proc,tag=tagvalue pm_cpu%=0.0,pm_mem%=10.1
The text was updated successfully, but these errors were encountered: