English Forums > Tutorials and FAQs
Getting Telegraf to log CPU temperatures to Influx
(1/1)
MTR:
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
--- End quote ---
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: ---sysctl dev.cpu | grep temperature | sed 's/[a-z\.]*/systemp cpu/;s/\.[a-z]*\: /=/;s/.$//'
--- End code ---
The output looks like this:
--- Quote ---systemp cpu3=47.0
systemp cpu2=47.0
systemp cpu1=46.0
systemp cpu0=46.0
--- End quote ---
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: ---[[inputs.exec]]
commands = [
"sh /usr/local/etc/telegraf-scripts/cputemp.sh",
]
timeout = "5s"
data_format = "influx"
--- End code ---
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.
xedmada:
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: ---sysctl dev.cpu | grep temperature | sed 's/[a-z\.]*/sensors,feature=cpu/;s/\.[a-z]*\: / temp_input=/;s/.$//'
--- End code ---
MTR:
Nice, thanks!
Navigation
[0] Message Index
Go to full version