OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • English Forums »
  • Tutorials and FAQs »
  • Getting Telegraf to log CPU temperatures to Influx
« previous next »
  • Print
Pages: [1]

Author Topic: Getting Telegraf to log CPU temperatures to Influx  (Read 9686 times)

MTR

  • Newbie
  • *
  • Posts: 35
  • Karma: 4
    • View Profile
Getting Telegraf to log CPU temperatures to Influx
« on: July 04, 2020, 07:30:22 pm »
Hi,

I was fiddling around with the Telegraf plugin and a TICK-stack server and i thought it would be nice to graph the CPU temperatures as well. But adding [[inputs.temp]] to /usr/local/etc/telegraf.conf throws an error:
Quote
E! [inputs.temp] Error in plugin: plugin is not supported on this platform: not implemented yet
Hm, bummer. So i tried some stuff to get it to work and i came up with a workaround utilizing [[inputs.exec]].

This might or might not work on different systems than the one i'm using but it does work for a Intel i7-4500U CPU. I use this one-liner to get a properly formed output of my cpu temperatures from sysctl (you might need to change this to make it work for your system):
Code: [Select]
sysctl dev.cpu | grep temperature | sed 's/[a-z\.]*/systemp cpu/;s/\.[a-z]*\: /=/;s/.$//'The output looks like this:
Quote
systemp cpu3=47.0
systemp cpu2=47.0
systemp cpu1=46.0
systemp cpu0=46.0

To get it all going:
1) Create /usr/local/etc/telegraf-scripts/cputemp.sh which contains above mentioned one-liner
2) Add these lines to /usr/local/etc/telegraf.conf:
Code: [Select]
[[inputs.exec]]
  commands = [
    "sh /usr/local/etc/telegraf-scripts/cputemp.sh",
  ]
  timeout = "5s"
  data_format = "influx"
3) Restart telegraf: service telegraf restart

That's it. You should now be able to graph your CPU temperatures from the newly created systemp measurement on your Influx server.

Logged

xedmada

  • Newbie
  • *
  • Posts: 1
  • Karma: 1
    • View Profile
Re: Getting Telegraf to log CPU temperatures to Influx
« Reply #1 on: October 07, 2021, 01:22:23 pm »
Thank you for sharing. After discovering your post I made a small adjustment to the sed used in order to output a format setting the cpu# as a feature tag so it more closely matches the existing Telegraf sensors format:

Code: [Select]
sysctl dev.cpu | grep temperature | sed 's/[a-z\.]*/sensors,feature=cpu/;s/\.[a-z]*\: / temp_input=/;s/.$//'
Logged

MTR

  • Newbie
  • *
  • Posts: 35
  • Karma: 4
    • View Profile
Re: Getting Telegraf to log CPU temperatures to Influx
« Reply #2 on: October 12, 2021, 07:37:52 pm »
Nice, thanks!
Logged

bluemorph

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: Getting Telegraf to log CPU temperatures to Influx
« Reply #3 on: November 03, 2024, 01:38:35 am »
still worked like a charm!

Thank you :heart:
Logged

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • English Forums »
  • Tutorials and FAQs »
  • Getting Telegraf to log CPU temperatures to Influx
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2