home-assistant-ecosystem / python-glances-api

Python API for interacting with Glances
MIT License
4 stars 8 forks source link

Containers sections needs update to consume API version 3.4 #18

Open elmigbot opened 1 year ago

elmigbot commented 1 year ago

3.4 puts container information under the "containers" plugin. (3.3 was "docker")

Also, "containers" omits some info, putting specific container data at top level. (i.e. http://localhost:61208/api/3/docker/containers becomes http://localhost:61208/api/3/containers

freeDom- commented 1 year ago

This is a breaking change. It would be great if you could create a PR adding the maximum supported version to the HA documentation.

I don't think that it should be changed atm, because Debian 11 (which HA supports) currently uses Glances 3.2.1 as default. Dont know which v HA OS ships with, but probably the same?

elmigbot commented 1 year ago

I believe most people would be using the glances Add-on from the "Home Assistant Community Add-ons". The Add-on updated to 3.4 in version 0.19 back in May.

https://github.com/hassio-addons/addon-glances/releases/tag/v0.19.0

freeDom- commented 1 year ago

I believe most people would be using the glances Add-on from the "Home Assistant Community Add-ons". The Add-on updated to 3.4 in version 0.19 back in May.

https://github.com/hassio-addons/addon-glances/releases/tag/v0.19.0

I don't think that most people are using the addon, but indeed that is a problem! The addon should not use a version, which is currently not supported, because of API changes.

On the long term I agree that we need to make that change anyways.

In order to not break older versions it is probably best, if it would be configurable by creating an option such as "Use legacy v3 API". Then when data is pulled this is done according to the flag.

elmigbot commented 1 year ago

Maybe just look for http://localhost:61208/api/3/containers, but if not available, then look for http://localhost:61208/api/3/docker/containers?

freeDom- commented 1 year ago

Maybe just look for http://localhost:61208/api/3/containers, but if not available, then look for http://localhost:61208/api/3/docker/containers?

Generally OK and definitely the easy way for implementing, but it would result in two api calls instead of one, slowing everything down unnecessarily and creating more load. Why ask for something when knowing it does not exist?

elmigbot commented 1 year ago

True...

But, if it calls the new and expected API first, then its only one call for the majority of the time. And as time goes by, it becomes less and less likely to make the second call.

The trade-off is a breaking-change VS unnecessary load for a specific and dissappearing scenario. Maybe if the flag defaults to the latest version, it tips the scale toward the flag approach. (Only if the latest is prevalent).

vajonam commented 1 year ago

Can confirm this PR works with latest glances to get the containers information! please pull this in!

LeeThompson commented 1 year ago

I'm running home assistant in a docker container, I don't think I can use the "add on" if I wanted to so... yeah please fix this.

elmigbot commented 1 year ago

True...

But, if it calls the new and expected API first, then its only one call for the majority of the time. And as time goes by, it becomes less and less likely to make the second call.

The trade-off is a breaking-change VS unnecessary load for a specific and dissappearing scenario. Maybe if the flag defaults to the latest version, it tips the scale toward the flag approach. (Only if the latest is prevalent).

...or the integration uses an ALL endpoint rendering this discussion pointless :)

Good job @engrbm87 Thanks @vajonam !

vajonam commented 1 year ago

in the near term,

execute this inside the HA docker container, will need to do this after each update.

cd /usr/local/lib/python3.11/site-packages/glances_api
rm __init__.py
wget https://raw.githubusercontent.com/home-assistant-ecosystem/python-glances-api/0fa529b3c9a10afcdec50b191c559acbeebb6d9f/glances_api/__init__.py
bratanon commented 1 year ago

So #21 is now merged which fixes this issue. Time to close this one?

vajonam commented 1 year ago

not sure how issues are closed, if its done after the release, but I think it can be closed. masted on that merge

LeeThompson commented 11 months ago

I'm still not seeing containers in the docker version of HomeAssistant's "Glances" provider. (I delete the integration and re-add it.) The Glances integration is working, it just doesn't show any docker container information. If I access Glances directly, I see the container information as expected.

HomeAssistant Information:

Version: 2023.11.0 Frontend 20231030.1

I should note I'm using linuxserver.io's docker image: https://hub.docker.com/r/linuxserver/homeassistant The image is linuxserver/homeassistant:latest@sha256:7a307f78e79168bdd6d19a493f08b7646607e45ff22a956c97ae32fe521c8235

The glances image is docker.io/nicolargo/glances:latest@sha256:d79dd333a67008403a8b05dfcd827283b453ebc5732801519a39fa545c9bbb91

vajonam commented 11 months ago

Yeah not sure its been merged in. @bratanon do you know which HA release this will be included in?

freeDom- commented 11 months ago

Yeah not sure its been merged in. @bratanon do you know which HA release this will be included in?

First of all @fabaff would need to release a new version of the Glances API. Afterwards the Glances API version needs to be bumped in the Home Assistant repository before the changes will be applied to the Glances Home Assistant Integration.

vajonam commented 9 months ago

@fabaff , can you please release a version that addresses this? so that HA can then be bumped to use it please?

XtracT commented 9 months ago

Hello!

I assume that now with 0.5.1 released, the only thing missing is to bump the version number here @cohenchris ?:

https://github.com/home-assistant/core/blob/dev/homeassistant/components/glances/manifest.json

engrbm87 commented 9 months ago

Version 0.5.0 already includes provision for 'containers' as well as 'dockers' keys. This is already in the latest HA core.

LeeThompson commented 6 months ago

I'm running HA 2024.3.3 Frontend 20240307.0 (docker) and Glances info is still greatly reduced from what it used to be. For docker data I get the number of active containers, and a summary of CPU and memory usage (for all containers, not individually)