Telegraf Input Exec and Piped command


Hy everyone i try to use this “piped command” on the exec input :

but i have this error :

2018-04-04T12:53:50Z E! Error in plugin [inputs.exec]: exec: exit status 2 for command ‘curl --user admin:password http:// -s | xml_grep ‘cpuUtilization’ --text_only’: curl: option --text_only: is unknown…

Command works well in CLI :

[root@influxDB ~]# curl --user admin:password http:// -s | xml_grep ‘cpuUtilization’ --text_only

On my telegraf.conf :

commands = [“curl --user admin:password http:// -s | xml_grep ‘cpuUtilization’ --text_only”]

name_override = “Hikvision_cpu”

data_format = “value”
data_type = “integer”


Telegraf doesn’t support pipes in the exec input.

You can add your command to a shell script and execute that instead. Make sure that you set the permissions on the script so that the telegraf user can execute them.

1 Like