Module: check_mk
Branch: master
Commit: a8bf7362eea66531eb4d1cd6232041de4f7fd54a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a8bf7362eea665…
Author: Andreas Umbreit <au(a)mathias-kettner.de>
Date: Thu Jan 31 11:52:32 2019 +0100
6940 FIX Fix OnlyFrom entry in check_mk agent section
Previously, the OnlyFrom entry, that represents the list of
only-from IP entries within the xinetd-configuration,
rendered empty for baked agents.
The cause for this was that the agent was looking for
the service name "check_mk", that only is used by the
raw agent.
The agent is now looking for the right service name set
from the agent bakery, i.e. "check-mk-agent" or a user-specified
name coming from the "name of agent packages" rule.
(Jira: CMK-1540)
Change-Id: I590c7d9f8914923c6e5b3bb12bcab82ed80599f8
---
.werks/6940 | 20 ++++++++++++++++++++
agents/check_mk_agent.linux | 6 +++++-
agents/check_mk_agent.openwrt | 6 +++++-
doc/treasures/agents/check_mk_agent.busybox | 6 +++++-
4 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/.werks/6940 b/.werks/6940
new file mode 100644
index 0000000..dedbd08
--- /dev/null
+++ b/.werks/6940
@@ -0,0 +1,20 @@
+Title: Fix OnlyFrom entry in check_mk agent section
+Level: 1
+Component: agents
+Compatible: compat
+Edition: cee
+Version: 1.6.0i1
+Date: 1548937503
+Class: fix
+
+Previously, the OnlyFrom entry, that represents the list of
+only-from IP entries within the xinetd-configuration,
+rendered empty for baked agents.
+
+The cause for this was that the agent was looking for
+the service name "check_mk", that only is used by the
+raw agent.
+
+The agent is now looking for the right service name set
+from the agent bakery, i.e. "check-mk-agent" or a user-specified
+name coming from the "name of agent packages" rule.
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index cb8ce67..f0fc7f4 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -43,6 +43,10 @@ elif [ "$SSH_CLIENT" ] ; then
export REMOTE=${SSH_CLIENT%% *}
fi
+# The package name gets patched for baked agents to either
+# "check-mk-agent" or the name set by the "name of agent packages"
rule
+XINETD_SERVICE_NAME=check_mk
+
# Make sure, locally installed binaries are found
PATH=$PATH:/usr/local/bin
@@ -369,7 +373,7 @@ echo "LocalDirectory: $LOCALDIR"
if [ -n "$REMOTE_HOST" ]
then
echo -n 'OnlyFrom: '
- sed -n
'/^service[[:space:]]*check_mk/,/}/s/^[[:space:]]*only_from[[:space:]]*=[[:space:]]*\(.*\)/\1/p'
/etc/xinetd.d/* | head -n1; echo
+ sed -n
'/^service[[:space:]]*'$XINETD_SERVICE_NAME'/,/}/s/^[[:space:]]*only_from[[:space:]]*=[[:space:]]*\(.*\)/\1/p'
/etc/xinetd.d/* | head -n1; echo
fi
section_df
diff --git a/agents/check_mk_agent.openwrt b/agents/check_mk_agent.openwrt
index 71d6381..6661bf5 100755
--- a/agents/check_mk_agent.openwrt
+++ b/agents/check_mk_agent.openwrt
@@ -35,6 +35,10 @@ export MK_VARDIR="/var/lib/check_mk_agent"
# Optionally set a tempdir for all subsequent calls
#export TMPDIR=
+# The package name gets patched for baked agents to either
+# "check-mk-agent" or the name set by the "name of agent packages"
rule
+XINETD_SERVICE_NAME=check_mk
+
# Provide information about the remote host. That helps when data
# is being sent only once to each remote host.
if [ "$REMOTE_HOST" ] ; then
@@ -237,7 +241,7 @@ echo "LocalDirectory: $LOCALDIR"
if [ -n "$REMOTE_HOST" ]
then
echo -n 'OnlyFrom: '
- echo $(sed -n
'/^service[[:space:]]*check_mk/,/}/s/^[[:space:]]*only_from[[:space:]]*=[[:space:]]*\(.*\)/\1/p'
/etc/xinetd.d/* | head -n1)
+ echo $(sed -n
'/^service[[:space:]]*'$XINETD_SERVICE_NAME'/,/}/s/^[[:space:]]*only_from[[:space:]]*=[[:space:]]*\(.*\)/\1/p'
/etc/xinetd.d/* | head -n1)
fi
# Print out Partitions / Filesystems. (-P gives non-wrapped POSIXed output)
diff --git a/doc/treasures/agents/check_mk_agent.busybox
b/doc/treasures/agents/check_mk_agent.busybox
index 5980faf..596f6c2 100644
--- a/doc/treasures/agents/check_mk_agent.busybox
+++ b/doc/treasures/agents/check_mk_agent.busybox
@@ -34,6 +34,10 @@ export MK_LIBDIR="/usr/lib/check_mk_agent"
export MK_CONFDIR="/etc/check_mk"
export MK_VARDIR="/var/lib/check_mk_agent"
+# The package name gets patched for baked agents to either
+# "check-mk-agent" or the name set by the "name of agent packages"
rule
+XINETD_SERVICE_NAME=check_mk
+
# Provide information about the remote host. That helps when data
# is being sent only once to each remote host.
if [ "$REMOTE_HOST" ] ; then
@@ -98,7 +102,7 @@ echo LocalDirectory: $LOCALDIR
if [ -n "$REMOTE_HOST" ]
then
echo -n 'OnlyFrom: '
- echo $(sed -n
'/^service[[:space:]]*check_mk/,/}/s/^[[:space:]]*only_from[[:space:]]*=[[:space:]]*\(.*\)/\1/p'
/etc/xinetd.d/* | head -n1)
+ echo $(sed -n
'/^service[[:space:]]*'$XINETD_SERVICE_NAME'/,/}/s/^[[:space:]]*only_from[[:space:]]*=[[:space:]]*\(.*\)/\1/p'
/etc/xinetd.d/* | head -n1)
fi
# Print out Partitions / Filesystems. (-P gives non-wrapped POSIXed output)