2 # -*- encoding: utf-8; py-indent-offset: 4 vim: set ft=python:-*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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 factory_settings
['msexch_database_defaultlevels'] = {
28 "read_attached_latency": (200., 250.),
29 "read_recovery_latency": (150., 200.),
30 "write_latency": (40., 50.),
31 "log_latency": (5., 10.),
34 _CHECKED_COUNTERS
= [ # counter, setting, name, perfvar
35 ("i/o database reads (attached) average latency", "read_attached_latency",
36 "db read (attached) latency", "db_read_latency"),
37 ("i/o database reads (recovery) average latency", "read_recovery_latency",
38 "db read (recovery) latency", "db_read_recovery_latency"),
39 ("i/o database writes (attached) average latency", "write_latency",
40 "db write (attached) latency", "db_write_latency"),
41 ("i/o log writes average latency", "log_latency", "Log latency", "db_log_latency"),
45 u
'e/a: durchschnittliche wartezeit f\x81r datenbankleseoperationen (angef\x81gt)': "i/o database reads (attached) average latency",
46 u
'e/a: durchschnittliche wartezeit f\x81r datenbankleseoperationen (wiederherstellung)': "i/o database reads (recovery) average latency",
47 u
'e/a: durchschnittliche wartezeit f\x81r datenbankschreiboperationen (angef\x81gt)': "i/o database writes (attached) average latency",
48 u
'e/a: durchschnittliche wartezeit f\x81r protokollschreiboperationen': "i/o log writes average latency",
52 def _delocalize_de_DE(instance
, counter
, value
):
53 # replace localized thousands-/ decimal-separators
54 value
= value
.replace(".", "").replace(",", ".")
55 counter
= _de_DE
.get(counter
, counter
)
56 return instance
, counter
, value
59 def parse_msexch_database(info
):
61 if not (info
and info
[0]):
64 delocalize_func
= None
66 if len(info
[0]) > 1 and info
[0][0] == 'locale':
67 locale
= info
[0][1].strip()
70 'de-DE': _delocalize_de_DE
,
74 for row
in info
[offset
:]:
75 row
= [r
.strip('"') for r
in row
]
76 if len(row
) != 2 or not row
[0].startswith('\\\\'):
79 __
, obj
, counter
= row
[0].rsplit("\\", 2)
80 instance
= obj
.split("(", 1)[-1].split(")", 1)[0]
83 if delocalize_func
is not None:
84 instance
, counter
, value
= delocalize_func(instance
, counter
, value
)
86 # The entries for log verifier contain an ID as the last part
87 # which changes upon reboot of the exchange server. Therefore,
88 # we just remove them here as a workaround.
89 if '/log verifier' in instance
:
90 instance
= instance
.rsplit(' ', 1)[0]
93 parsed
.setdefault(instance
, {})[counter
] = float(value
)
99 def inventory_msexch_database(parsed
):
100 for instance
, data
in parsed
.iteritems():
101 if any(entry
[0] in data
for entry
in _CHECKED_COUNTERS
):
105 def check_msexch_database(item
, params
, parsed
):
106 data
= parsed
.get(item
)
110 for counter
, setting
, name
, perfvar
in _CHECKED_COUNTERS
:
111 value
= data
.get(counter
)
115 warn
, crit
= params
.get(setting
, (None, None))
116 if crit
is not None and value
>= crit
:
118 elif warn
is not None and value
>= warn
:
120 yield status
, "%.1fms %s" % (value
, name
), [(perfvar
, value
, warn
, crit
, None, None)]
123 check_info
['msexch_database'] = {
124 'inventory_function': inventory_msexch_database
,
125 'check_function': check_msexch_database
,
126 'parse_function': parse_msexch_database
,
127 'has_perfdata': True,
128 'service_description': "Exchange Database %s",
129 'group': 'msx_database',
130 'default_levels_variable': 'msexch_database_defaultlevels'