Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #945, cpu temperature is signed. #965

Merged
merged 4 commits into from
Jun 7, 2018

Conversation

derekmarcotte
Copy link
Contributor

@derekmarcotte derekmarcotte commented Jun 5, 2018

Added a type conversion to cpu temperature sysctl. Will still collect/report -1 when the value is -1, this is because it should be up to interpretation whether this is the correct value for the system or not.

Some drivers will report -1 for cpu temperature. Other sensors will report "an input into the fan control algorithm", i.e. not the actual temperature, but how much fan it wants. Some people cool their machines
with liquid nitrogen.

Closes: #945

Added a type conversion to cpu temperature sysctl.  Will still
collect/report -1 when the value is -1, this is because it should be up
to interpretation whether this is the correct value for the system or
not.

Some drivers will report -1 for cpu temperature.  Other sensors will
report "an input into the fan control algorithm", i.e. not the actual
temperature, but how much fan it wants.  Some people cool their machines
with liquid nitrogen.

Signed-off-by: Derek Marcotte <554b8425@razorfever.net>
@discordianfish
Copy link
Member

LGTM but maybe extend the comment a bit to explain what exactly is going on there?

@SuperQ
Copy link
Member

SuperQ commented Jun 5, 2018

Let's re-arrange this a little so it's easier to understand.

// Temp is a signed integer in centi-degrees Kelvin.
// Cast uint32 to int32 and convert to float64 degrees Celcius.
ch <- c.temp.mustNewConstMetric(float64(int32(temp))/10-273.15, lcpu)

Signed-off-by: Derek Marcotte <554b8425@razorfever.net>
Signed-off-by: Derek Marcotte <554b8425@razorfever.net>
@discordianfish
Copy link
Member

Codespell ftw!

./collector/cpu_freebsd.go:143: Celcius ==> Celsius

But LGTM beside that one.

Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

ch <- c.temp.mustNewConstMetric(float64(temp-2732)/10, lcpu)

// Temp is a signed integer in deci-degrees Kelvin.
// Cast uint32 to int32 and convert to float64 degrees Celcius.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codespell error :-)

./collector/cpu_freebsd.go:143: Celcius  ==> Celsius

Signed-off-by: Derek Marcotte <554b8425@razorfever.net>
@SuperQ SuperQ merged commit 2678d68 into prometheus:master Jun 7, 2018
@derekmarcotte derekmarcotte deleted the dm-fix-#945 branch June 7, 2018 20:41
oblitorum pushed a commit to shatteredsilicon/node_exporter that referenced this pull request Apr 9, 2024
* Fix for prometheus#945, cpu temperature is signed.

Added a type conversion to cpu temperature sysctl.  Will still
collect/report -1 when the value is -1, this is because it should be up
to interpretation whether this is the correct value for the system or
not.

Some drivers will report -1 for cpu temperature.  Other sensors will
report "an input into the fan control algorithm", i.e. not the actual
temperature, but how much fan it wants.  Some people cool their machines
with liquid nitrogen.

Signed-off-by: Derek Marcotte <554b8425@razorfever.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants