From d133b38bba32467b34d87c7245dcd9cba40bad8a Mon Sep 17 00:00:00 2001 From: Mike Degatano Date: Tue, 10 May 2022 13:24:05 -0400 Subject: [PATCH] Add debug option to mosquitto (#2477) * Add debug option to mosquitto for issues * Pass debug option to tempio and add translation * log_type not 'log type' --- mosquitto/CHANGELOG.md | 4 ++++ mosquitto/DOCS.md | 4 ++++ mosquitto/config.yaml | 3 ++- mosquitto/rootfs/etc/cont-init.d/mosquitto.sh | 1 + mosquitto/rootfs/usr/share/tempio/mosquitto.gtpl | 6 +++++- mosquitto/translations/en.yaml | 4 ++++ 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/mosquitto/CHANGELOG.md b/mosquitto/CHANGELOG.md index 390bbccca80..d834a725316 100644 --- a/mosquitto/CHANGELOG.md +++ b/mosquitto/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 6.1.2 + +- Add debug option to help with issues + ## 6.1.1 - Don't purge openssl in cleanup diff --git a/mosquitto/DOCS.md b/mosquitto/DOCS.md index 0c6c24e43b1..3903c9bd21a 100644 --- a/mosquitto/DOCS.md +++ b/mosquitto/DOCS.md @@ -80,6 +80,10 @@ A file containing the private key. Place this file in the Home Assistant `ssl` f If set to `true` encryption will be enabled using the cert- and keyfile options. +### Option: `debug` + +If set to `true` turns on debug logging for mosquitto and its auth plugin. This an help when tracking down an issue however running with this long term is not recommended as sensitive information will be logged. + ## Home Assistant user management This add-on is attached to the Home Assistant user system, so MQTT clients can make use of these credentials. Local users may also still be set independently within the configuration options for the add-on. For the internal Home Assistant ecosystem, we register `homeassistant` and `addons`, so these may not be used as user names. diff --git a/mosquitto/config.yaml b/mosquitto/config.yaml index f4908315cd3..50cac623345 100644 --- a/mosquitto/config.yaml +++ b/mosquitto/config.yaml @@ -1,5 +1,5 @@ --- -version: 6.1.1 +version: 6.1.2 slug: mosquitto name: Mosquitto broker description: An Open Source MQTT broker @@ -42,6 +42,7 @@ schema: customize: active: bool folder: str + debug: bool? services: - mqtt:provide startup: system diff --git a/mosquitto/rootfs/etc/cont-init.d/mosquitto.sh b/mosquitto/rootfs/etc/cont-init.d/mosquitto.sh index 7ffc0f1f400..56b59c8adf2 100644 --- a/mosquitto/rootfs/etc/cont-init.d/mosquitto.sh +++ b/mosquitto/rootfs/etc/cont-init.d/mosquitto.sh @@ -79,6 +79,7 @@ bashio::var.json \ keyfile "${keyfile}" \ require_certificate "^$(bashio::config 'require_certificate')" \ ssl "^${ssl}" \ + debug "^$(bashio::config 'debug')" \ | tempio \ -template /usr/share/tempio/mosquitto.gtpl \ -out /etc/mosquitto/mosquitto.conf diff --git a/mosquitto/rootfs/usr/share/tempio/mosquitto.gtpl b/mosquitto/rootfs/usr/share/tempio/mosquitto.gtpl index 89f68eead0f..9c792806409 100644 --- a/mosquitto/rootfs/usr/share/tempio/mosquitto.gtpl +++ b/mosquitto/rootfs/usr/share/tempio/mosquitto.gtpl @@ -1,10 +1,14 @@ protocol mqtt user root log_dest stdout +{{ if .debug }} +log_type all +{{ else }} log_type error log_type warning log_type notice log_type information +{{ end }} persistence true persistence_location /data/ @@ -17,7 +21,7 @@ auth_opt_auth_cache_seconds 300 auth_opt_auth_jitter_seconds 30 auth_opt_acl_cache_seconds 300 auth_opt_acl_jitter_seconds 30 -auth_opt_log_level error +auth_opt_log_level {{ if .debug }}debug{{ else }}error{{ end }} # HTTP backend for the authentication plugin auth_opt_files_password_path /etc/mosquitto/pw diff --git a/mosquitto/translations/en.yaml b/mosquitto/translations/en.yaml index a6bf63f7a1e..3a4523e4f13 100644 --- a/mosquitto/translations/en.yaml +++ b/mosquitto/translations/en.yaml @@ -29,6 +29,10 @@ configuration: name: Customize description: >- See the Documentation tab for more information about these options. + debug: + name: Debug + description: >- + If enabled will turn on debug logging for mosquitto and the auth plugin. network: 1883/tcp: Normal MQTT 1884/tcp: MQTT over WebSocket