2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2019 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 # exemplary output of special agent agent_ucs_bladecenter (separator is <TAB> and means tabulator):
29 #<<<ucs_c_rack_server_util:sep(9)>>>
30 #serverUtilization<TAB>dn sys/rack-unit-1/utilization<TAB>overallUtilization 0<TAB>cpuUtilization 0<TAB>memoryUtilization 0<TAB>ioUtilization 0
31 # serverUtilization<TAB>dn sys/rack-unit-2/utilization<TAB>overallUtilization 90<TAB>cpuUtilization 90<TAB>memoryUtilization 90<TAB>ioUtilization 90
33 # The format of the XML API v2.0 raw output provided via the agent is not documented.
34 # The description about the meaning of the XML attributes is described in the corresponding
35 # section of the GUI Configuration Guide. The units of overallUtilization, cpuUtilization,
36 # memoryUtilization and ioUtilization are percentages.
37 # https://www.cisco.com/c/en/us/td/docs/unified_computing/ucs/c/sw/gui/config/guide/3_1/b_Cisco_UCS_C-series_GUI_Configuration_Guide_31/b_Cisco_UCS_C-series_GUI_Configuration_Guide_31_chapter_0101.pdf
40 def parse_ucs_c_rack_server_util(info
):
42 Returns dict with indexed racks mapped to keys and utilization values mapped to dicts.
45 # The element count of info lines is under our control (agent output) and
46 # ensured to have expected length. It is ensured that elements contain a
47 # string. Handles invalid values provided by the XML API which cannot be
48 # casted by setting corresponding values to None.
49 for _
, dn
, overall_util
, cpu_util
, memory_util
, pci_io_util
in info
:
50 rack
= dn
.replace("dn ", "").replace("sys/", "").replace("rack-unit-",
51 "Rack unit ").replace(
53 parsed
.setdefault(rack
, {})
54 for ds_key
, ds
in (('overallUtilization', overall_util
), ('cpuUtilization', cpu_util
),
55 ('memoryUtilization', memory_util
), ('ioUtilization', pci_io_util
)):
57 parsed
[rack
][ds_key
] = float(ds
.replace(ds_key
+ " ", ""))
59 # The default value set by setdefault is None. These values are handled in the
60 # check function via check_levels() appropriatelly.
65 def inventory_ucs_c_rack_server_util(parsed
):
67 Yields indexed racks as items (e.g. Rack Unit 1).
69 for key
in parsed
.keys():
73 ##########################
74 # ucs_c_rack_server_util #
75 ##########################
77 factory_settings
["ucs_c_rack_server_util_overall_default_levels"] = {
78 "upper_levels": (90.0, 95.0),
83 def check_ucs_c_rack_server_util(item
, params
, data
):
84 # None values passed to check_levels(value, ...) are handled by Check_MK internals appropriatelly.
86 data
['overallUtilization'],
88 params
['upper_levels'],
89 human_readable_func
=get_percent_human_readable
)
92 check_info
["ucs_c_rack_server_util"] = {
93 'parse_function': parse_ucs_c_rack_server_util
,
94 'inventory_function': inventory_ucs_c_rack_server_util
,
95 'check_function': check_ucs_c_rack_server_util
,
96 'group': 'overall_utilization_multiitem',
97 'service_description': 'Overall Utilization %s',
98 'default_levels_variable': 'ucs_c_rack_server_util_overall_default_levels',
102 ##############################
103 # ucs_c_rack_server_util.cpu #
104 ##############################
106 factory_settings
["ucs_c_rack_server_util_cpu_default_levels"] = {
107 "upper_levels": (90.0, 95.0),
111 @get_parsed_item_data
112 def check_ucs_c_rack_server_util_cpu(item
, params
, data
):
113 # None values passed to check_levels(value, ...) are handled by Check_MK internals appropriatelly.
114 return check_cpu_util(data
['cpuUtilization'], params
['upper_levels'])
117 check_info
["ucs_c_rack_server_util.cpu"] = {
118 'inventory_function': inventory_ucs_c_rack_server_util
,
119 'check_function': check_ucs_c_rack_server_util_cpu
,
120 'group': 'cpu_utilization_multiitem',
121 'service_description': 'CPU Utilization %s',
122 'default_levels_variable': 'ucs_c_rack_server_util_cpu_default_levels',
123 'has_perfdata': True,
124 'includes': ['cpu_util.include'],
127 #################################
128 # ucs_c_rack_server_util.pci_io #
129 #################################
131 factory_settings
["ucs_c_rack_server_util_pci_io_default_levels"] = {
132 "upper_levels": (90.0, 95.0),
136 @get_parsed_item_data
137 def check_ucs_c_rack_server_util_pci_io(item
, params
, data
):
139 data
['ioUtilization'],
141 params
['upper_levels'],
142 human_readable_func
=get_percent_human_readable
)
145 check_info
["ucs_c_rack_server_util.pci_io"] = {
146 'inventory_function': inventory_ucs_c_rack_server_util
,
147 'check_function': check_ucs_c_rack_server_util_pci_io
,
148 'group': 'pci_io_utilization_multiitem',
149 'service_description': 'PCI IO Utilization %s',
150 'default_levels_variable': 'ucs_c_rack_server_util_pci_io_default_levels',
151 'has_perfdata': True,
154 ##############################
155 # ucs_c_rack_server_util.mem #
156 ##############################
158 factory_settings
["ucs_c_rack_server_util_mem_default_levels"] = {
159 "upper_levels": (90.0, 95.0),
163 @get_parsed_item_data
164 def check_ucs_c_rack_server_util_mem(item
, params
, data
):
166 data
['memoryUtilization'],
168 params
['upper_levels'],
169 human_readable_func
=get_percent_human_readable
)
172 check_info
["ucs_c_rack_server_util.mem"] = {
173 'inventory_function': inventory_ucs_c_rack_server_util
,
174 'check_function': check_ucs_c_rack_server_util_mem
,
175 'group': 'memory_utilization_multiitem',
176 'service_description': 'Memory Utilization %s',
177 'default_levels_variable': 'ucs_c_rack_server_util_mem_default_levels',
178 'has_perfdata': True,