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