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 # In cooperation with Thorsten Bruhns from OPITZ Consulting
29 # <<<oracle_dataguard_stats:sep(124)>>>
30 # TUX12C|TUXSTDB|PHYSICAL STANDBY|transport lag|+00 00:00:00
31 # TUX12C|TUXSTDB|PHYSICAL STANDBY|apply lag|+00 00:28:57
32 # TUX12C|TUXSTDB|PHYSICAL STANDBY|apply finish time|+00 00:00:17.180
33 # TUX12C|TUXSTDB|PHYSICAL STANDBY|estimated startup time|20
36 def inventory_oracle_dataguard_stats(info
):
41 inventory
.append(("%s.%s" % (line
[0], line
[1]), {}))
45 def check_oracle_dataguard_stats(item
, params
, info
):
46 def get_seconds(timestamp
):
47 if str(timestamp
)[0:1] == '+':
48 days
= int(timestamp
[1:3])
49 h
= int(timestamp
[4:6])
50 min_
= int(timestamp
[7:9])
51 sec
= int(timestamp
[10:12])
53 seconds
= int(sec
+ min_
* 60 + h
* 3600 + days
* 24 * 3600)
66 if line
[0] + '.' + line
[1] == item
:
67 _db_name
, _db_unique_name
, database_role
, parameter
, value
= line
[:5]
71 infotext
= 'Database Role %s' % (database_role
.lower())
73 if parameter
in ('transport lag', 'apply lag', 'apply finish time'):
75 if parameter
== 'apply lag':
76 params_value
= 'apply_lag'
78 elif parameter
== 'transport lag':
79 params_value
= 'transport_lag'
86 seconds
= int(get_seconds(value
))
88 infotext
+= ' %s %s' % (parameter
, get_age_human_readable(seconds
))
90 if params
.get(params_value
):
91 infotext
+= ' (warn/crit at '
93 if parameter
== 'apply lag' and params
.get('apply_lag_min'):
95 # minimum apply lag needs a configured apply lag rule!
96 warn
, crit
= params
.get('apply_lag_min')
97 infotext
+= '%s/%s .. ' % (get_age_human_readable(warn
), \
98 get_age_human_readable(crit
))
100 # apply_lag_min is a MINIMUM value!
103 state_marker
= '(!!)'
104 elif warn
>= seconds
:
105 state
= max(state
, 1)
108 warn
, crit
= params
.get(params_value
)
109 infotext
+= '%s/%s)' % (get_age_human_readable(warn
), \
110 get_age_human_readable(crit
))
114 state_marker
= '(!!)'
115 elif warn
<= seconds
:
116 state
= max(state
, 1)
119 infotext
+= state_marker
121 perfdata
.append((parameter
.replace(' ', '_'), seconds
, warn
, crit
))
123 perfdata
.append((parameter
.replace(' ', '_'), seconds
))
125 if itemfound
is True:
126 return state
, infotext
, perfdata
128 # In case of missing information we assume that the login into
129 # the database has failed and we simply skip this check. It won't
130 # switch to UNKNOWN, but will get stale.
131 raise MKCounterWrapped("Dataguard disabled or Instance not running")
134 check_info
['oracle_dataguard_stats'] = {
135 "check_function": check_oracle_dataguard_stats
,
136 "inventory_function": inventory_oracle_dataguard_stats
,
137 "service_description": "ORA %s Dataguard-Stats",
138 "has_perfdata": True,
139 "group": "oracle_dataguard_stats",