Module: check_mk
Branch: master
Commit: ec10e72525b8a48d1bf548dd33f61e0aa8f07b97
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ec10e72525b8a4…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed May 25 14:46:13 2016 +0200
3539 Event console: The EC notifications are now also controlled through the master
control snapin
In previous versions, the event console always sent notifications, hereby
ignoring the <i>Notifications</i> switch in the master control plugin.
This has been fixed.
---
.werks/3539 | 12 ++++++++++++
ChangeLog | 1 +
bin/mkeventd | 43 +++++++++++++++++++++++++++++++++++++------
3 files changed, 50 insertions(+), 6 deletions(-)
diff --git a/.werks/3539 b/.werks/3539
new file mode 100644
index 0000000..55ae0c8
--- /dev/null
+++ b/.werks/3539
@@ -0,0 +1,12 @@
+Title: Event console: The EC notifications are now also controlled through the master
control snapin
+Level: 1
+Component: ec
+Compatible: compat
+Version: 1.2.9i1
+Date: 1464179953
+Class: feature
+
+In previous versions, the event console always sent notifications, hereby
+ignoring the <i>Notifications</i> switch in the master control plugin.
+
+This has been fixed.
diff --git a/ChangeLog b/ChangeLog
index 0094e6e..bbf2916 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -428,6 +428,7 @@
* 3262 Event Console: bulk delete button for custom MIBs now available
* 3388 Event Console can now process SNMPv3 traps...
* 3390 Events can now be cancelled by the syslog application...
+ * 3539 Event console: The EC notifications are now also controlled through the master
control snapin...
* 3058 FIX: Event Console is now allowing non loadable MIB modules on startup...
* 3097 FIX: mkeventd: fixed crash with non-descriptive error message if mibs
couldn't be loaded
* 3335 FIX: Improved error handling when requested rule pack does not exist
diff --git a/bin/mkeventd b/bin/mkeventd
index 59c56f9..385043c 100755
--- a/bin/mkeventd
+++ b/bin/mkeventd
@@ -475,6 +475,30 @@ def initialize_snmp_credentials():
securityEngineId=snmp_v2c.OctetString(hexValue=engine_id)
)
+#.
+# .--Livestatus----------------------------------------------------------.
+# | _ _ _ _ |
+# | | | (_)_ _____ ___| |_ __ _| |_ _ _ ___ |
+# | | | | \ \ / / _ \/ __| __/ _` | __| | | / __| |
+# | | |___| |\ V / __/\__ \ || (_| | |_| |_| \__ \ |
+# | |_____|_| \_/ \___||___/\__\__,_|\__|\__,_|___/ |
+# | |
+# +----------------------------------------------------------------------+
+# | Livestatus connection |
+# '----------------------------------------------------------------------'
+
+def livestatus_query(query):
+ try:
+ livesock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ livesock.connect(g_livestatus_socket)
+ livesock.send(query)
+ livesock.shutdown(socket.SHUT_WR)
+ return livesock.recv(10000000)
+ except Exception, e:
+ log("Unable to contact monitoring core")
+ if opt_debug:
+ raise
+
#.
# .--Timeperiods---------------------------------------------------------.
@@ -498,13 +522,8 @@ def update_timeperiods():
if g_timeperiods != None and int(time.time()) / 60 == g_last_timeperiod_update:
return # only update once a minute
log("Updating timeperiod information")
-
try:
- livesock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- livesock.connect(g_livestatus_socket)
- livesock.send("GET timeperiods\nColumns: name alias in\n")
- livesock.shutdown(socket.SHUT_WR)
- answer = livesock.recv(10000000)
+ answer = livestatus_query("GET timeperiods\nColumns: name alias in\n")
table = [ line.split(';') for line in answer.split('\n')[:-1] ]
new_timeperiods = {}
for tpname, alias, isin in table:
@@ -3411,6 +3430,18 @@ def do_event_action(action, event, user=""):
monitoring_state_names = [ "OK", "WARN", "CRIT",
"UNKNOWN" ]
def do_notify(event, username, is_cancelling):
+ # Check if notifications are enabled at all
+ try:
+ answer = livestatus_query("GET status\nColumns:
enable_notifications\nOutputFormat: python\n")
+ if answer:
+ notifications_enabled = eval(answer)
+ if not notifications_enabled[0][0]:
+ log("Notifications are currently disabled. Skipped notification for
event %d" % event["id"])
+ return
+ except:
+ # On any error, assume that notifications are enabled
+ pass
+
# Create notification context based on event
# If the host name is the IP address, then use that. Otherwise let