Cleanup config.nodes_of
[check_mk.git] / checks / oracle_processes
blob107b493afb778b3de374609ff6d43973b8e5ede2
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_processes>>>
30 # TUX2 51 300
31 # FOOBAR 11 4780
33 # Columns: SID PROCESSES_COUNT PROCESSES_LIMIT
35 factory_settings["oracle_processes_defaults"] = {
36 "levels": (70.0, 90.0),
40 def inventory_oracle_processes(info):
42 return [(line[0], {}) for line in info]
45 def check_oracle_processes(item, params, info):
46 for line in info:
47 if line[0] == item:
48 err = oracle_handle_ora_errors(line)
49 if err is False:
50 continue
51 elif isinstance(err, tuple):
52 return err
54 processes_num = int(line[1])
55 processes_max = int(line[2])
56 processes_pct = float(processes_num) / float(processes_max) * 100
58 warn, crit = params["levels"]
59 processes_warn = processes_max * warn / 100
60 processes_crit = processes_max * crit / 100
62 if processes_pct >= crit:
63 state = 2
64 elif processes_pct >= warn:
65 state = 1
66 else:
67 state = 0
69 return state, "%d of %d processes are used (%d%%, warn/crit at %d%%/%d%%)" \
70 % (processes_num, processes_max, processes_pct, warn, crit), \
71 [("processes", processes_num, processes_warn, processes_crit)]
73 # In case of missing information we assume that the login into
74 # the database has failed and we simply skip this check. It won't
75 # switch to UNKNOWN, but will get stale.
76 raise MKCounterWrapped("Login into database failed")
79 check_info['oracle_processes'] = {
80 "check_function": check_oracle_processes,
81 "inventory_function": inventory_oracle_processes,
82 "service_description": "ORA %s Processes",
83 "has_perfdata": True,
84 "default_levels_variable": "oracle_processes_defaults",
85 "group": "oracle_processes",
86 "includes": ["oracle.include"],