Cleanup config.nodes_of
[check_mk.git] / checks / oracle.include
blob268c83461c1fd8a2c456795269809fe4f163c3dc
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.
28 # This function must be executed for each agent line which has been
29 # found for the current item. It must deal with the ORA-* error
30 # messages. It has to skip over the lines which show the SQL statement
31 # and the SQL error message which comes before the ORA-* message.
33 # The check must completely skip the lines before the ORA-* messages
34 # and return UNKNOWN on the first found ORA-* message.
35 # line[0] is the item (db instance)
37 # This function returns a tuple when an ORA-* message has been found.
38 # It returns False if this line should be skipped by the check.
39 def oracle_handle_ora_errors(line):
40 if len(line) == 1:
41 return
43 legacy_error = oracle_handle_legacy_ora_errors(line)
44 if legacy_error:
45 return legacy_error
47 # Handle error output from new agent
48 if line[1] == 'FAILURE':
49 if len(line) >= 3 and line[2].startswith("ORA-"):
50 return (3, "%s" % " ".join(line[2:]))
51 return False # ignore other FAILURE lines
53 # Handle error output from old (pre 1.2.0p2) agent
54 if line[1] in ['select', '*', 'ERROR']:
55 return False
56 if line[1].startswith('ORA-'):
57 return (3, 'Found error in agent output "%s"' % ' '.join(line[1:]))
60 def oracle_handle_legacy_ora_errors(line):
61 # Skip over line before ORA- errors (e.g. sent by AIX agent from 2014)
62 if line == ["ERROR:"]:
63 return False
65 if line[0].startswith('ORA-'):
66 return (3, 'Found error in agent output "%s"' % ' '.join(line))
69 # Fully prevent creation of services when an error is found.
70 def oracle_handle_ora_errors_discovery(info):
71 for line in info:
72 err = oracle_handle_ora_errors(line)
73 if err is False:
74 continue
75 elif isinstance(err, tuple):
76 raise MKGeneralException(err[1])