CPU Temperature on Windows

I was having a hard time getting my CPU temperature information using MSAcpi_ThermalZoneTemperature… apparently my motherboard doesn’t support it.

So I ended up putting together a little program that uses CoreTemp’s shared memory interface. I relied heavily on a library and sample code put together by Michal Kokorceny from http://74.cz/.

I wanted to make this program available for anybody else that might be having similar problems with MSAcpi_ThermalZoneTemperature. The program is available for download here: http://www.tomk.xyz/k/coretemptelegraf Source code is available here: https://github.com/tkohhh/CoreTempTelegraf

Hopefully this is helpful to somebody!

1 Like

Thank you, @tkohhh

Great to see tools like this shared

Not idea what’s wrong but now Telegraf service refuses to startup.

In the cmd line I can see the data so this is NOT the Core Temp issue

c:\Program Files\telegraf>CoreTempTelegraf
coretemp_cpu,host=BEDAS,cpu=Intel_Core_i5_4670K_(Haswell) cpu_speed=3706,fsb_speed=100,multiplier=37,0,vid=1,13
coretemp_cpu,host=BEDAS,cpu=Intel_Core_i5_4670K_(Haswell),cpu_id=0,core_id=0,unit=C temperature=49
coretemp_cpu,host=BEDAS,cpu=Intel_Core_i5_4670K_(Haswell),cpu_id=0,core_id=1,unit=C temperature=50
coretemp_cpu,host=BEDAS,cpu=Intel_Core_i5_4670K_(Haswell),cpu_id=0,core_id=2,unit=C temperature=54
coretemp_cpu,host=BEDAS,cpu=Intel_Core_i5_4670K_(Haswell),cpu_id=0,core_id=3,unit=C temperature=50

This is what I appended to my telegraf.conf:

commands = ["c:\Program Files\telegraf\CoreTempTelegraf"]
data_format = "influx"

When Telegraf won’t start, that’s usually because there’s a problem in the .conf file(s).

I believe you need spaces to indent the lines below [[inputs.exec]]. I don’t know if it’s picky, but I have two spaces preceeding the “commands” line and the “data_format” line. Try that and see if it works!

I have indentation of two spaces as well. But I’m sure that isn’t the problem.
I also tried to to move it to different (non-C:) drive with no avail.
commands = [ "D:\CoreTempTelegraf" ]

I’m starting thinking this is permission issue of your exe file. Even tho I’m Admin on this PC.

Telegraf starts up just fine if I comment out your three lines.

When I was having permission issues with the program, it wasn’t preventing Telegraf from starting; rather, Telegraf would start but would collect no data from the program.

Can you try adding
timeout = "5s"
below the “data_format” line? I didn’t think that was required, but maybe it is.

So your entry would look like this:

  commands = ["c:\Program Files\telegraf\CoreTempTelegraf"]
  data_format = "influx"
  timeout = "5s"

I just doesn’t work.
I tried to create a conf file with only those 3/4 lines and I call it in cmd line as admin:

C:\Program Files\telegraf>telegraf --test --config CoreTempTelegraf.conf --console
2020-06-19T15:24:01Z I! Starting Telegraf 1.13.3
2020-06-19T15:24:01Z E! [telegraf] Error running agent: Error parsing CoreTempTelegraf.conf, line 2: invalid TOML syntax

But wrong syntax is obviously a non-sense here.
So I tried this as a workaround:

commands = [
  'powershell -Command "D:\CoreTempTelegraf" '
data_format = "influx"

And now getting this:

C:\Program Files\telegraf>telegraf --test --config CoreTempTelegraf.conf --console
2020-06-19T15:28:47Z I! Starting Telegraf 1.13.3
2020-06-19T15:28:48Z E! [inputs.exec] Error in plugin: metric parse error: expected field at 1:103: "coretemp_cpu,host=BEDAS,cpu=Intel_Core_i5_4670K_(Haswell) cpu_speed=3806,fsb_speed=100,multiplier=38,0,vid=1,15"
2020-06-19T15:28:48Z E! [telegraf] Error running agent: One or more input plugins had an error

EDIT: I see it now. It is my locale. My system uses decimal comma, not decimal dot.

So it’s that vid value causing the problem. I believe I can put that value in double quotes so it can be parsed correctly. I should be able to have an update by the end of the day!

First off, thanks for the quick updates :slight_smile:

If a influxdb field is put into quotes, it’s considered a string.

Could you instead reformat the value to use a dot as a decimal mark?

Yes, I was just reading up on that. I’ll have it check for a comma and replace with decimal if it exists. Thanks for your help identifying the issue!

I’ve posted an updated .exe to my site (http://www.tomk.xyz/k/coretemptelegraf) that I believe will fix your problem. Would you mind checking it out and let me know if it’s working?

I declared a local TFormatSettings with a DecimalSeparator as a period, and then used those format settings for the output.

Let me know!

1 Like

IT WORKS :wave:

Thanks for the prompt resolution.

So glad to hear that!!