# \[inputs.exec\] Error in plugin: exec: exit status 1 for command

**URL:** <https://community.influxdata.com/t/inputs-exec-error-in-plugin-exec-exit-status-1-for-command/14501>\
**Category:** Systems\
**Tags:** telegraf\
**Created:** [May 25, 2020, 2:47pm UTC](https://community.influxdata.com/t/inputs-exec-error-in-plugin-exec-exit-status-1-for-command/14501 "2020-05-25T14:47:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![JanC](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/janc/32/5007_2.png) [@JanC](https://community.influxdata.com/u/JanC)\
**Post date:** [May 25, 2020, 2:47pm UTC](https://community.influxdata.com/t/inputs-exec-error-in-plugin-exec-exit-status-1-for-command/14501/1 "2020-05-25T14:47:42Z")

</div>

Hello,  
I’d like to use the [Speed Test CLI](https://www.speedtest.net/apps/cli) as a `[[inputs.exec]]` but the Telegraf logs tell me:

> May 25 13:45:05 rockpro64 telegraf[4432]: 2020-05-25T13:45:05Z E! [inputs.exec] Error in plugin: exec: exit status 1 for command ‘/usr/bin/speedtest --format json’: ==============================================================================…

My telegraf.conf has the following section:

```
[[inputs.exec]]
  interval = "300s"
  commands = ["/usr/bin/speedtest --format json | jq '{packetLoss: .packetLoss}'"]
  # commands = ["cat /tmp/speedtest.json"]
  timeout = "60s"
  data_format = "json"
  name_suffix = "_speedtest"

```

I tried running the command as `telegraf` and it works correctly (here I added the `echo $?` to double check that the result code is 0)

`sudo -u telegraf /usr/bin/speedtest --format json; echo $?`

I thought that the json format could the problem but if I replace the `inputs.exec` with a simple `cat /tmp/speedtest.json` of a json saved from the command ran manually, it works as expected and all the json values are published to the influxdb output

Any idea why is telegraf reporting that the command exits with a 1 status or how could I debug more?

cheers  
Jan

---

<div class="post-metadata">

**Author:** ![tmdag](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/tmdag/32/4277_2.png) [@tmdag](https://community.influxdata.com/u/tmdag)\
**Post date:** [June 12, 2020, 10:43pm UTC](https://community.influxdata.com/t/inputs-exec-error-in-plugin-exec-exit-status-1-for-command/14501/2 "2020-06-12T22:43:52Z")

</div>

I’m getting exact same error with same command 🙂 . Did you found some work around ?

Cheers!

---

<div class="post-metadata">

**Author:** ![daniel](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/daniel/32/142_2.png) [@daniel](https://community.influxdata.com/u/daniel)\
**Post date:** [June 13, 2020, 12:29am UTC](https://community.influxdata.com/t/inputs-exec-error-in-plugin-exec-exit-status-1-for-command/14501/3 "2020-06-13T00:29:49Z")

</div>

I think this is probably due to the shell pipeline in the command, if you want to use these types of constructs you need to run the command in a shell explicitly:

```auto
commands = ['sh -c "echo foo bar=1 | cat"']

```

I do find it a bit easier to parse this command using the `--csv` flag, here is what I have been doing:

```auto
[[inputs.exec]]
  name_override = "speedtest"
  interval = "1h"
  timeout = "30s"
  commands=["speedtest --csv"]
  csv_column_names = ["server_id", "sponsor", "server_name", "timestamp", "distance", "ping", "download", "upload", "share", "ip_address"]
  csv_column_types = ["string", "string", "string", "string", "float", "float", "float", "float", "string", "string"]
  csv_timestamp_column = "timestamp"
  csv_timestamp_format = "2006-01-02T15:04:05.000000Z"
  csv_tag_columns = ["ip_address", "server_name"]
  data_format = "csv"

```

---

<div class="post-metadata">

**Author:** ![JanC](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/janc/32/5007_2.png) [@JanC](https://community.influxdata.com/u/JanC)\
**Post date:** [June 20, 2020, 5:18am UTC](https://community.influxdata.com/t/inputs-exec-error-in-plugin-exec-exit-status-1-for-command/14501/4 "2020-06-20T05:18:53Z")

</div>

Hi,  
sorry for the late answer. I eventually found out the it was indeed the command itself that was failing.

`sudo -u telegraf /usr/bin/speedtest` worked fine but not

```auto
sudo su - telegraf
/usr/bin/speedtest

```

The speedtest commands is looking for a file in `~/.config/ookla/speedtest-cli.json` that was not present.

Now for the telegraf part, I believe it would be really helpful to see the error output in the telegraf logs when the command fails. It would have saved me quite some time.

cheers  
Jan

---

<div class="post-metadata">

**Author:** ![JanC](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/janc/32/5007_2.png) [@JanC](https://community.influxdata.com/u/JanC)\
**Post date:** [June 20, 2020, 5:28am UTC](https://community.influxdata.com/t/inputs-exec-error-in-plugin-exec-exit-status-1-for-command/14501/5 "2020-06-20T05:28:20Z")

</div>

On more thing related to the speedtest command (and unrelated to my original question) . The json output `bandwidth` values are in bits per second:

```auto
{
  "download": {
    "bandwidth": 116566437,
    "bytes": 1501215368,
    "elapsed": 14607
  },
  "upload": {
    "bandwidth": 6050120,
    "bytes": 85190976,
    "elapsed": 15013
  }
}

```

but I wanted to have them in Mbps so I transform them json using `jq`

```auto
#! /bin/bash

/usr/bin/speedtest --format json | jq '.download.bandwidth = .download.bandwidth / 125000 | .upload.bandwidth = .upload.bandwidth / 125000'

{
  "type": "result",
  "timestamp": "2020-05-25T13:55:18Z",
  "ping": {
    "jitter": 3.928,
    "latency": 25.169
  },
  "download": {
    "bandwidth": 932.531496,
    "bytes": 1501215368,
    "elapsed": 14607
  },
  "upload": {
    "bandwidth": 48.40096,
    "bytes": 85190976,
    "elapsed": 15013
  }
}

```

I have the above script in my `speedtest.sh` that I call from Telegraf:

```auto
[[inputs.exec]]
  commands = [
    "/home/rock64/speedtest.sh"
    ]

```

Hope it helps  
Jan

---

<div class="post-metadata">

**Author:** ![darox](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/darox/32/2073_2.png) [@darox](https://community.influxdata.com/u/darox)\
**Post date:** [July 23, 2020, 12:42pm UTC](https://community.influxdata.com/t/inputs-exec-error-in-plugin-exec-exit-status-1-for-command/14501/6 "2020-07-23T12:42:56Z")

</div>

I am hitting the same problem but I run the docker image of telegraf. I can manually execute the speedtest binary, but for some reason telegraf isn’t running it.

---

<div class="post-metadata">

**Author:** ![prlombaard](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/prlombaard/32/5690_2.png) [@prlombaard](https://community.influxdata.com/u/prlombaard)\
**Post date:** [October 1, 2020, 7:54am UTC](https://community.influxdata.com/t/inputs-exec-error-in-plugin-exec-exit-status-1-for-command/14501/7 "2020-10-01T07:54:06Z")

</div>

Getting the same problem as the previous persons. I can run the whole /usr/bin/speedtest -f json-pretty from outside of my docker container using either the root or telegraf user. I’ve giving and created the correct .config folders inside of the container. It returns JSON string without issue. But if Telegraf runs this then it returns with exit code 1.

It would be nice to get more debug data on what’s been output when the error occurs.

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [October 9, 2020, 2:51pm UTC](https://community.influxdata.com/t/inputs-exec-error-in-plugin-exec-exit-status-1-for-command/14501/8 "2020-10-09T14:51:34Z")

</div>

Hello @prlombaard,  
Have you tried setting `debug=True` in the agent portion of your telegraf config?
