Module: check_mk
Branch: master
Commit: eef09f0f0621ac146622f22cefd287cb7c826951
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=eef09f0f0621ac…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Tue Jan 30 14:27:42 2018 +0100
5496 FIX lnx_if: fix an issue that could lead to a crash of the agent if no interface
address is returned
Change-Id: Iaabbb663209860c523bc969bf1ab30b890cbe603
---
.werks/5496 | 10 ++++++++++
agents/check_mk_agent.linux | 6 +++---
agents/check_mk_agent.openwrt | 6 +++---
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/.werks/5496 b/.werks/5496
new file mode 100644
index 0000000..5404be8
--- /dev/null
+++ b/.werks/5496
@@ -0,0 +1,10 @@
+Title: lnx_if: fix an issue that could lead to a crash of the agent if no interface
address is returned
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i3
+Date: 1517490540
+Class: fix
+
+
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 0a94bdc..074c224 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -389,11 +389,11 @@ echo '<<<lnx_if:sep(58)>>>'
sed 1,2d /proc/net/dev
if type ethtool > /dev/null
then
- for eth in $(sed -e 1,2d < /proc/net/dev | cut -d':' -f1 | sort)
+ for eth in $(sed -e 1,2d /proc/net/dev | cut -d':' -f1 | sort)
do
echo "[$eth]"
- ethtool $eth | egrep '(Speed|Duplex|Link detected|Auto-negotiation):'
- echo -en "\tAddress: " ; cat /sys/class/net/$eth/address ; echo
+ ethtool "$eth" | grep -E '(Speed|Duplex|Link
detected|Auto-negotiation):'
+ echo -e "\tAddress: $(cat "/sys/class/net/$eth/address")\n"
done
fi
diff --git a/agents/check_mk_agent.openwrt b/agents/check_mk_agent.openwrt
index 86c2ea0..0e3bc75 100755
--- a/agents/check_mk_agent.openwrt
+++ b/agents/check_mk_agent.openwrt
@@ -336,11 +336,11 @@ echo '<<<lnx_if:sep(58)>>>'
sed 1,2d /proc/net/dev
if type ethtool > /dev/null
then
- for eth in $(sed -e 1,2d < /proc/net/dev | cut -d':' -f1 | sort)
+ for eth in $(sed -e 1,2d /proc/net/dev | cut -d':' -f1 | sort)
do
echo "[$eth]"
- ethtool $eth | egrep '(Speed|Duplex|Link detected|Auto-negotiation):'
- echo -en "\tAddress: " ; cat /sys/class/net/$eth/address ; echo
+ ethtool "$eth" | grep -E '(Speed|Duplex|Link
detected|Auto-negotiation):'
+ echo -e "\tAddress: $(cat "/sys/class/net/$eth/address")\n"
done
fi