Module: check_mk
Branch: master
Commit: 77c2883368881528b81bf618ceb441943dcf1b93
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=77c28833688815…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jan 28 11:55:18 2011 +0100
oracle_tablespaces: refined check logic
---
checkman/oracle_tablespaces | 49 ++++++++++++++++++++++-----
checks/oracle_tablespaces | 79 +++++++++++++++++++++++++++++-------------
2 files changed, 94 insertions(+), 34 deletions(-)
diff --git a/checkman/oracle_tablespaces b/checkman/oracle_tablespaces
index 3df7638..f94aa09 100644
--- a/checkman/oracle_tablespaces
+++ b/checkman/oracle_tablespaces
@@ -1,4 +1,4 @@
-title: Check size, state and auto extension of ORACLE tablespaces
+title: Check various aspects of ORACLE tablespaces
agents: linux
author: Mathias Kettner <mk(a)mathias-kettner.de>
license: GPL
@@ -6,7 +6,8 @@ distribution: check_mk
description:
This check monitors the state of ORACLE tablespaces. It
checks the current and maximum size, the online state
- and the autoextension.
+ and the autoextension and optionally the setting of
+ the increment size.
{Autoextension}: During inventory the autoextension
setting is determined and frozen into the check parameter.
@@ -15,18 +16,31 @@ description:
consist of several data files with different settings.
If at least one data file has auto extension turned on,
the table space is considered to have auto extension
- turned on.
+ turned on. You can turn off auto extension checking
+ by setting the first check parameter to {None} rather
+ then to {True} or {False}. Inventory will do this for
+ you if you set {oracle_tablespaces_check_autoext} to {False}.
- {State}: Only table spaces in state {ONLINE} will be
- found by inventory and monitored. If the state changes
- later, the check will get critical.
+ {Increment size}: If the configuration parameter
+ {oracle_tablespaces_check_default_increment} is set to
+ {True} (which is the defaut), then the check will warn
+ you, if the increment size is set to the ORACLE default
+ value of {1} (which is generally considered as a non-optimal
+ setting).
+
+ {State}: Only table spaces in state {ONLINE} and {READONLY}
+ will be found by inventory and monitored. If the state changes
+ later, the check will {not} get critical. The state will
+ just be displayed. We assume that state changes are due
+ to normal operations.
{Size}: The logic of the size check depends on whether
autoextend is on or off. If auto extension is on, then
the still possible extensions are accounted for as free
spaces as well as the space currently free in the
data files. If auto extension is off, only the currently
- free space will be honored.
+ free space will be honored. Table spaces in state {READONLY}
+ will {not} be checked for the size.
This check needs the Check_MK {mk_oracle}-plugin installed in
the agent. Please refer to the online documentation
@@ -52,9 +66,26 @@ inventory:
[parameters]
autoextend(bool): Either {True} or {False} - depending on
wether auto extension is expected to be on or off.
-warn(int / float): Warning level for free space. If this is a float, it is considered as
percentage of the maximum size of the tablespace. If it is an integer, it is considered to
be MB of free space. If the space drops to this level or below, the check will get into
warning state.
+warn(int / float): Warning level for free space. If this is a float,
+ it is considered as percentage of the maximum size of the tablespace.
+ If it is an integer, it is considered to be MB of free space. If the
+ space drops to this level or below, the check will get into warning state.
crit(int / float): The critical level for free space.
[configuration]
-oracle_tablespaces_default_levels(int/float, int/float): The default warning and critical
levels used for inventorized checks. This is preset to {(10.0, 5.0)}.
+oracle_tablespaces_default_levels(int/float, int/float): The default warning and critical
levels
+ used for inventorized checks. This is preset to {(10.0, 5.0)}.
+
+oracle_tablespaces_check_autoext(bool): This boolean setting determines, whether
+ inventory should activate monitoring of the auto extension setting. Per default
+ this is set to {True}, so the current state of the auto extension will be
+ put into the check parameters as either {True} or {False}. If you set the
+ configuration variable to {False}, then inventory will enter {None} as
+ check parameter und thus disable the checking of the auto extensible flag
+ for newly inventorized table spaces.
+oracle_tablespaces_check_default_increment(bool): This setting does not
+ control inventory but is used live during the checking und thus affects
+ all checks, not only newly inventorized ones. Per default it is set to
+ {True}. That way the check will warn if the table space has its increment
+ size set to {1} (the ORACLE default value).
diff --git a/checks/oracle_tablespaces b/checks/oracle_tablespaces
index 26e8f9d..f244538 100644
--- a/checks/oracle_tablespaces
+++ b/checks/oracle_tablespaces
@@ -50,19 +50,31 @@
# integer: MB.
oracle_tablespaces_default_levels = (10.0, 5.0)
+# Whether to check auto extend settings
+oracle_tablespaces_check_autoext = True
+
+# Whether to check default increment size
+oracle_tablespaces_check_default_increment = True
def inventory_oracle_tablespaces(checkname, info):
tablespaces = set([])
autoextensible = set([])
for line in info:
ts = (line[0], line[2])
- if line[11] == "ONLINE":
+ if line[11] in [ "ONLINE", "READONLY" ]:
tablespaces.add(ts)
if line[4] == "YES":
autoextensible.add(ts)
- return [("%s.%s" % t,
- "(%s, oracle_tablespaces_default_levels[0],
oracle_tablespaces_default_levels[1])" % (t in autoextensible))
- for t in tablespaces]
+
+ inventory = []
+ for t in tablespaces:
+ if oracle_tablespaces_check_autoext:
+ ae = t in autoextensible
+ else:
+ ae = None # means: ignore, only display setting
+ inventory.append( ("%s.%s" % t,
+ "(%s, oracle_tablespaces_default_levels[0],
oracle_tablespaces_default_levels[1])" % ae))
+ return inventory
def check_oracle_tablespaces(item, params, info):
sid, tbsname = item.split('.')
@@ -77,12 +89,14 @@ def check_oracle_tablespaces(item, params, info):
increment_size = 0
free_space = 0
+ uses_default_increment = False
+
for line in info:
if line[0] == sid and line[2] == tbsname:
ts_status = line[11]
blocksize = int(line[10])
num_files += 1
- if line[3] in [ "AVAILABLE", "ONLINE" ]:
+ if line[3] in [ "AVAILABLE", "ONLINE",
"READONLY" ]:
num_avail += 1
current_size += blocksize * int(line[5])
used += blocksize * int(line[7])
@@ -93,6 +107,8 @@ def check_oracle_tablespaces(item, params, info):
max_size += my_max_size
free_bl = int(line[6]) - int(line[5]) # number of free extension
blocks
incsize = int(line[8]) # size of next increment in blocks
+ if incsize == 1:
+ uses_default_increment = True
incs = free_bl / incsize
num_increments += incs
increment_size += blocksize * incsize * incs
@@ -107,11 +123,9 @@ def check_oracle_tablespaces(item, params, info):
if ts_status == None:
return (3, "UNKNOWN - Tablespace not found")
- if ts_status != "ONLINE":
- return (2, "CRIT - Tablespace is not online, but %s" % ts_status)
-
- infotext = " - size %s, used %s" % \
- (get_bytes_human_readable(current_size),
+ infotext = " - %s, size %s, used %s" % \
+ (ts_status,
+ get_bytes_human_readable(current_size),
get_bytes_human_readable(used))
if num_extensible > 0:
@@ -121,12 +135,25 @@ def check_oracle_tablespaces(item, params, info):
status = 0
autoext, warn, crit = params
- if autoext and num_extensible == 0:
- infotext += ", Autoextend is off!!"
- status = 2
- elif not autoext and num_extensible > 0:
- infotext += ", Autotextend is on!!"
- status = 2
+
+ # Check increment size, should not be set to default (1)
+ if oracle_tablespaces_check_default_increment:
+ if uses_default_increment:
+ infotext += ", DEFAULT INCREMENT!"
+ status = 1
+
+ # Check autoextend status if parameter not set to None
+ if autoext != None:
+ if autoext and num_extensible == 0:
+ infotext += ", AUTOEXTEND!!"
+ status = 2
+ elif not autoext and num_extensible > 0:
+ infotext += ", NO AUTOTEXTEND!!"
+ status = 2
+ elif num_extensible > 0:
+ infotext += ", autoextend"
+ else:
+ infotext += ", no autoextend"
# warn/crit level are float => percentages of max size, otherwise MB
if type(warn) == float:
@@ -139,14 +166,16 @@ def check_oracle_tablespaces(item, params, info):
else:
crit *= 1024 * 1024
- if free_space <= crit or free_space <= warn:
- infotext += ", only %s left" % get_bytes_human_readable(free_space)
- infotext += " (levels at %s/%s)" % (
- get_bytes_human_readable(warn), get_bytes_human_readable(crit))
- if free_space <= crit:
- status = 2
- else:
- status = max(1, status)
+ # Check free space, but only if status is not READONLY
+ if ts_status != "READONLY":
+ if free_space <= crit or free_space <= warn:
+ infotext += ", only %s left" %
get_bytes_human_readable(free_space)
+ infotext += " (levels at %s/%s)" % (
+ get_bytes_human_readable(warn), get_bytes_human_readable(crit))
+ if free_space <= crit:
+ status = 2
+ else:
+ status = max(1, status)
perfdata = [ ("size", current_size, max_size - warn, max_size - crit),
("used", used),
@@ -158,4 +187,4 @@ def check_oracle_tablespaces(item, params, info):
return (status, nagios_state_names[status] + infotext, perfdata)
check_info['oracle_tablespaces'] = (check_oracle_tablespaces, "ORA %s
Tablespace", 1, inventory_oracle_tablespaces )
-
+check_config_variables.append("oracle_tablespaces_check_default_increment")