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

SensorType change in REST API breaks compatibility in 4.0.4 #2788

Closed
wittypluck opened this issue May 17, 2024 · 8 comments · Fixed by #2789
Closed

SensorType change in REST API breaks compatibility in 4.0.4 #2788

wittypluck opened this issue May 17, 2024 · 8 comments · Fixed by #2789

Comments

@wittypluck
Copy link

wittypluck commented May 17, 2024

Describe the bug
There is a Sensor type change in REST API in Glances v4.0.4 which breaks compatibility with previous versions.
I am not sure if this change is wanted, as it is not documented in the changes from v3 to v4 ?

This might be linked to this change which introduces a new SensorType Enum:
#2768

To Reproduce
Steps to reproduce the behavior:

  1. Get sensors in v4.04:
    curl http://localhost:61208/api/4/sensors
  2. Result :
    [{"label":"cpu_thermal 0","unit":"C","value":50,"warning":110,"critical":110,"type":"SensorType.CPU_TEMP","key":"label"}]
  3. Expected :
    [{"label":"cpu_thermal 0","unit":"C","value":50,"warning":110,"critical":110,"type":"temperature_core","key":"label"}]

Expected behavior
THe API should probably return the same type as previous versions, or document the change.

Screenshots
If applicable, add screenshots to help explain your problem.

Environement (please complete the following information)

  • Operating System (lsb_release -a or OS name/version): To be completed with result of: lsb_release -a
  • Glances & psutil versions: To be completed with result of: glances -V
  • How do you install Glances (Pypi package, script, package manager, source): docker
  • Glances test (only available with Glances 3.1.7 or higher):
To be completed with result of: glances --issue

Additional context
Add any other context about the problem here.

You can also pastebin:

@wittypluck wittypluck changed the title SensorType change in REST API breaks compatibilty in 4.0.4 SensorType change in REST API breaks compatibility in 4.0.4 May 17, 2024
@RazCrimson RazCrimson added this to the Glances 4.0.5 milestone May 17, 2024
@RazCrimson
Copy link
Collaborator

@wittypluck
Sorry the issue got auto closed by merging the PR.

The fixes should work fine. But could you just give the dev images a test and see if the data API works fine for you?

@RazCrimson RazCrimson reopened this May 17, 2024
@nicolargo
Copy link
Owner

Fixes work fine:

./venv/bin/python -m glances --stdout-json sensors
sensors: [{"label":"CPU","unit":"C","value":50,"warning":0,"critical":null,"type":"temperature_core","key":"label"},{"label":"Core Pkg","unit":"C","value":52,"warning":100,"critical":100,"type":"temperature_core","key":"label"},{"label":"HDD","unit":"C","value":30,"warning":0,"critical":null,"type":"temperature_core","key":"label"},{"label":"NVME","unit":"C","value":28,"warning":82,"critical":84,"type":"temperature_core","key":"label"},{"label":"SODIMM","unit":"C","value":32,"warning":0,"critical":null,"type":"temperature_core","key":"label"},{"label":"Wifi","unit":"C","value":25,"warning":null,"critical":null,"type":"temperature_core","key":"label"},{"label":"CPU Fan","unit":"R","value":0,"warning":null,"critical":null,"type":"fan_speed","key":"label"},{"label":"Video Fan","unit":"R","value":0,"warning":null,"critical":null,"type":"fan_speed","key":"label"},{"label":"Battery","value":32,"unit":"%","status":"Charging","type":"battery","key":"label"}]
sensors: [{"label":"CPU","unit":"C","value":50,"warning":0,"critical":null,"type":"temperature_core","key":"label"},{"label":"Core Pkg","unit":"C","value":52,"warning":100,"critical":100,"type":"temperature_core","key":"label"},{"label":"HDD","unit":"C","value":30,"warning":0,"critical":null,"type":"temperature_core","key":"label"},{"label":"NVME","unit":"C","value":28,"warning":82,"critical":84,"type":"temperature_core","key":"label"},{"label":"SODIMM","unit":"C","value":32,"warning":0,"critical":null,"type":"temperature_core","key":"label"},{"label":"Wifi","unit":"C","value":25,"warning":null,"critical":null,"type":"temperature_core","key":"label"},{"label":"CPU Fan","unit":"R","value":0,"warning":null,"critical":null,"type":"fan_speed","key":"label"},{"label":"Video Fan","unit":"R","value":0,"warning":null,"critical":null,"type":"fan_speed","key":"label"},{"label":"Battery","value":32,"unit":"%","status":"Charging","type":"battery","key":"label"}]

@wittypluck
Copy link
Author

Great, thanks for the quick fix!

@wittypluck
Copy link
Author

The fix seemed to be included in the 4.0.5 release notes so I tested via my docker install of glances.
The fix works fine on dev tag, but is not present in the 4.0.5 tag or latest tag.
Maybe a packaging issue ?

Tag dev:

$ curl http://localhost:61208/api/4/version
"4.1.0_beta01"
$ curl http://localhost:61208/api/4/sensors
[{"label":"cpu_thermal 0","unit":"C","value":49,"warning":110,"critical":110,"type":"temperature_core","key":"label"}]

Tag latest or 4.0.5:

$ curl http://localhost:61208/api/4/version
"4.0.5"
$ curl http://localhost:61208/api/4/sensors
[{"label":"cpu_thermal 0","unit":"C","value":49,"warning":110,"critical":110,"type":"SensorType.CPU_TEMP","key":"label"}]

@RazCrimson
Copy link
Collaborator

Reproduced

@RazCrimson RazCrimson reopened this May 20, 2024
@nicolargo
Copy link
Owner

Idem with Glances 4.0.6/latest.

@nicolargo
Copy link
Owner

Will be corrected in Glances 4.0.7 (build ongoing)

@wittypluck
Copy link
Author

wittypluck commented May 25, 2024

I can confirm the issue is solved in 4.0.7 and latest docker builds, thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants