From aefb22ed23f7360ed5a60f5e02e372481feeca0f 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..606c027420f --- /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.4.0b1 +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 f95a9433bfc..5b2b9314a47 100755 --- a/agents/check_mk_agent.openwrt +++ b/agents/check_mk_agent.openwrt @@ -354,7 +354,7 @@ section_checkmk() { echo "<<>>" echo "Version: 2.4.0b1" echo "AgentOS: openwrt" - echo "Hostname: $(hostname)" + echo "Hostname: $(cat /proc/sys/kernel/hostname)" echo "AgentDirectory: ${MK_CONFDIR}" echo "DataDirectory: ${MK_VARDIR}" echo "SpoolDirectory: ${SPOOLDIR}" @@ -948,7 +948,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