Module: check_mk
Branch: master
Commit: 3768828da12d1f735da83248b969f074bac66d47
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3768828da12d1f…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Wed Oct 22 16:03:02 2014 +0200
Preparing new Notification Method Spectrum (via snmp trap)
---
notifications/spectrum | 62 +++++++++++++++++++++++++++++++++++++
web/plugins/wato/notifications.py | 20 ++++++++++++
2 files changed, 82 insertions(+)
diff --git a/notifications/spectrum b/notifications/spectrum
new file mode 100755
index 0000000..82f8310
--- /dev/null
+++ b/notifications/spectrum
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+# Sepectrum Server
+
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+
+import os, subprocess
+
+def send_trap(oids, target, community):
+ cmd = ["/usr/sbin/snmptrap", '-v', '1', '-c',
community, target ]
+ for oid, text in oids.items():
+ cmd += [oid, str(text)]
+ p = subprocess.Popen(cmd, stdin = subprocess.PIPE)
+ return True
+
+def main():
+ # gather all options from env
+ context = dict([
+ (var[7:], value.decode("utf-8"))
+ for (var, value)
+ in os.environ.items()])
+ oids = {
+ "1.3.6.1.4.1.13424.10.5.2.1.1.1" : context['MONITORING_HOST'],
+ "1.3.6.1.4.1.13424.10.5.2.1.1.2" : context['HOSTNAME'],
+ "1.3.6.1.4.1.13424.10.5.2.1.1.3" : context['HOSTADDRESS'],
+ "1.3.6.1.4.1.13424.10.5.2.1.1.4" :
context['HOSTCONTACTGROUPNAMES'],
+ "1.3.6.1.4.1.13424.10.5.2.1.1.5" : context['SERVICEDESC'],
+ "1.3.6.1.4.1.13424.10.5.2.1.1.6" : context['SERVICESTATE'],
+ "1.3.6.1.4.1.13424.10.5.2.1.1.7" : context['SERVICEOUTPUT'],
+ "1.3.6.1.4.1.13424.10.5.2.1.1.8" : "HARD", # Notifications
always are in HARDSTATE
+ "1.3.6.1.4.1.13424.10.5.2.1.1.9" : context['SERVICEDESC'],
+ "1.3.6.1.4.1.13424.10.5.2.1.1.10" : 3, #SPECIFIC TRAP (type) NUMBER
+ "1.3.6.1.4.1.13424.10.5.2.1.1.11" : "CNO Digital Lvl2 Support (P3
ET, call xxxxx)", #CALLOUT STRING
+ "1.3.6.1.4.1.13424.10.5.2.1.1.12" : context['SERVICEURL'],
+ "1.3.6.1.4.1.13424.10.5.2.1.1.13" : "%s Alarm on host %s" %
(context['SERVICEDESC'], context['HOSTNAME']),
+ "1.3.6.1.4.1.13424.10.5.2.1.1.14" :
context['SERVICEGROUPNAMES'],
+ }
+ send_trap(oids, context['PARAMETER_DESTINATION'],
context['PARAMETER_COMMUNITY'])
+
+main()
diff --git a/web/plugins/wato/notifications.py b/web/plugins/wato/notifications.py
index 33d8830..12d4733 100644
--- a/web/plugins/wato/notifications.py
+++ b/web/plugins/wato/notifications.py
@@ -197,3 +197,23 @@ register_notification_parameters("mkeventd",
]
)
)
+
+
+register_notification_parameters("spectrum",
+ Dictionary(
+ optional_keys = None,
+ elements = [
+ ("destination",
+ IPv4Address(
+ title = _("Destination IP"),
+ help = _("IP Address of the Spectrum server receiving the SNMP
trap")
+ ),
+ ),
+ ("community",
+ TextAscii(
+ title = _("SNMP Community"),
+ help = _("SNMP Community for the SNMP trap")
+ ),
+ ),
+ ])
+ )