Skip to content

Exec

Exec#

Overview#

The ML Pack for Exec collects metrics from any script at a given interval

Config#

1. In your Settings > Configuration Management image

2. Create a new Data Collection image

3. Pick the Exec MLPack template image

4. Edit your template

# Read metrics from one or more commands that can output to stdout
[[inputs.exec]]
  ## Commands array
  commands = ["speedtest -server 911 -json"]
  interval = "300s"
  timeout = "60s"
  name_suffix = "_speedtest"
  data_format = "json"
  json_string_fields = ["server_name", "server_country","server_lat","server_lon"]
  tag_keys = ["server_id"]


# Send metrics to command as input over stdin
[[outputs.exec]]
  command = ["tee", "-a", "/dev/null"]
  timeout = "60s"
  data_format = "json"

We are using a script call speedtest - It make speedtest for a given server - The output is in JSON format.

4. Save your data collection image

5. Inject the script into your telegraf container

$ wget -O speedtest https://github.com/sivel/go-speedtest/releases/download/v0.0.2/speedtest_linux_amd64 speedtest | chmod +x speedtest
$ docker cp speedtest <docker_telegraf_id>:/usr/local/sbin/