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

healthcheck command line script #40

Open
cnaslain opened this issue Feb 11, 2023 · 3 comments
Open

healthcheck command line script #40

cnaslain opened this issue Feb 11, 2023 · 3 comments

Comments

@cnaslain
Copy link

cnaslain commented Feb 11, 2023

Hi,

Just found this interesting project to replace the direct connection between my EnOcean dongle and Home Assistant (running in a docker container). I already use a Mosquitto MQTT broker with Zigbee & Zwave. So having a similar gateway is great. My first try with enocean-mqtt works well. Thanks :-)

I have an enhancement request: Would it be possible to add an HTTP endpoint (like /health) to the python project, so it would be possible to configure an healthcheck on the enocean-mqtt container (in docker-compose)?

If not (for any good reason like lightweight, complexity etc.) how is it possible to check the health of enocean-mqtt ?

Regards

Chris

PS: I am not a python developer, but found an example in https://snyk.io/blog/best-practices-containerizing-python-docker/ (section 5). It may help and give some ideas.

@cnaslain cnaslain changed the title healthcheck healthcheck HTTP endpoint Feb 11, 2023
@romor
Copy link
Member

romor commented Feb 12, 2023

I am not sure whether we should introduce an additional http endpoint for health data.

However, we could introduce some mqtt heartbeat message, which gets repeatedly published?

Alternatively, we could subscribe to an mqtt topic where we listen for incoming commands. Such command could be to publish a status/health message or to publish some packet statistics?

@mak-gitdev
Copy link
Contributor

mak-gitdev commented Feb 12, 2023

Hi @romor and @cnaslain,

@romor, I had the idea to propose a mix of your two ideas in a kind of availibility message.
It would be published OK (ON) when connected to the broker, then unavailable (OFF) once enocean-mqtt is stopped (normally or due to an exception).
This would be accessible at <mqtt_prefix>/<topic_name> (may be availability as topic name).

@cnaslain
Copy link
Author

cnaslain commented Feb 12, 2023

Publishing a message into the MQTT broker to test the enocean-mqtt container may be an idea only if this test is executed from a script inside the enocean-mqtt container. A simple command returning 0 if it is ok, and 1 if it is not. The HTTP endpoint was just an idea, but any command line (wget/HTTP, bash script, python script) that can be executed inside the container is ok.

Simple command lines examples from my docker-compose for other services:

[...]
    healthcheck:
      test: ["CMD-SHELL", "mosquitto_sub -h 127.0.0.1 -p 1880 -t 'topic' -C 1 -E -i probe -W 3" ] # for Mosquitto
[...]
    healthcheck:
      test: ["CMD-SHELL", "curl -f http://127.0.0.1:8123"] # for HA
[...]

@cnaslain cnaslain changed the title healthcheck HTTP endpoint healthcheck command line script Feb 12, 2023
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

No branches or pull requests

3 participants