Refactoring: Changed remaining check parameters starting with an 's' to the new rules...
[check_mk.git] / checks / ucs_bladecenter_faultinst
blobf36d5671570e30fdbbf3b270c1a584c2cdb3468b
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2015 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 # <<<ucs_bladecenter_faultinst:sep(9)>>>
28 # faultInst Dn sys/chassis-2/bl...ault-F1256 Descr Local disk 2 missing on server 2/3 Severity info
29 # faultInst Dn sys/chassis-2/bl...ault-F1256 Descr Local disk 1 missing on server 2/3 Severity info
30 # faultInst Dn sys/chassis-1/bl...ault-F1256 Descr Local disk 2 missing on server 1/3 Severity info
33 def inventory_ucs_bladecenter_faultinst(parsed):
34 yield None, None
37 def check_ucs_bladecenter_faultinst(item, _no_params, parsed):
38 severity_map = {
39 "critical": 2,
40 "major": 1,
41 "warning": 1,
42 "minor": 1,
43 "info": 0,
44 "condition": 0,
45 "cleared": 0,
47 severities = {}
48 for values in parsed.get("faultInst", {}).itervalues():
49 entry_sev = values.get("Severity").lower()
50 severities.setdefault(entry_sev, [])
51 severities[entry_sev].append(values)
53 if not severities.items():
54 yield 0, "No fault instances found"
55 return
57 for sev, instances in severities.items():
58 sev_state = severity_map.get(sev, 3)
60 # Right now, OK instances are also reported in detail
61 # If required we can increase the state level here, so that only WARN+ messages are shown
62 if sev_state >= 0:
63 extra_info = []
64 for instance in instances:
65 extra_info.append("%s" % instance["Descr"])
66 extra_info = ": " + ", ".join(extra_info)
67 else:
68 extra_info = ""
70 yield sev_state, "%d %s Instances%s" % (len(instances), sev.upper(), extra_info)
73 check_info["ucs_bladecenter_faultinst"] = {
74 'parse_function': ucs_bladecenter_convert_info,
75 'inventory_function': inventory_ucs_bladecenter_faultinst,
76 'check_function': check_ucs_bladecenter_faultinst,
77 'service_description': 'Fault Instances',
78 'includes': ['ucs_bladecenter.include'],