Telegraf Input Exec and Piped command

#1

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:// 192.168.1.21/ISAPI/System/status -s | xml_grep ‘cpuUtilization’ --text_only’: curl: option --text_only: is unknown…

Command works well in CLI :

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

On my telegraf.conf :

[[inputs.exec]]
commands = [“curl --user admin:password http:// 192.168.1.21/ISAPI/System/status -s | xml_grep ‘cpuUtilization’ --text_only”]

name_override = “Hikvision_cpu”

data_format = “value”
data_type = “integer”

#2

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