Hey,
I’m using telegraf, influxdb and grafana to make a monitoring system for a distributed application. The first thing I want to do is to count the number of java process running on a machine.
But when I make my request, the result are egal to the correct process number or the correct process number + 1.
I’m running centos 7 and Telegraf v1.5.0 (git: release-1.5 a1668bbf)
All Java process I want to count :
[root@localhost ~]# pgrep -f java 10665 10688 10725 10730 11104 11174 16298 22138
My telegraf.conf :
[global_tags]
Configuration for telegraf agent
[agent]
interval = “5s”
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = “0s”
flush_interval = “10s”
flush_jitter = “0s”
precision = “”
debug = true
quiet = false
logfile = “/var/log/telegraf/telegraf.log”
hostname = “my_server”
omit_hostname = false
My input.conf :
Read metrics about disk usagee
[[inputs.disk]]
fielddrop = [ “inodes*” ]
mount_points=[“/”, “/workspace”]File
[[inputs.filestat]]
files = [“myfile.log”]
[[inputs.exec]]Commands array
commands = [“/etc/telegraf/telegraf.d/customScript.sh”]
name_override = “java_process”
data_format = “value”
My /etc/telegraf/telegraf.d/customScript.sh :
#!/bin/bash
ps -aux | grep java | wc -l
I think the problem comes to grep
but I don’t know how resolve this. I tried to use pgrep -f -c java
but the result are same.