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.
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?
The reason there is no measurement, is because you have the wrong data_format. Set it to 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)
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.
If there is output that looks like the following, then you just need to debug your configured output:
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 has some good conversation regarding telegraf on pfsense.
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!
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.
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 …
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: