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 # <<<oracle_logswitches>>>
31 factory_settings
["oracle_logswitches_default_levels"] = {
33 'levels_lower': (-1, -1),
37 def inventory_oracle_logswitches(info
):
38 oracle_handle_ora_errors_discovery(info
)
39 return [(line
[0], {}) for line
in info
if len(line
) >= 2]
42 def check_oracle_logswitches(item
, params
, info
):
44 if isinstance(params
, tuple):
45 params
= {'levels': (params
[2], params
[3]),
46 'levels_lower': (params
[1], params
[0]),
51 err
= oracle_handle_ora_errors(line
)
54 elif isinstance(err
, tuple):
57 lowarn
, locrit
= params
['levels_lower']
58 warn
, crit
= params
['levels']
59 logswitches
= int(line
[1])
60 infotext
= "%d log switches in the last 60 minutes (warn/crit below %d/%d) (warn/crit at %d/%d)" \
61 % (logswitches
, locrit
, lowarn
, warn
, crit
)
62 perfdata
= [("logswitches", logswitches
, warn
, crit
, 0, None)]
63 if logswitches
>= crit
or logswitches
<= locrit
:
64 return (2, infotext
, perfdata
)
65 elif logswitches
>= warn
or logswitches
<= lowarn
:
66 return (1, infotext
, perfdata
)
67 return (0, infotext
, perfdata
)
69 # In case of missing information we assume that the login into
70 # the database has failed and we simply skip this check. It won't
71 # switch to UNKNOWN, but will get stale.
72 raise MKCounterWrapped("Login into database failed")
75 check_info
["oracle_logswitches"] = {
76 'check_function': check_oracle_logswitches
,
77 'inventory_function': inventory_oracle_logswitches
,
78 'service_description': 'ORA %s Logswitches',
80 'group': 'oracle_logswitches',
81 'default_levels_variable': 'oracle_logswitches_default_levels',
82 'includes': ['oracle.include'],