Module: check_mk
Branch: master
Commit: ff3917d11b10fef8d1f385b02704d7c39188fa57
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ff3917d11b10fe…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Feb 2 10:39:24 2012 +0100
cmk --notify: new macros $MONITORING_HOST$, $OMD_ROOT$ and $OMD_SITE$
---
ChangeLog | 1 +
modules/notify.py | 14 +++++++++++++-
web/plugins/wato/globals_notification.py | 4 ++++
3 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 48f6e5c..f586e33 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -219,6 +219,7 @@
* Drop RRA-configuration files for PNP4Nagios completely
* New configuration variable ping_levels for configuring parameters
for the host checks.
+ * cmk --notify: new macros $MONITORING_HOST$, $OMD_ROOT$ and $OMD_SITE$
Checks & Agents:
* if/if64: new ruleset if_disable_if64_hosts, that force if on
diff --git a/modules/notify.py b/modules/notify.py
index 01676bd..f15ba30 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -97,6 +97,15 @@ def do_notify(args):
in os.environ.items()
if var.startswith("NOTIFY_")
and not re.match('^\$[A-Z]+\$$', value)])
+
+ # Add a few further helper variables
+ import socket
+ context["MONITORING_HOST"] = socket.gethostname()
+ if omd_root:
+ context["OMD_ROOT"] = omd_root
+ context["OMD_SITE"] = os.getenv("OMD_SITE",
"")
+
+
if notification_logging >= 2:
notify_log("Notification context:\n"
+ "\n".join(["%s=%s" % v for v in
sorted(context.items())]))
@@ -140,7 +149,10 @@ def do_notify(args):
sys.stderr.write("Details have been logged to %s.\n" %
notification_log)
sys.exit(1)
except Exception, e:
- file(var_dir + "/notify/crash.log",
"a").write("CRASH:\n%s\n\n" % format_exception())
+ crash_dir = var_dir + "/notify"
+ if not os.path.exists(crash_dir):
+ os.makedirs(crash_dir)
+ file(crash_dir + "/crash.log",
"a").write("CRASH:\n%s\n\n" % format_exception())
def format_exception():
import traceback, StringIO, sys
diff --git a/web/plugins/wato/globals_notification.py
b/web/plugins/wato/globals_notification.py
index ea47a21..9857039 100644
--- a/web/plugins/wato/globals_notification.py
+++ b/web/plugins/wato/globals_notification.py
@@ -115,6 +115,10 @@ register_configvar(group,
"<tt><b>$LONGSERVICEOUTPUT$</b></tt>: the
long output of the check command, "
"<tt><b>$SERVICEPERFDATA$</b></tt>: the
performance data of the check, "
"<tt><b>$SERVICECHECKCOMMAND$</b></tt>:
the name of the service check command"
+ "<br><br>"
+ "<tt><b>$MONITORING_HOST$</b></tt>: the
host name of the monitoring server "
+ "<tt><b>$OMD_ROOT$</b></tt>: the home
directory of the OMD site (only on OMD) "
+ "<tt><b>$OMD_SITE$</b></tt>: the name of
the OMD site (only on OMD) "
),
),
domain = "check_mk")