Module: check_mk
Branch: master
Commit: dcabc0cb44d67ca17a53cebae29e4a5f6af23963
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dcabc0cb44d67c…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Wed Sep 26 10:44:42 2018 +0200
check_mk_agent.solaris: bring back missing replace_datevariable()
Change-Id: I748e92d29f9fff0cec572bd43a977f646be82c45
---
agents/check_mk_agent.solaris | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/agents/check_mk_agent.solaris b/agents/check_mk_agent.solaris
index 1ebde23..3420367 100755
--- a/agents/check_mk_agent.solaris
+++ b/agents/check_mk_agent.solaris
@@ -359,6 +359,24 @@ then
fi
+# Fileinfo-Check: put patterns for files into $MK_CONFDIR/fileinfo.cfg
+function replace_datevariable()
+{
+ # Replace the date variable of the input, e.g. $DATE:%Y%m%d$, by
+ # the current date. If there's no match just return the input.
+ local file_name="$1"
+ local pattern='(\$DATE:(.*)\$)'
+
+ if [[ ! $file_name =~ $pattern ]]; then
+ echo "$file_name"
+ else
+ date_variable="${BASH_REMATCH[1]}"
+ format_string="${BASH_REMATCH[2]}"
+ echo "${file_name/$date_variable/$(date +$format_string)}"
+ fi
+}
+
+
# Fileinfo-Check: put patterns for files into /etc/check_mk/fileinfo.cfg
if [ -r "$MK_CONFDIR/fileinfo.cfg" ]; then
echo '<<<fileinfo:sep(124)>>>'