Module: check_mk
Branch: master
Commit: 3da5d48c5bb34f833b4f7c05056bb85e5eb79872
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3da5d48c5bb34f…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Thu Nov 16 14:16:12 2017 +0100
5478 FIX fileinfo: fix globbing pattern expansion
Fixes the issue that globbing patterns were not expanded
after the introduction of werk 5344.
Change-Id: Ia8cee28137aefc9e8aff5b8db6f28e1c24ea3ab2
---
.werks/5478 | 12 ++++++++++++
agents/check_mk_agent.aix | 4 ++--
agents/check_mk_agent.freebsd | 4 ++--
agents/check_mk_agent.linux | 4 ++--
agents/check_mk_agent.macosx | 4 ++--
agents/check_mk_agent.openwrt | 4 ++--
agents/check_mk_agent.solaris | 4 ++--
7 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/.werks/5478 b/.werks/5478
new file mode 100644
index 0000000..ada7403
--- /dev/null
+++ b/.werks/5478
@@ -0,0 +1,12 @@
+Title: fileinfo: fix globbing pattern expansion
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1510837983
+
+Fixes the issue that globbing patterns were not expanded
+after the introduction of werk 5344.
diff --git a/agents/check_mk_agent.aix b/agents/check_mk_agent.aix
index 7632cb5..9376857 100755
--- a/agents/check_mk_agent.aix
+++ b/agents/check_mk_agent.aix
@@ -291,12 +291,12 @@ if [ -r "$MK_CONFDIR/fileinfo.cfg" ]; then
date +%s
# simulate output of the Linux "stat -c "%n|%s|%Y" command
# TODO: feel free to improve this command. It opens the perl interpreter for every
file found...
- while read pattern
+ for pattern in $(cat "$MK_CONFDIR/fileinfo.cfg" 2>/dev/null)
do
if [ -f "$pattern" ]; then
ls -1 "$pattern"
fi
- done < "$MK_CONFDIR/fileinfo.cfg" 2>/dev/null |\
+ done |\
while read file
do
/usr/bin/perl -e 'printf "$_|%s|%s\n", (stat) [7,9] for @ARGV'
"$file"
diff --git a/agents/check_mk_agent.freebsd b/agents/check_mk_agent.freebsd
index 3748661..ba9aaf4 100755
--- a/agents/check_mk_agent.freebsd
+++ b/agents/check_mk_agent.freebsd
@@ -380,14 +380,14 @@ fi
if [ -r "$MK_CONFDIR/fileinfo.cfg" ] ; then
echo '<<<fileinfo:sep(124)>>>'
date +%s
- while read line
+ for line in $(cat "$MK_CONFDIR/fileinfo.cfg")
do
stat -f "%N|%z|%m" "$line" 2>/dev/null
if [ $? -ne 0 ]; then
echo "$line|missing|$(date +%s)"
fi
- done < "$MK_CONFDIR/fileinfo.cfg"
+ done
fi
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index f060f68..18244fb 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -766,7 +766,7 @@ function replace_datevariable()
if [ -r "$MK_CONFDIR/fileinfo.cfg" ] ; then
echo '<<<fileinfo:sep(124)>>>'
date +%s
- while read line
+ for line in $(cat "$MK_CONFDIR/fileinfo.cfg")
do
# only work on lines containing files, skip e.g. comments and blank lines
if [ "${line:0:1}" = "/" ]; then
@@ -777,7 +777,7 @@ if [ -r "$MK_CONFDIR/fileinfo.cfg" ] ; then
echo "$line|missing|$(date +%s)"
fi
fi
- done < "$MK_CONFDIR/fileinfo.cfg"
+ done
fi
# Get stats about OMD monitoring cores running on this machine.
diff --git a/agents/check_mk_agent.macosx b/agents/check_mk_agent.macosx
index 73b65ee..cb15c7e 100755
--- a/agents/check_mk_agent.macosx
+++ b/agents/check_mk_agent.macosx
@@ -93,14 +93,14 @@ netstat -ntfinet | awk ' /^tcp/ { c[$6]++; } END { for (x in c) {
print x, c[x];
if [ -r "$MK_CONFDIR/fileinfo.cfg" ] ; then
echo '<<<fileinfo:sep(124)>>>'
date +%s
- while read line
+ for line in $(cat "$MK_CONFDIR/fileinfo.cfg")
do
stat -f "%N|%z|%m" "$line" 2>/dev/null
if [ $? -ne 0 ]; then
echo "$line|missing|$(date +%s)"
fi
- done < "$MK_CONFDIR/fileinfo.cfg"
+ done
fi
if type tmutil >/dev/null
diff --git a/agents/check_mk_agent.openwrt b/agents/check_mk_agent.openwrt
index c7e3125..37b9ff5 100755
--- a/agents/check_mk_agent.openwrt
+++ b/agents/check_mk_agent.openwrt
@@ -681,14 +681,14 @@ fi
if [ -r "$MK_CONFDIR/fileinfo.cfg" ] ; then
echo '<<<fileinfo:sep(124)>>>'
date +%s
- while read line
+ for line in $(cat "$MK_CONFDIR/fileinfo.cfg")
do
stat -c "%n|%s|%Y" "$line" 2>/dev/null
if [ $? -ne 0 ]; then
echo "$line|missing|$(date +%s)"
fi
- done < "$MK_CONFDIR/fileinfo.cfg"
+ done
fi
# Get stats about OMD monitoring cores running on this machine.
diff --git a/agents/check_mk_agent.solaris b/agents/check_mk_agent.solaris
index 95b4dac..68c4310 100755
--- a/agents/check_mk_agent.solaris
+++ b/agents/check_mk_agent.solaris
@@ -369,7 +369,7 @@ then
echo '<<<fileinfo:sep(124)>>>'
/usr/bin/perl -e 'print time."\n"'
# note: patterns in the fileinfo.cfg are resolved inside this loop
- while read file
+ for file in $(cat "$MK_CONFDIR/fileinfo.cfg")
do
# only work on lines containing files, skip e.g. comments and blank lines
if [ "${file:0:1}" = "/" ]; then
@@ -387,7 +387,7 @@ then
echo "$file|missing|$(/usr/bin/perl -e 'print time')"
fi
fi
- done < "$MK_CONFDIR/fileinfo.cfg"
+ done
fi
# Libelle Business Shadow