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: tomk.xyz Source code is available here: GitHub - tkohhh/CoreTempTelegraf: CoreTemp Windows Telegraf Plugin

Hopefully this is helpful to somebody!

1 Like

Thank you, @tkohhh

Great to see tools like this shared

@tkohhh
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:

[[inputs.exec]]
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:

[[inputs.exec]]
  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:

[[inputs.exec]]
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 (tomk.xyz) 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!!

Hello tkohhh,

I am trying to use your tool and unfortunately I get an error message when starting Telegraf.
I have inserted the passage in the telegraf-conf. your tool also outputs the correct values. But when I run telegraf I get the error: “Error parsing data: line 253: invalid TOML syntax”.

Do you know where my problem is?

I don’t know exactly, but can you try a test config file with just the [[inputs.exec]] section? I’m wondering if the incorrect TOML is in another section of your file.

thank you very much for the quick reply.

I was not sure if I understood you correctly, so 2 variants with unfortunately the same result:

  1. .conf only with the exec part
  2. .conf output part + input only exec.

Error pattern unfortunately unchanged.

1.:

…any idea?

Ahhh, I wonder if it’s your text file. I don’t think the file will save correctly with Notepad. Can you download/install Notepad++, and then create a new file with UTF8 encoding and Unix format end of line (EOL). Then you should be able to add the [[inputs.exec]] section and it should work!

sorry. witch of these options do i have to choose to convert?

That’s correct… the only other thing is the EOL:

image