# Inputs.exec not creating data

**URL:** <https://community.influxdata.com/t/inputs-exec-not-creating-data/10644>\
**Category:** Telegraf\
**Tags:** influxdb, telegraf\
**Created:** [July 23, 2019, 2:27pm UTC](https://community.influxdata.com/t/inputs-exec-not-creating-data/10644 "2019-07-23T14:27:52Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![tkohhh](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/tkohhh/32/8301_2.png) [@tkohhh](https://community.influxdata.com/u/tkohhh)\
**Post date:** [July 23, 2019, 2:27pm UTC](https://community.influxdata.com/t/inputs-exec-not-creating-data/10644/1 "2019-07-23T14:27:52Z")

</div>

Hi all, I recently built a pfSense router, and installed the Telegraf package to write metrics to my InfluxDB. However, the base Telegraf package for pfSense does not have a measurement for CPU Temperature. So, I figured I could add an inputs.exec entry to the “additional configuration for Telegraf” box.

Here’s what I entered:

```
[[inputs.exec]]
  commands = ["sysctl -n dev.cpu.0.temperature | tr -d 0.C"]
  name_override = "cpu_temp"
  timeout = "5s"
  data_format = "influx"
  [inputs.exec.tags]
    cpu = "cpu0"
```

However, this does not result in a new measurement. As far as I can tell, it’s doing nothing. I know that user account access can be an issue, but as far as I can tell there is only one user on my pfSense, and that user has full administrator access.  
Can anyone point me in the right direction?

---

<div class="post-metadata">

**Author:** ![glinton](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@glinton](https://community.influxdata.com/u/glinton)\
**Post date:** [July 23, 2019, 2:51pm UTC](https://community.influxdata.com/t/inputs-exec-not-creating-data/10644/2 "2019-07-23T14:51:57Z")

</div>

The reason there is no measurement, is because you have the wrong [`data_format`](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md). Set it to [`value`](https://github.com/influxdata/telegraf/tree/master/plugins/parsers/value) and then set `data_type=integer` (unless you change your `tr` to `tr -d C`, in which case you would set the `data_type` to `float`)

---

<div class="post-metadata">

**Author:** ![tkohhh](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/tkohhh/32/8301_2.png) [@tkohhh](https://community.influxdata.com/u/tkohhh)\
**Post date:** [July 23, 2019, 4:05pm UTC](https://community.influxdata.com/t/inputs-exec-not-creating-data/10644/3 "2019-07-23T16:05:33Z")

</div>

This makes perfect sense… I was a little confused about the data\_format, and this clears that up. Also, thank you for your note about the tr command. I did choose to trim 0.C because it appears those values are always whole numbers, however it occurred to me that if it ever returned a decimal value, my command would no longer work. I think I will change it to trim off only the C, and set the data\_type to float.

With that said, I’ve made the suggested changes and restarted pfSense, but unfortunately the measurement is still not showing up. Seems like there must be something else wrong.

Are there any logs in pfSense that might tell me what is happening? I looked around in the system log, but I didn’t see anything.

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![glinton](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@glinton](https://community.influxdata.com/u/glinton)\
**Post date:** [July 23, 2019, 4:32pm UTC](https://community.influxdata.com/t/inputs-exec-not-creating-data/10644/4 "2019-07-23T16:32:55Z")

</div>

Can you ssh into your box and run telegraf manually pointing at this config:

```plaintext
[[outputs.file]]

[[inputs.exec]]
  commands = ["sysctl -n dev.cpu.0.temperature | tr -d C"]
  name_override = "cpu_temp"
  timeout = "5s"
  data_format = "value"
  data_type = "float"
  [inputs.exec.tags]
    cpu = "cpu0"

```

If there is output that looks like the following, then you just need to debug your configured output:

```auto
cpu_temp,cpu="cpu0" cpu_temp=41.0 123498762134

```

Regarding logging, it depends on your config file. I’m not sure where pfsense’s telegraf config has the logs going to. I manually installed telegraf on my pfsense box. [This telegraf issue](https://github.com/influxdata/telegraf/issues/5665) has some good conversation regarding telegraf on pfsense.

---

<div class="post-metadata">

**Author:** ![tkohhh](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/tkohhh/32/8301_2.png) [@tkohhh](https://community.influxdata.com/u/tkohhh)\
**Post date:** [July 23, 2019, 5:02pm UTC](https://community.influxdata.com/t/inputs-exec-not-creating-data/10644/5 "2019-07-23T17:02:10Z")

</div>

Thanks, I’ll give this a try when I get home tonight. If you can point me in the right direction for how to run telegraf manually from the shell, that would be helpful! However, I’m sure I can google my way there if I need to!

Thanks again, you’ve been very helpful!

---

<div class="post-metadata">

**Author:** ![glinton](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@glinton](https://community.influxdata.com/u/glinton)\
**Post date:** [July 23, 2019, 5:17pm UTC](https://community.influxdata.com/t/inputs-exec-not-creating-data/10644/6 "2019-07-23T17:17:45Z")

</div>

If telegraf is in your path (should be after either manual `pkgadd` or pfsense gui install), you simply call it: `telegraf --config /path/to/your/config` ctrl-c to end the process.

---

<div class="post-metadata">

**Author:** ![tkohhh](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/tkohhh/32/8301_2.png) [@tkohhh](https://community.influxdata.com/u/tkohhh)\
**Post date:** [July 24, 2019, 4:30am UTC](https://community.influxdata.com/t/inputs-exec-not-creating-data/10644/7 "2019-07-24T04:30:52Z")

</div>

Well, I ran telegraf manually per your instructions (thank you again for that!), and the result is the following error:

```
Error in plugin [inputs.exec]: exec: exit status 4 for command 'sysctl -n dev.cpu.0.temperature | tr -d C': sysctl: unknown oid '|'...
```

Google isn’t yielding much for “telegraf inpus.exec exit status 4”… any ideas?

---

<div class="post-metadata">

**Author:** ![MarcV](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/marcv/32/7676_2.png) [@MarcV](https://community.influxdata.com/u/MarcV)\
**Post date:** [July 24, 2019, 4:22pm UTC](https://community.influxdata.com/t/inputs-exec-not-creating-data/10644/8 "2019-07-24T16:22:44Z")

</div>

Hi @tkohhh

can you try to put the commands in an executable script , with a shebang and all , and call the script in the inputs.exec plug-in ?The user Telegraf should have execute permissions on that script and you may have to specify the complete path in the commands parameter …

---

<div class="post-metadata">

**Author:** ![tkohhh](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/tkohhh/32/8301_2.png) [@tkohhh](https://community.influxdata.com/u/tkohhh)\
**Post date:** [July 24, 2019, 4:48pm UTC](https://community.influxdata.com/t/inputs-exec-not-creating-data/10644/9 "2019-07-24T16:48:37Z")

</div>

Thanks for the suggestion. I’ll read up on creating scripts and see if I can get that going when I get home tonight!

---

<div class="post-metadata">

**Author:** ![tkohhh](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/tkohhh/32/8301_2.png) [@tkohhh](https://community.influxdata.com/u/tkohhh)\
**Post date:** [July 25, 2019, 1:28am UTC](https://community.influxdata.com/t/inputs-exec-not-creating-data/10644/10 "2019-07-25T01:28:50Z")

</div>

I was able to get this working. Somebody on reddit suggested using sh -c ‘command here’ in the telegraf command block. That worked great, so here is the telegraf.conf entry that I ended up using:

```
[[inputs.exec]]
  commands = ["sh -c 'sysctl -n dev.cpu.0.temperature | tr -d C'"]
  name_override = "cpu_temp"
  timeout = "5s"
  data_format = "value"
  data_type = "float"
  [inputs.exec.tags]
    core = "core0"

[[inputs.exec]]
  commands = ["sh -c 'sysctl -n dev.cpu.1.temperature | tr -d C'"]
  name_override = "cpu_temp"
  timeout = "5s"
  data_format = "value"
  data_type = "float"
  [inputs.exec.tags]
    core = "core1"

[[inputs.exec]]
  commands = ["sh -c 'sysctl -n dev.cpu.2.temperature | tr -d C'"]
  name_override = "cpu_temp"
  timeout = "5s"
  data_format = "value"
  data_type = "float"
  [inputs.exec.tags]
    core = "core2"

[[inputs.exec]]
  commands = ["sh -c 'sysctl -n dev.cpu.3.temperature | tr -d C'"]
  name_override = "cpu_temp"
  timeout = "5s"
  data_format = "value"
  data_type = "float"
  [inputs.exec.tags]
    core = "core3"
```

Thank you both for your help!!!

---

<div class="post-metadata">

**Author:** ![MarcV](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/marcv/32/7676_2.png) [@MarcV](https://community.influxdata.com/u/MarcV)\
**Post date:** [August 1, 2019, 7:26am UTC](https://community.influxdata.com/t/inputs-exec-not-creating-data/10644/11 "2019-08-01T07:26:41Z")

</div>

Tkohhh ,

thank you for this very valuable feedback !
