[checkmk-commits] mssql: no longer reporting a warning if relative levels have been configured for a db that has no max_size

Sebastian Herbord sh at mathias-kettner.de
Tue May 17 09:57:24 CEST 2016


Module: check_mk
Branch: master
Commit: 882b16c92de7990841c1e797f9010eba18cb3a98
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=882b16c92de7990841c1e797f9010eba18cb3a98

Author: Sebastian Herbord <sh at mathias-kettner.de>
Date:   Tue May 17 09:57:18 2016 +0200

mssql: no longer reporting a warning if relative levels have been configured for a db that has no max_size

---

 checks/mssql.include                 |   24 +++++++++++++-----------
 web/plugins/wato/check_parameters.py |    6 ++++++
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/checks/mssql.include b/checks/mssql.include
index ed4ece6..fe91584 100644
--- a/checks/mssql.include
+++ b/checks/mssql.include
@@ -57,18 +57,18 @@ def inventory_mssql_datafiles(mode, info):
 def mssql_datafiles_process_sizes(params, used_size, allocated_size, max_size, unlimited):
     def calculate_levels(levels, reference_value):
         if isinstance(levels[0], float):
-            if reference_value == -1:
-                return 0, None
-            else:
+            if reference_value != -1:
                 return map(lambda x: (x * reference_value) / 100, levels)
         elif levels[0] is not None:
             return map(lambda x: x * 1024 * 1024, levels)
-        else:
-            return None, None
+
+        return None, None
 
     if unlimited:
         max_size = -1
 
+    rel_levels = False
+
     for param_key,                name,             perf_key,         value,          reference_value in [
         ('used_levels',           "used",           "data_size",      used_size,      max_size),
         ('allocated_used_levels', "allocated used", None,             used_size,      allocated_size),
@@ -85,6 +85,8 @@ def mssql_datafiles_process_sizes(params, used_size, allocated_size, max_size, u
                     break
         else:
             warn, crit = calculate_levels(levels, reference_value)
+            if isinstance(levels[0], float):
+                rel_levels = True
 
         if crit is not None and value >= crit:
             status = 2
@@ -92,12 +94,9 @@ def mssql_datafiles_process_sizes(params, used_size, allocated_size, max_size, u
             status = 1
 
         if status > 0:
-            if warn == 0:
-                wc_msg = " (max_size is unlimited, please use absolute levels)"
-            else:
-                wc_msg = " (warn/crit at %s/%s)" % (
-                            get_bytes_human_readable(warn),
-                            get_bytes_human_readable(crit))
+            wc_msg = " (warn/crit at %s/%s)" % (
+                        get_bytes_human_readable(warn),
+                        get_bytes_human_readable(crit))
         else:
             wc_msg = ""
 
@@ -114,6 +113,9 @@ def mssql_datafiles_process_sizes(params, used_size, allocated_size, max_size, u
                         name, wc_msg), \
                     [(perf_key, value, warn, crit, 0, reference_value)]
 
+    if unlimited and rel_levels:
+        yield 0, "no maximum size", []
+
 
 def check_mssql_datafiles(item, params, info):
     max_size_sum = allocated_size_sum = used_size_sum = 0
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index d1cc396..d85c82a 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -6822,6 +6822,9 @@ register_check_parameters(
     _("MSSQL Transactionlog Sizes"),
     Dictionary(
         title = _("File Size Levels"),
+        help = _("Specify levels for transactionlogs of a database. Please note that relative "
+                 "levels will only work if there is a max_size set for the file on the database "
+                 "side."),
         elements = [
             ("used_levels", levels_absolute_or_dynamic(_("Transactionlog"), _("used"))),
             ("allocated_used_levels", levels_absolute_or_dynamic(_("Transactionlog"), _("used of allocation"))),
@@ -6840,6 +6843,9 @@ register_check_parameters(
     _("MSSQL Datafile Sizes"),
     Dictionary(
         title = _("File Size Levels"),
+        help = _("Specify levels for datafiles of a database. Please note that relative "
+                 "levels will only work if there is a max_size set for the file on the database "
+                 "side."),
         elements = [
             ("used_levels", levels_absolute_or_dynamic(_("Datafile"), _("used"))),
             ("allocated_used_levels", levels_absolute_or_dynamic(_("Datafile"), _("used of allocation"))),



More information about the checkmk-commits mailing list