This file is indexed.

/usr/share/check_mk/checks/zypper 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
89
90
91
92
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# |             ____ _               _        __  __ _  __           |
# |            / ___| |__   ___  ___| | __   |  \/  | |/ /           |
# |           | |   | '_ \ / _ \/ __| |/ /   | |\/| | ' /            |
# |           | |___| | | |  __/ (__|   <    | |  | | . \            |
# |            \____|_| |_|\___|\___|_|\_\___|_|  |_|_|\_\           |
# |                                                                  |
# | Copyright Mathias Kettner 2014             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.

# <<<zypper:sep(124)>>>
# 5 patches needed (2 security patches)
# Updates for openSUSE 12.1 12.1-1.4 | openSUSE-2012-326 | 1       | recommended | needed | Softwarestack update
# Updates for openSUSE 12.1 12.1-1.4 | openSUSE-2012-316 | 1       | security    | needed | bind: Fixed a remote denial of service
# Updates for openSUSE 12.1 12.1-1.4 | openSUSE-2012-318 | 1       | recommended | needed | mdadm: fixed some race conditions during startup
# Updates for openSUSE 12.1 12.1-1.4 | openSUSE-2012-320 | 1       | security    | needed | update for libxml2
# Updates for openSUSE 12.1 12.1-1.4 | openSUSE-2012-321 | 1       | recommended | needed | sudo: fixed pam session leak and tls option handling
# Updates for openSUSE 12.1 12.1-1.4 | openSUSE-2012-324 | 1       | recommended | needed | util-linux: make mount honor 'noexec' and 'user' option
# 1 | apache | package | (any)
# 2 | mysql  | package | (any)


def inventory_zypper(info):
    # the agent section is only present when the agent has
    # detected that zypper is installed, therefore the check
    # can always register
    return [(None,{})]

def check_zypper(_no_item, _no_params, info):
    patch_types = {}
    updates = 0
    locks = []
    firstline = " ".join(info[0])
    if re.match("ERROR:", firstline):
        return 3, firstline
    for line in info:
        # 5 patches needed (2 security patches)
        if len(line) >= 5 and line[4].lower().strip() == 'needed':
            patch_type = line[3].strip()
            patch_types.setdefault(patch_type, 0)
            patch_types[patch_type] += 1
            updates += 1
        elif len(line) == 4:
            locks.append(line[1])

    state = 0

    infotext = "%d updates" % updates
    if updates:
        patch_items = patch_types.items()
        patch_items.sort()
        infos = []
        for t,c in patch_items:
            if t == "security":
                marker = '(!!)'
                state = 2
            elif t == "recommended":
                marker = '(!)'
                state = max(state, 1)
            else:
                marker = ''
            infos.append("%s: %d%s" % (t, c, marker))
        infotext += " (" + ", ".join(infos) + ")"

    if locks:
        state = max(1, state)
        infotext += ", %d locks(!)" % len(locks)

    return state, infotext

check_info['zypper'] = {
    "check_function"          : check_zypper,
    "inventory_function"      : inventory_zypper,
    "service_description"     : "Zypper Updates",
    "group"                   : "zypper",
}