Module: check_mk
Branch: master
Commit: 1f6ba3f43eb47b20be40886026c94f6c3fdeb186
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1f6ba3f43eb47b…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Feb 5 20:52:21 2013 +0100
Add: oracle_tablespaces with magic number and
WATO configuration
---
ChangeLog | 2 +
checks/oracle_tablespaces | 98 ++++++++++++++++++++++++++++-----
web/plugins/wato/check_parameters.py | 56 +++++++++++++++++++
3 files changed, 141 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 977dc9b..468ae96 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -32,6 +32,7 @@
* if: Inventory settings can now be set host based
* FIX: lnx_bonding/ovs_bonding: correct definition of bonding.include
* Add: if check now able to handle interface groups (if_groups)
+ * Add: oracle_tablespace now with flexible warn/crit levels(magic number)
Multisite:
* Added comment painter to notification related views
@@ -51,6 +52,7 @@
* FIX: Fixed generation of auth.php (Needed for NagVis Multisite Authorisation)
* FIX: Fixed missing general.* permissions in auth.php on slave sites in
case of distributed WATO setups
+ * Added oracle_tablespaces configuration to the application checkgroup
Event Console:
* Added UNIX socket for sending events to the EC
diff --git a/checks/oracle_tablespaces b/checks/oracle_tablespaces
index 87f2a67..273fa0f 100644
--- a/checks/oracle_tablespaces
+++ b/checks/oracle_tablespaces
@@ -7,7 +7,7 @@
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
-# | Copyright Mathias Kettner 2013 mk(a)mathias-kettner.de |
+# | Copyright Mathias Kettner 2012 mk(a)mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
@@ -47,10 +47,20 @@
# 11. status of the table space
# 12. free space in the datafile
+
+# This definition needs to be removed at a later stage
+# A previous version of this check didn't write the parameter
+# name into the autochecks file, but the parameter itself
# default levels for *free* space. float: percent,
# integer: MB.
oracle_tablespaces_default_levels = (10.0, 5.0)
+factory_settings["oracle_tablespaces_default_levels"] = {
+ "levels" : (10.0, 5.0),
+ "magic_normsize" : 1000,
+ "levels_low" : (0.0, 0.0)
+}
+
# Whether to check auto extend settings
oracle_tablespaces_check_autoext = True
@@ -75,10 +85,62 @@ def inventory_oracle_tablespaces(info):
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))
+
+ parameters = { "autoextend" : ae }
+ inventory.append(("%s.%s" % t, parameters))
return inventory
+
+def get_tablespace_levels_in_bytes(size_bytes, params):
+ # If the magic factor is used, take table size and magic factor
+ # into account in order to move levels
+ magic = params.get("magic")
+ warn, crit = params.get("levels")
+
+ if magic:
+ # convert warn/crit to percentage
+ if type(warn) != float:
+ warn = savefloat(warn * 1024 * 1024 / float(size_bytes)) * 100
+ if type(crit) != float:
+ crit = savefloat(crit * 1024 * 1024 / float(size_bytes)) * 100
+
+ normsize = params["magic_normsize"]
+ hbytes_size = size_bytes / (float(normsize) * 1024 * 1024)
+ felt_size = hbytes_size ** magic
+ scale = felt_size / hbytes_size
+ warn_scaled = 100 - (( 100 - warn ) * scale)
+ crit_scaled = 100 - (( 100 - crit ) * scale)
+
+ # Make sure, levels do never get too low due to magic factor
+ lowest_warning_level, lowest_critical_level = params["levels_low"]
+ if warn_scaled < lowest_warning_level:
+ warn_scaled = lowest_warning_level
+ if crit_scaled < lowest_critical_level:
+ crit_scaled = lowest_critical_level
+ warn_bytes = savefloat(size_bytes * warn_scaled / 100)
+ crit_bytes = savefloat(size_bytes * crit_scaled / 100)
+ else:
+ # warn/crit level are float => percentages of max size, otherwise MB
+ if type(warn) == float:
+ warn_bytes = warn / 100.0 * size_bytes
+ else:
+ warn_bytes = warn * 1024 * 1024
+
+ if type(crit) == float:
+ crit_bytes = crit / 100.0 * size_bytes
+ else:
+ crit_bytes = crit * 1024 * 1024
+
+ warn_scaled = savefloat(warn_bytes / size_bytes * 100)
+ crit_scaled = savefloat(crit_bytes / size_bytes * 100)
+
+
+ levels = {}
+ levels["levels_bytes"] = (warn_bytes, crit_bytes)
+ levels["levels_text"] = "(levels at %.1f/%.1f%%)" % (warn_scaled,
crit_scaled)
+ return levels
+
+
def check_oracle_tablespaces(item, params, info):
sid, tbsname = item.split('.')
ts_status = None
@@ -91,7 +153,12 @@ def check_oracle_tablespaces(item, params, info):
num_increments = 0
increment_size = 0
free_space = 0
+
+ # Conversion of old autochecks params
+ if type(params) == tuple:
+ params = { "autoextend" : params[0], "levels" : params[1:] }
+ autoext = params.get("autoextend")
uses_default_increment = False
for line in info:
@@ -132,6 +199,8 @@ def check_oracle_tablespaces(item, params, info):
if ts_status == None:
return (3, "UNKNOWN - Tablespace not found")
+
+
infotext = " - %s, size %s, used %s" % \
(ts_status,
@@ -144,7 +213,6 @@ def check_oracle_tablespaces(item, params, info):
(num_increments, get_bytes_human_readable(increment_size))
status = 0
- autoext, warn, crit = params
# Check increment size, should not be set to default (1)
if oracle_tablespaces_check_default_increment:
@@ -165,16 +233,9 @@ def check_oracle_tablespaces(item, params, info):
else:
infotext += ", no autoextend"
- # warn/crit level are float => percentages of max size, otherwise MB
- if type(warn) == float:
- warn = warn / 100.0 * max_size
- else:
- warn *= 1024 * 1024
- if type(crit) == float:
- crit = crit / 100.0 * max_size
- else:
- crit *= 1024 * 1024
+ level_info = get_tablespace_levels_in_bytes(max_size, params)
+ warn, crit = level_info.get("levels_bytes")
# Check free space, but only if status is not READONLY
if ts_status != "READONLY":
@@ -196,6 +257,13 @@ 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_info['oracle_tablespaces'] = {
+ "service_description" : "ORA %s Tablespace",
+ "check_function" : check_oracle_tablespaces,
+ "inventory_function" : inventory_oracle_tablespaces,
+ "has_perfdata" : True,
+ "group" : "oracle_tablespaces",
+ "default_levels_variable" : "oracle_tablespaces_default_levels",
+ "includes" : [ "oracle.include" ]
+}
check_config_variables.append("oracle_tablespaces_check_default_increment")
-check_includes['oracle_tablespaces'] = [ "oracle.include" ]
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 380c156..9fc22f4 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -1413,6 +1413,62 @@ checkgroups.append((
checkgroups.append((
subgroup_applications,
+ "oracle_tablespaces",
+ _("Oracle Tablespaces"),
+ Dictionary(
+ elements = [
+ ( "levels",
+ Alternative(
+ title = _("Total Memory Levels"),
+ elements = [
+ Tuple(
+ title = _("Percentage levels of free maximum
space"),
+ elements = [
+ Percentage(title = _("Warning at"), label =
_("free")),
+ Percentage(title = _("Critical at"), label =
_("free")),
+ ]
+ ),
+ Tuple(
+ title = _("Absolute free space"),
+ elements = [
+ Integer(title = _("Warning lower than"), unit =
_("MB")),
+ Integer(title = _("Critical lower than"), unit
= _("MB")),
+ ]
+ )
+ ])),
+ ( "magic",
+ Float(
+ title = _("Magic factor (automatic level adaptation for large
tablespaces)"),
+ minvalue = 0.1,
+ maxvalue = 1.0)),
+ ( "magic_normsize",
+ Integer(
+ title = _("Reference size for magic factor"),
+ minvalue = 1,
+ default_value = 1000,
+ label = _("MB"))),
+ ( "levels_low",
+ Tuple(
+ title = _("Minimum levels if using magic factor"),
+ help = _("The tablespace levels will never fall below these
values, when using "
+ "the magic factor and the tablespace is very
small."),
+ elements = [
+ Percentage(title = _("Warning at"), label =
_("usage"), allow_int = True),
+ Percentage(title = _("Critical at"), label =
_("usage"), allow_int = True)])),
+ ( "autoextend",
+ Checkbox(
+ title = _("Autoextend"),
+ label = _("Autoextension is expected"),
+ help = _(""))),
+ ]),
+ TextAscii(
+ title = _("Service descriptions"),
+ allow_empty = False),
+ None))
+
+
+checkgroups.append((
+ subgroup_applications,
"oracle_logswitches",
_("Oracle Logswitches"),
Tuple(