Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / oracle_undostat
blob8607747bae6ffa7be58c3eb9b5b90b79fa4a04cf
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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_undostat>>>
30 # TUX2 160 0 1081 300 0
32 factory_settings["oracle_undostat_defaults"] = {
33 "levels": (600, 300),
34 "nospaceerrcnt_state": 2,
38 def inventory_oracle_undostat(info):
39 return [(line[0], {}) for line in info if len(line) == 6]
42 def check_oracle_undostat(item, params, info):
43 for line in info:
44 if line[0] == item:
45 infotext = ''
47 activeblks, maxconcurrency, tuned_undoretention, maxquerylen, nospaceerrcnt = map(
48 int, line[1:])
49 warn, crit = params["levels"]
51 if tuned_undoretention == -1:
52 state = 0
53 elif tuned_undoretention <= crit:
54 state = 2
55 elif tuned_undoretention <= warn:
56 state = 1
57 else:
58 state = 0
60 nospaceerrcntpic = ""
61 if nospaceerrcnt:
62 state_errcnt = params['nospaceerrcnt_state']
63 state = max(state, state_errcnt)
64 if state_errcnt == 1:
65 nospaceerrcntpic = "(!)"
66 elif state_errcnt == 2:
67 nospaceerrcntpic = "(!!)"
68 elif state_errcnt == 3:
69 nospaceerrcntpic = "(?)"
71 if tuned_undoretention >= 0:
72 infotext = "%s Undoretention (warn/crit at %s/%s), %d active undoblocks, " \
73 % (get_age_human_readable(tuned_undoretention),
74 get_age_human_readable(warn),
75 get_age_human_readable(crit),
76 activeblks)
78 infotext += "%d max concurrent transactions, %s max querylen, %d space errors%s" \
79 % (maxconcurrency,
80 get_age_human_readable(maxquerylen),
81 nospaceerrcnt, nospaceerrcntpic)
83 perfdata = [
84 ('activeblk', activeblks),
85 ('transconcurrent', maxconcurrency),
86 ('tunedretention', tuned_undoretention, warn, crit),
87 ('querylen', maxquerylen),
88 ('nonspaceerrcount', nospaceerrcnt),
91 return state, infotext, perfdata
93 # In case of missing information we assume that the login into
94 # the database has failed and we simply skip this check. It won't
95 # switch to UNKNOWN, but will get stale.
96 raise MKCounterWrapped("Login into database failed")
99 check_info['oracle_undostat'] = {
100 "check_function": check_oracle_undostat,
101 "inventory_function": inventory_oracle_undostat,
102 "service_description": "ORA %s Undo Retention",
103 "has_perfdata": True,
104 "default_levels_variable": "oracle_undostat_defaults",
105 "group": "oracle_undostat",