Hi,
I’m trying to get [[inputs.exec]] to execute my command.
telegraf.conf
[agent]
interval = “2s”
round_interval = true
debug = true
quiet = false
[[inputs.exec]]
commands = [ “/disktemp.sh” ]
name_suffix = “_disktemp”
timeout = “5s”
interval = “15s”
data_format = “json”
tag_keys = [“disk”, “model”, “serial”, “capacity”]
[[processors.regex]]
[[processors.regex.tags]]
key = “host”
replacement = “nas”
pattern = “telegraf2”
[[outputs.influxdb_v2]]
urls = [“http://influxdb2:8086”]
token = “”
organization = “my-org”
bucket = “test-bucket”
test run:
$ telegraf -test -input-filter=exec -debug
2022-10-22T15:26:59Z I! Using config file: /etc/telegraf/telegraf.conf
2022-10-22T15:26:59Z I! Starting Telegraf 1.24.2
2022-10-22T15:26:59Z I! Available plugins: 222 inputs, 9 aggregators, 26 processors, 20 parsers, 57 outputs
2022-10-22T15:26:59Z I! Loaded inputs: exec
2022-10-22T15:26:59Z I! Loaded aggregators:
2022-10-22T15:26:59Z I! Loaded processors: regex
2022-10-22T15:26:59Z W! Outputs are not used in testing mode!
2022-10-22T15:26:59Z I! Tags enabled: host=telegraf2
2022-10-22T15:26:59Z D! [agent] Initializing plugins
2022-10-22T15:26:59Z D! [agent] Starting service inputs
2022-10-22T15:27:00Z D! [agent] Stopping service inputs
2022-10-22T15:27:00Z D! [agent] Input channel closed
2022-10-22T15:27:00Z D! [agent] Processor channel closed
2022-10-22T15:27:00Z D! [agent] Stopped Successfully
exec_disktemp,capacity=10000831348736,disk=/dev/sda,host=nas,model=WDC\ WD101EFAX-68LDBN0,serial=xzy temperature=43 1666452420000000000
exec_disktemp,capacity=10000831348736,disk=/dev/sdb,host=nas,model=WDC\ WD101EFAX-68LDBN0,serial=xzy temperature=45 1666452420000000000
exec_disktemp,capacity=10000831348736,disk=/dev/sdc,host=nas,model=WDC\ WD101EFAX-68LDBN0,serial=xzy temperature=45 1666452420000000000
exec_disktemp,capacity=10000831348736,disk=/dev/sdd,host=nas,model=WDC\ WD101EFAX-68LDBN0,serial=xzy temperature=43 1666452420000000000
exec_disktemp,capacity=10000831348736,disk=/dev/sde,host=nas,model=WDC\ WD101EFAX-68LDBN0,serial=xzy temperature=44 1666452420000000000
But it does not execute when I run it in non-test mode:
2022-10-22T15:41:21Z I! Using config file: /etc/telegraf/telegraf.conf
2022-10-22T15:41:21Z I! Starting Telegraf 1.24.2
2022-10-22T15:41:21Z I! Available plugins: 222 inputs, 9 aggregators, 26 processors, 20 parsers, 57 outputs
2022-10-22T15:41:21Z I! Loaded inputs: exec
2022-10-22T15:41:21Z I! Loaded aggregators:
2022-10-22T15:41:21Z I! Loaded processors: regex
2022-10-22T15:41:21Z I! Loaded outputs: influxdb_v2
2022-10-22T15:41:21Z I! Tags enabled: host=telegraf2
2022-10-22T15:41:21Z I! [agent] Config: Interval:2s, Quiet:false, Hostname:“telegraf2”, Flush Interval:10s
2022-10-22T15:41:21Z D! [agent] Initializing plugins
2022-10-22T15:41:21Z D! [agent] Connecting outputs
2022-10-22T15:41:21Z D! [agent] Attempting connection to [outputs.influxdb_v2]
2022-10-22T15:41:21Z D! [agent] Successfully connected to outputs.influxdb_v2
2022-10-22T15:41:21Z D! [agent] Starting service inputs
2022-10-22T15:41:23Z D! [agent] Stopping service inputs
2022-10-22T15:41:23Z D! [agent] Input channel closed
2022-10-22T15:41:23Z D! [agent] Processor channel closed
2022-10-22T15:41:23Z I! [agent] Hang on, flushing any cached metrics before shutdown
2022-10-22T15:41:23Z D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
2022-10-22T15:41:23Z I! [agent] Stopping running outputs
2022-10-22T15:41:23Z D! [agent] Stopped Successfully
2022-10-22T15:41:24Z I! Using config file: /etc/telegraf/telegraf.conf
2022-10-22T15:41:24Z I! Starting Telegraf 1.24.2
2022-10-22T15:41:24Z I! Available plugins: 222 inputs, 9 aggregators, 26 processors, 20 parsers, 57 outputs
2022-10-22T15:41:24Z I! Loaded inputs: exec
2022-10-22T15:41:24Z I! Loaded aggregators:
2022-10-22T15:41:24Z I! Loaded processors: regex
2022-10-22T15:41:24Z I! Loaded outputs: influxdb_v2
2022-10-22T15:41:24Z I! Tags enabled: host=telegraf2
2022-10-22T15:41:24Z I! [agent] Config: Interval:2s, Quiet:false, Hostname:“telegraf2”, Flush Interval:10s
2022-10-22T15:41:24Z D! [agent] Initializing plugins
2022-10-22T15:41:24Z D! [agent] Connecting outputs
2022-10-22T15:41:24Z D! [agent] Attempting connection to [outputs.influxdb_v2]
2022-10-22T15:41:24Z D! [agent] Successfully connected to outputs.influxdb_v2
2022-10-22T15:41:24Z D! [agent] Starting service inputs
2022-10-22T15:41:34Z D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
2022-10-22T15:41:44Z D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
2022-10-22T15:41:54Z D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
I am running telegraf in docker, hence the hostname being telegraf2.
But I for the life of me can’t figure out why it does not execute the inputs.exec.
Any hits would be welcome.