Trying to add all linux processes to telegraf via inputs.exec - no data is seen

i have a need to watch over all the processes on the linux server via the output of ps aux.
for that i have created a inputs.exec and an output.file (to test the outcome of the inputs):
files = [“stdout”, “/tmp/metrics.out”]
data_format = “json”
commands = [ “/bin/bash /opt/processes.bash” ]
timeout = "5s"
data_format = “json”

gIflux:/var/log# cat /opt/processes.bash

/bin/ps -elf| /usr/bin/jq -sR '[sub("\n$";"") | splits("\n") | sub("^ +";"") | [splits(" +")]] | .[0] as $header | .[1:] | [.[] | [. as $x | range($header | length) | {"key": $header[.], "value": $x[.]}] | from_entries]'
## line to test when the script is running
echo "$(whoami) $(/bin/date '+%Y-%m-%d_%H:%M:%S')" >> /tmp/mytest.txt

i dont see any error in the syslog.
i can see that the /opt/processes.bash is running every 10 sec.

i cannot find the ps data in the /tmp/metrics.out.

What am i missing?

Below is a sample of the json the script creates :

“USER”: “root”,
“PID”: “1”,
"%CPU": “0.0”,
"%MEM": “0.1”,
“VSZ”: “128180”,
“RSS”: “6896”,
“TTY”: “?”,
“STAT”: “Ss”,
“START”: “Jan07”,
“TIME”: “0:06”,
“COMMAND”: “/usr/lib/systemd/systemd”
“USER”: “root”,
“PID”: “2”,
"%CPU": “0.0”,
"%MEM": “0.0”,
“VSZ”: “0”,
“RSS”: “0”,
“TTY”: “?”,
“STAT”: “S”,
“START”: “Jan07”,
“TIME”: “0:00”,
“COMMAND”: “[kthreadd]”

The JSON data format requires at least one numeric value to use as a field value, strings can only be added as tags using the tag_keys option.

1 Like

I decided to go with the influx form.
was easier to create a hash and upload it.