2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
27 # example agent output sections...
30 # <<<zypper:sep(124)>>>
31 # 5 patches needed (2 security patches)
32 # Updates for openSUSE 12.1 12.1-1.4 | openSUSE-2012-326 | 1 | recommended | needed | Softwarestack update
33 # Updates for openSUSE 12.1 12.1-1.4 | openSUSE-2012-316 | 1 | security | needed | bind: Fixed a remote denial of service
34 # Updates for openSUSE 12.1 12.1-1.4 | openSUSE-2012-318 | 1 | recommended | needed | mdadm: fixed some race conditions during startup
35 # Updates for openSUSE 12.1 12.1-1.4 | openSUSE-2012-320 | 1 | security | needed | update for libxml2
36 # Updates for openSUSE 12.1 12.1-1.4 | openSUSE-2012-321 | 1 | recommended | needed | sudo: fixed pam session leak and tls option handling
37 # Updates for openSUSE 12.1 12.1-1.4 | openSUSE-2012-324 | 1 | recommended | needed | util-linux: make mount honor 'noexec' and 'user' option
38 # 1 | apache | package | (any)
39 # 2 | mysql | package | (any)
42 # <<<zypper:sep(124)>>>
43 # 4 patches needed (2 security patches)
44 # SLE11-SDK-SP4-Updates | sdksp4-apache2-mod_fcgid-12653 | 1 | security | needed
45 # SLES11-SP4-Updates | slessp4-mysql-12847 | 1 | security | needed
46 # SLES11-SP4-Updates | slessp4-timezone-12844 | 1 | recommended | needed
47 # SLES11-SP4-Updates | slessp4-wget-12826 | 1 | recommended | needed
49 # ...new since SLES12:
50 # <<<zypper:sep(124)>>>
51 # 4 patches needed (1 security patches)
52 # SLES12-SP1-Updates | SUSE-SLE-SERVER-12-SP1-2016-1141 | security | moderate | --- | needed | Security update for sqlite3
53 # SLES12-SP1-Updates | SUSE-SLE-SERVER-12-SP1-2016-1147 | recommended | moderate | --- | needed | Recommended update for dracut
54 # SLES12-SP1-Updates | SUSE-SLE-SERVER-12-SP1-2016-1149 | recommended | low | --- | needed | Recommended update for gcc48
55 # SLES12-SP1-Updates | SUSE-SLE-SERVER-12-SP1-2016-1150 | recommended | low | --- | needed | Recommended update for release-notes-sles
57 # <<<zypper:sep(124)>>>
58 # 4 patches needed (1 security patches)
59 # SLES12-SP0-Updates | SUSE-SLE-SERVER-12-2016-967 | recommended | low | needed | Recommended update for timezone
60 # SLES12-SP0-Updates | SUSE-SLE-SERVER-12-2016-981 | recommended | moderate | needed | Recommended update for mdadm
61 # SLES12-SP0-Updates | SUSE-SLE-SERVER-12-2016-987 | recommended | low | needed | Recommended update for procps
62 # SLES12-SP0-Updates | SUSE-SLE-SERVER-12-2016-997 | recommended | moderate | needed | Recommended update for bind
65 def inventory_zypper(info
):
66 # the agent section is only present when the agent has
67 # detected that zypper is installed, therefore the check
72 def check_zypper(_no_item
, _no_params
, info
):
76 firstline
= " ".join(info
[0])
77 if re
.match("ERROR:", firstline
):
80 # 5 patches needed (2 security patches)
83 if len(line
) >= 7 and line
[5].lower().strip() == 'needed': # since SLES12
84 patch_type
= line
[2].strip()
85 elif line
[4].lower().strip() == 'needed':
86 patch_type
= line
[3].strip()
88 patch_types
.setdefault(patch_type
, 0)
89 patch_types
[patch_type
] += 1
96 infotext
= "%d updates" % updates
98 patch_items
= patch_types
.items()
101 for t
, c
in patch_items
:
105 elif t
== "recommended":
107 state
= max(state
, 1)
110 infos
.append("%s: %d%s" % (t
, c
, marker
))
111 infotext
+= " (" + ", ".join(infos
) + ")"
114 state
= max(1, state
)
115 infotext
+= ", %d locks(!)" % len(locks
)
117 return state
, infotext
120 check_info
['zypper'] = {
121 "check_function": check_zypper
,
122 "inventory_function": inventory_zypper
,
123 "service_description": "Zypper Updates",