Module: check_mk
Branch: master
Commit: 192a3b81e961db79a55d23710f19a0c09616877b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=192a3b81e961db…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Fri Apr 15 14:20:04 2016 +0200
update for wk3022: changed name of logwatch statefile
---
agents/plugins/mk_logwatch | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/agents/plugins/mk_logwatch b/agents/plugins/mk_logwatch
index 6697358..24c758a 100755
--- a/agents/plugins/mk_logwatch
+++ b/agents/plugins/mk_logwatch
@@ -56,17 +56,25 @@ else:
mk_confdir = os.getenv("MK_CONFDIR") or "."
mk_vardir = os.getenv("MK_VARDIR") or "."
-remote_hostname = os.getenv("REMOTE", "")
print "<<<logwatch>>>"
config_filename = mk_confdir + "/logwatch.cfg"
config_dir = mk_confdir + "/logwatch.d/*.cfg"
+
+# Determine the name of the state file
+# $REMOTE set -> logwatch.state.$REMOTE
+# $REMOTE not set and a tty -> logwatch.state.local
+# $REMOTE not set and not a tty -> logwatch.state
+remote_hostname = os.getenv("REMOTE", "")
if remote_hostname != "":
- status_filename = "%s/mk_logwatch_%s.state" % (mk_vardir, remote_hostname)
+ status_filename = "%s/logwatch.state.%s" % (mk_vardir, remote_hostname)
else:
- status_filename = "%s/mk_logwatch.state" % mk_vardir
+ if sys.stdout.isatty():
+ status_filename = "%s/logwatch.state.local" % mk_vardir
+ else:
+ status_filename = "%s/logwatch.state" % mk_vardir
# Copy the last known state from the logwatch.state when there is no status_filename yet.
if not os.path.exists(status_filename) and os.path.exists("%s/logwatch.state" % mk_vardir):