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 # <<<db2_bp_hitratios>>>
28 # [[[db2taddm:CMDBS1]]]
29 # BP_NAME TOTAL_HIT_RATIO_PERCENT DATA_HIT_RATIO_PERCENT INDEX_HIT_RATIO_PERCENT XDA_HIT_RATIO_PERCENT
30 # IBMDEFAULTBP 99.36 98.48 99.94 -
31 # BUF8K 99.94 99.94 99.95 -
32 # BUF32K 99.99 99.98 99.99 -
33 # BP8 100.00 100.00 - -
36 def parse_db2_bp_hitratios(info
):
37 pre_parsed
= parse_db2_dbs(info
)
39 # Some databases run in DPF mode. This means they are split over several instances
40 # Each instance has its own bufferpool hitratio information. We create on service for each instance
42 for instance
, lines
in pre_parsed
[1].items():
43 header_idx
, node_names
= None, []
44 for idx
, line
in enumerate(lines
):
46 node_names
.append(" ".join(line
[1:]))
47 elif line
[0] == "BP_NAME":
54 current_node_offset
= -1
55 current_instance
= None
56 for line
in lines
[header_idx
+ 1:]:
57 if line
[0] == "IBMDEFAULTBP":
58 current_node_offset
+= 1
59 current_instance
= "%s DPF %s" % (instance
, node_names
[current_node_offset
])
60 databases
.setdefault(current_instance
, [node_headers
])
61 databases
[current_instance
].append(line
)
63 databases
[instance
] = lines
68 def inventory_db2_bp_hitratios(parsed
):
69 for key
, values
in parsed
.items():
70 for field
in values
[1:]:
71 if not field
[0].startswith("IBMSYSTEMBP"):
72 yield "%s:%s" % (key
, field
[0]), {}
75 def check_db2_bp_hitratios(item
, no_params
, parsed
):
76 db_instance
, field
= item
.rsplit(":", 1)
77 db
= parsed
.get(db_instance
)
79 raise MKCounterWrapped("Login into database failed")
84 hr_info
= dict(zip(headers
[1:], line
[1:])) # skip BP_NAME
85 for key
in headers
[1:]:
87 value
= value
.replace("-", "0").replace(",", ".")
88 key
= key
.replace("_RATIO_PERCENT", "")
95 yield 0, "%s: %s%%" % (map_key_to_text
[key
], value
), [("%sratio" % key
.lower(),
96 float(value
), None, None, 0,
101 check_info
['db2_bp_hitratios'] = {
102 "parse_function": parse_db2_bp_hitratios
,
103 "service_description": "DB2 BP-Hitratios %s",
104 "check_function": check_db2_bp_hitratios
,
105 "inventory_function": inventory_db2_bp_hitratios
,
106 "has_perfdata": True,
107 "includes": ["db2.include"]