From be857c174e7fe3a442b45514439beeb7e538a276 Mon Sep 17 00:00:00 2001 From: Stefan Kalscheuer Date: Fri, 21 Jun 2024 17:06:00 +0200 Subject: [PATCH] 17237 FIX check_mk_agent.openwrt: resolve issue when hostname command unavailable Built-in BusyBox shell in OpenWRT has no `hostname` command available per default. While it can be added with additional packages in custom images there are alternative ways to determine the machine's hostname without introducing an additional dependency. This werk uses one of those alternatives. Closes: #721 Change-Id: Ib05f837151f02942077a5b405dab966e7f4f9318 --- .werks/17237.md | 17 +++++++++++++++++ agents/check_mk_agent.openwrt | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 .werks/17237.md diff --git a/.werks/17237.md b/.werks/17237.md new file mode 100644 index 00000000000..afbf75506cb --- /dev/null +++ b/.werks/17237.md @@ -0,0 +1,17 @@ +[//]: # (werk v2) +# check_mk_agent.openwrt: resolve issue when hostname command unavailable + +key | value +---------- | --- +date | 2024-11-08T07:14:01+00:00 +version | 2.3.0p21 +class | fix +edition | cre +component | checks +level | 1 +compatible | yes + +Built-in BusyBox shell in OpenWRT has no `hostname` command available per default. +While it can be added with additional packages in custom images there are alternative +ways to determine the machine's hostname without introducing an additional dependency. +This werk uses one of those alternatives. diff --git a/agents/check_mk_agent.openwrt b/agents/check_mk_agent.openwrt index 05faf11dcee..96be8a0e33e 100755 --- a/agents/check_mk_agent.openwrt +++ b/agents/check_mk_agent.openwrt @@ -272,7 +272,7 @@ section_checkmk() { echo "<<>>" echo "Version: 2.3.0p21" echo "AgentOS: openwrt" - echo "Hostname: $(hostname)" + echo "Hostname: $(cat /proc/sys/kernel/hostname)" echo "AgentDirectory: ${MK_CONFDIR}" echo "DataDirectory: ${MK_VARDIR}" echo "SpoolDirectory: ${SPOOLDIR}" @@ -857,7 +857,7 @@ section_veritas_vcs() { # Secure mode must be off to allow root to execute commands if [ -x /opt/VRTSvcs/bin/haclus ]; then echo "<<>>" - vcshost=$(hostname | cut -d. -f1) + vcshost=$(cut -d. -f1