I have the following inputs in my telegraf.conf that go to Grafana. I can get the simpler first 3 examples to work but cannot get the 4th to work.
[[inputs.exec]]
commands = ["sh -c 'grep -i DatasetVersion /etc/aaa/systemnameX/configfile | cut -d'=' -f2'"]
name_override = "systemnameX"
timeout = "5s"
data_format = "value"
data_type = "string"
[inputs.exec.tags]
type = "dataset_version"
[[inputs.exec]]
commands = ["sh -c 'cat /root/config/OS_Version.txt | tr -d C'"]
name_override = "systemnameX"
timeout = "5s"
data_format = "value"
data_type = "string"
[inputs.exec.tags]
type = "os_version"
[[inputs.exec]]
commands = ["sh -c 'grep -i VERSION= /usr/bin/sw_install | head -1 | cut -d'=' -f2 '"]
name_override = "systemnameX"
timeout = "5s"
data_format = "value"
data_type = "string"
[inputs.exec.tags]
type = "sw_version"
[[inputs.exec]]
commands = ["/sbin/ifconfig eth0 | grep 'inet' | cut -d: -f2 | awk '{print $2}'"]
name_override = "systemnameX"
timeout = "5s"
data_format = "value"
data_type = "string"
[inputs.exec.tags]
type = "ip_address"
This is the error when I run the telegraf test
2021-09-04T06:36:51Z E! Error in plugin [inputs.exec]: exec: exit status 1 for command '/sbin/ifconfig eth0 | grep 'inet' | cut -d: -f2 | awk '{print $2}''
and when I put the exact command into a command line I get the following error:
awk: cmd. line:1: {print
awk: cmd. line:1: ^ unexpected newline or end of string
Any help about how to fix the awk part would be greatly appreciated.
cheers, Tara