Module: check_mk
Branch: master
Commit: 5e4924ad44d1dbfaf133c7f3ace08ed3590b2c4b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5e4924ad44d1db…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Feb 11 12:30:05 2013 +0100
mknotifyd: Broke some things in settings
---
mknotifyd/web/plugins/wato/mknotifyd.py | 80 +++++++++++++-----------------
modules/check_mk.py | 9 +++-
modules/notify.py | 9 ++--
3 files changed, 47 insertions(+), 51 deletions(-)
diff --git a/mknotifyd/web/plugins/wato/mknotifyd.py
b/mknotifyd/web/plugins/wato/mknotifyd.py
index e255464..80162cf 100644
--- a/mknotifyd/web/plugins/wato/mknotifyd.py
+++ b/mknotifyd/web/plugins/wato/mknotifyd.py
@@ -29,20 +29,16 @@ import config
try:
mknotifyd_enabled = config.mknotifyd_enabled
except:
- mknotifyd_enabled = False
+ mknotifyd_enabled = True
config_dir = defaults.default_config_dir + "/mknotifyd.d/wato/"
-def log_mkeventd(what, message):
- log_entry(None, what, message, "audit.log") # central WATO audit log
- log_entry(None, what, message, "mknotify.log") # pending changes for
mknotifyd
-
if mknotifyd_enabled:
group = _("Notification")
# Check_MK var
register_configvar(group,
- "notification_spooling_enabled",
+ "notification_spooling",
Checkbox(
title = _("Spool notifications"),
help = _("Here you can set if notifications are processed through a
spooling mechanism."
@@ -53,6 +49,36 @@ if mknotifyd_enabled:
domain = "check_mk"
)
+ # Check_MK var
+ register_configvar(group,
+ "notification_spool_to",
+ Optional(
+ Tuple(
+ elements = [
+ TextAscii(
+ title = _("Remote host"),
+ ),
+ Integer(
+ title = _("TCP port"),
+ minvalue = 1,
+ maxvalue = 65535,
+ default_value = 6555,
+ ),
+ Checkbox(
+ title = _("Local processing"),
+ label = _("Also process notification locally"),
+ ),
+ ]),
+ title = _("Remote notification spooling"),
+ help = _("This option allows you to forward notifications to another
Check_MK site. "
+ "That site must have the notification spooler running and TCP
listening enabled. "
+ "This allows you to create a centralized notification
handling."),
+ label = _("Spool notifications to remote site"),
+ none_label = _("(Do not spool to remote site)"),
+ ),
+ domain = "check_mk"
+ )
+
# Daemon var
register_configvar_domain("mknotifyd", config_dir)
register_configvar(group,
@@ -70,50 +96,14 @@ if mknotifyd_enabled:
)
- # Check_MK var
- register_configvar(group,
- "notification_forward_mode",
- DropdownChoice(
- title = _("Forwarding mode"),
- help = _("How notifications should be forwarded<br>"
- "No Forwarding: Notifications are processed locally according
to the contact settings<br>"
- "Forward an process local: Notifications are forwarded to the
configured remote site, "
- "but also processed locally according to the contacts
settings<br>"
- "Exclusive forwarding: Notifications are forwarded to the
configured remote site and "
- "never processed on the local site. This means that the
configured notification plugins "
- "for the local contacts do not apply"
- ),
- choices = [
- ('off', _("No Forwarding")),
- ('forward' , _("Forward and process local")),
- ('forward_exclusive', _("Exclusive forwarding"))
- ]),
- domain = "check_mk"
- )
-
- # Check_MK var
- register_configvar(group,
- "notification_forward_to",
- Optional(
- TextAscii(
- title = _("{Host}:{Port}")
- ),
- title = _("Forward notifications to remote host"),
- help = _("This will forward notifications to a remote site"),
- label = _("Forward to remote host"),
- none_label = _("Do not send to remote host"),
- ),
- domain = "check_mk"
- )
-
# Daemon var
register_configvar(group,
"notification_daemon_listen_port",
Integer(
title = _("Port for receiving notifications"),
- help = _("Here you can set port at which the mknotifyd listens for
forwarded"
- "notification messages. The port number needs to be between
1025 and 65535"),
- minvalue = 1025,
+ help = _("Here you can set port at which the notification spooler
listens for forwarded"
+ "notification messages from spoolers on remote
sites."),
+ minvalue = 1,
maxvalue = 65535,
default_value = 6555,
),
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 5d7a3a0..9112a5b 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -319,6 +319,12 @@ host_attributes = {} # needed by WATO, ignored
by Check_MK
ping_levels = [] # special parameters for host/PING
check_command
check_periods = []
+# Notification Spooling
+notification_spooling = False
+notification_spool_to = None
+
+
+
# global variables used to cache temporary values (not needed in check_mk_base)
ip_to_hostname_cache = None
@@ -340,7 +346,7 @@ special_agent_info = {}
# Now include the other modules. They contain everything that is needed
# at check time (and many of that is also needed at administration time).
try:
- modules = [ 'check_mk_base', 'snmp', 'notify' ]
+ modules = [ 'check_mk_base', 'snmp' ]
for module in modules:
filename = modules_dir + "/" + module + ".py"
execfile(filename)
@@ -4856,6 +4862,7 @@ if __name__ == "__main__":
do_automation(a, args)
done = True
elif o == '--notify':
+ execfile(modules_dir + "/notify.py")
sys.exit(do_notify(args))
except MKGeneralException, e:
diff --git a/modules/notify.py b/modules/notify.py
index d5f6556..697b3f3 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -33,17 +33,15 @@
# encoded one) and can use any of the variables contact, email,
# hostname, servicedesc, hoststate, servicestate, output in
# the form %(variable)s
+
import pprint, uuid
+
# Default settings
notification_logdir = var_dir + "/notify"
notification_spooldir = var_dir + "/notify/spool"
notification_log = notification_logdir + "/notify.log"
notification_logging = 0
-notification_spooling_enabled = False
-notification_forward_to = ""
-notification_forward_mode = "off"
-
notification_log_template = \
u"$CONTACTNAME$ - $NOTIFICATIONTYPE$ - " \
u"$HOSTNAME$ $HOSTSTATE$ - " \
@@ -362,10 +360,11 @@ def do_notify(args):
sys.exit(1)
notify_log("forward mode %s" % notification_forward_mode)
+ # TODO:
if notification_forward_mode in ["forward",
"forward_exclusive"]:
# Create spoolfile
create_spoolfile({"context": context, "forward":
notification_forward_to})
- if notification_forward_mode == "forward_exclusive":
+ if notification_forward_mode == "forward_only":
return 0
try: