This file is indexed.

/usr/share/check_mk/notifications/spectrum is in check-mk-server 1.2.6p12-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/python
# Spectrum Server

# +------------------------------------------------------------------+
# |             ____ _               _        __  __ _  __           |
# |            / ___| |__   ___  ___| | __   |  \/  | |/ /           |
# |           | |   | '_ \ / _ \/ __| |/ /   | |\/| | ' /            |
# |           | |___| | | |  __/ (__|   <    | |  | | . \            |
# |            \____|_| |_|\___|\___|_|\_\___|_|  |_|_|\_\           |
# |                                                                  |
# | Copyright Mathias Kettner 2013             mk@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, sys

# Note: This script contains an example configuration
# You will probably have to modify the sent information

def send_trap(oids, target, community):
    cmd = ["/usr/bin/snmptrap", '-v', '1', '-c', community, target, "1.3.6.1.4.1.100.1.2.3", "172.25.221.23", "6", "1", "\"\"" ]
    for oid, value in oids.items():
        # Feel free to add more types. Currently only Integer and Strings are supported
        oid_type = type(value)
        oid_id   = oid_type == int and "i" or "s"
        if oid_type in [str, unicode]:
            value = "\"%s\"" % value.replace("\"", " ")
        cmd += [oid, oid_id, "%s" % value]

    sys.stderr.write("%r" % cmd)
    p = subprocess.Popen(cmd, stdin = subprocess.PIPE)
    return p.wait()

def main():
    # gather all options from env
    context = dict([
        (var[7:], value.decode("utf-8"))
        for (var, value)
        in os.environ.items()])

    # check if configured via flexible notifcations
    if "PARAMETER_1" in context:
        context["PARAMETER_COMMUNITY"]   = context["PARAMETER_1"]
        context["PARAMETER_DESTINATION"] = context["PARAMETER_2"]
        context["PARAMETER_BASEOID"]     = context["PARAMETER_3"]

    base_oid = context.get("PARAMETER_BASEOID", "1.3.6.1.4.1.1234")

    # adjust these oids to your needs
    complete_url = "https://" + context["MONITORING_HOST"]
    if "OMD_SITE" in context:
        complete_url += "/" + context["OMD_SITE"]
    complete_url += context.get("SERVICEURL", context.get("HOSTURL"))

    oids = {
        base_oid + ".1"  : context['MONITORING_HOST'],
        base_oid + ".2"  : context['HOSTNAME'],
        base_oid + ".3"  : context['HOSTADDRESS'],
        base_oid + ".4"  : context.get('HOSTGROUPNAMES', ""),
        base_oid + ".5"  : context.get('SERVICEDESC', 'Connectivity'),
        base_oid + ".6"  : context.get('SERVICESTATE', context.get('HOSTSTATE')),
        base_oid + ".7"  : context.get('SERVICEOUTPUT', context.get("HOSTOUTPUT")),
        base_oid + ".8"  : "HARD", # Notifications always are in HARDSTATE
        base_oid + ".9"  : context.get('SERVICEDESC', 'Connectivity'),
        base_oid + ".10" : 3, #SPECIFIC TRAP (type) NUMBER
        base_oid + ".11" : "Call number 123456", #CALLOUT STRING
        base_oid + ".12" : complete_url,
        base_oid + ".13" : "%s alarm on host %s" % (context.get('SERVICEDESC', 'Connectivity'), context['HOSTNAME']),
        base_oid + ".14" : context.get('SERVICEGROUPNAMES', ""),
    }

    sys.exit(send_trap(oids, context['PARAMETER_DESTINATION'], context['PARAMETER_COMMUNITY']))

main()