Skip to content

Commit e3104af

Browse files
committed
collect mosquitto config when collecting diag info
Signed-off-by: reubenmiller <reuben.d.miller@gmail.com>
1 parent 4866271 commit e3104af

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

configuration/contrib/diag-plugins/07_mosquitto.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -e
33

44
OUTPUT_DIR=""
55
COMMAND=""
6+
TEDGE_CONFIG_DIR=${TEDGE_CONFIG_DIR:-/etc/tedge}
67

78
# Parse arguments
89
while [ $# -gt 0 ]; do
@@ -39,12 +40,33 @@ mosquitto_log() {
3940
fi
4041
}
4142

43+
mosquitto_config() {
44+
if command -V tree >/dev/null >&2; then
45+
tree /etc/mosquitto > "$OUTPUT_DIR/etc_mosquitto.tree.txt" ||:
46+
fi
47+
48+
mkdir -p "$OUTPUT_DIR/mosquitto"
49+
if [ -f /etc/mosquitto/mosquitto.conf ]; then
50+
cp -aR /etc/mosquitto/mosquitto.conf "$OUTPUT_DIR/mosquitto" ||:
51+
fi
52+
if [ -d /etc/mosquitto/conf.d ]; then
53+
cp -aR /etc/mosquitto/conf.d "$OUTPUT_DIR/mosquitto/" ||:
54+
fi
55+
56+
mkdir -p "$OUTPUT_DIR/tedge"
57+
cp -aR "$TEDGE_CONFIG_DIR/mosquitto-conf" "$OUTPUT_DIR/tedge/" ||:
58+
59+
# sanitize password fields
60+
find "$OUTPUT_DIR" -name "*.conf" -exec sed -i 's/password\s*.*/password <redacted>/g' {} \; ||:
61+
}
62+
4263
collect() {
4364
if command -V mosquitto > /dev/null 2>&1; then
4465
if command -V journalctl >/dev/null 2>&1; then
4566
mosquitto_journal
4667
fi
4768
mosquitto_log
69+
mosquitto_config
4870
else
4971
echo "mosquitto not found" >&2
5072
# this plugin is not applicable when mosquitto doesn't exist

tests/RobotFramework/tests/tedge/diag/predefined_plugins.robot

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ Test Tags theme:troubleshooting theme:cli theme:plugins
6565
${log_names}= Create List
6666
... output.log
6767
... mosquitto.log
68+
... mosquitto/mosquitto.conf
69+
... mosquitto/conf.d/mosquitto.conf
6870
... mosquitto-journal.log
71+
... tedge/mosquitto-conf/tedge-mosquitto.conf
72+
... tedge/mosquitto-conf/c8y-bridge.conf
6973
FOR ${log_name} IN @{log_names}
7074
File Size Is Not Zero ${log_name}
7175
END

0 commit comments

Comments
 (0)