[checkmk-commits] Check_MK Git: check_mk: #1949 ibm_svc_host / other license checks: now able to configure limits

Sven Rueß sr at mathias-kettner.de
Wed Feb 11 08:51:04 CET 2015


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

Author: Sven Rueß <sr at mathias-kettner.de>
Date:   Wed Feb 11 08:43:20 2015 +0100

#1949 ibm_svc_host / other license checks: now able to configure limits

The check ibm_svc_host now has configurable host limits via WATO.

Old limits:
<ul>
<li>Check shows errors in case of degraded or offline hosts</li>
<li>Check always is in a OK State</li>
</ul>

New limits:
<ul>
<li>Absolut amount of active hosts - Warning/Critical at or below</li>
<li>Absolute amout of inactive hosts - Warning/Critical at or above</li>
<li>Absolute amout of degraded hosts - Warning/Critical at or above</li>
<li>Absolute amout of offline hosts - Warning/Critical at or above</li>
<li>Absolute amout of other hosts - Warning/Critical at or above</li>
</ul>

This change has been made because it was not possible to configure limits without
warning/critical states. Now all host categories can configured independently.

---

 .werks/1949                          |   27 +++++++++++++
 ChangeLog                            |    1 +
 checks/ibm_svc_host                  |   68 ++++++++++++++++++-------------
 web/plugins/wato/check_parameters.py |   74 +++++++++++++++++++++++++++-------
 4 files changed, 127 insertions(+), 43 deletions(-)

diff --git a/.werks/1949 b/.werks/1949
new file mode 100644
index 0000000..a15fa39
--- /dev/null
+++ b/.werks/1949
@@ -0,0 +1,27 @@
+Title: ibm_svc_host / other license checks: now able to configure limits
+Level: 1
+Component: wato
+Compatible: compat
+Version: 1.2.7i1
+Date: 1423639361
+Class: feature
+
+The check ibm_svc_host now has configurable host limits via WATO.
+
+Old limits:
+<ul>
+<li>Check shows errors in case of degraded or offline hosts</li>
+<li>Check always is in a OK State</li>
+</ul>
+
+New limits:
+<ul>
+<li>Absolut amount of active hosts - Warning/Critical at or below</li>
+<li>Absolute amout of inactive hosts - Warning/Critical at or above</li>
+<li>Absolute amout of degraded hosts - Warning/Critical at or above</li>
+<li>Absolute amout of offline hosts - Warning/Critical at or above</li>
+<li>Absolute amout of other hosts - Warning/Critical at or above</li>
+</ul>
+
+This change has been made because it was not possible to configure limits without
+warning/critical states. Now all host categories can configured independently.
diff --git a/ChangeLog b/ChangeLog
index 6331393..d5e837f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -207,6 +207,7 @@
             NOTE: Please refer to the migration notes!
     * 1934 WATO Web-API: Documentation is finally available...
     * 1935 WATO Web-API: Reduced number configurable role permissions...
+    * 1949 ibm_svc_host / other license checks: now able to configure limits...
     * 1761 FIX: Ruleset search is now consistent for host & serviceparameters and manual checks
     * 1765 FIX: Fixed bug when generating nagvis backends while having sites with livestatus proxy configured...
     * 1789 FIX: Fix preview of passive checks in WATO list of services
diff --git a/checks/ibm_svc_host b/checks/ibm_svc_host
index 84ef906..4f3cb5b 100644
--- a/checks/ibm_svc_host
+++ b/checks/ibm_svc_host
@@ -31,27 +31,16 @@
 # 2:host105:2:2:online
 # 3:host106:2:2:online
 
-factory_settings['ibm_svc_host_default_levels'] = {
-    'always_ok'  : False
-}
-
 def inventory_ibm_svc_host(info):
     return [(None, None)]
 
-
-def check_ibm_svc_host_state(state, aw_ok):
-    if aw_ok:
-        return 0
-    else:
-        return state
-
 def check_ibm_svc_host(item, params, info):
     degraded = 0
     offline  = 0
     active   = 0
     inactive = 0
     other    = 0
-    status   = 0
+
     for line in info:
         if line[4] == 'degraded':
             degraded += 1
@@ -64,29 +53,52 @@ def check_ibm_svc_host(item, params, info):
         else:
             other +=1
 
-    perfdata = [ ("active",   active),
-                 ("inactive", inactive),
-                 ("degraded", degraded),
-                 ("offline",  offline),
-                 ("other",    other),
-               ]
-    yield 0, "%s hosts active, %s inactive" % (active, inactive), perfdata
+    if 'always_ok' in params:
+        # Old configuration rule
+        # This was used with only one parameter always_ok until version 1.2.7
+        perfdata = [ ("active",   active),
+                     ("inactive", inactive),
+                     ("degraded", degraded),
+                     ("offline",  offline),
+                     ("other",    other),
+                   ]
+        yield 0, "%s active, %s inactive" % (active, inactive), perfdata
 
-    aw_ok = params['always_ok'] # Needed in function check_ibm_svc_host_state
-    if degraded > 0:
-        yield check_ibm_svc_host_state(1, aw_ok), "%s degraded" % degraded
-    if offline > 0:
-        yield check_ibm_svc_host_state(2, aw_ok), "%s offline" % offline
-    if other > 0:
-        yield check_ibm_svc_host_state(1, aw_ok),  "%s in an unidentified state(!)" % other
+        if degraded > 0:
+            yield (not params['always_ok'] and 1 or 0), "%s degraded" % degraded
+        if offline > 0:
+            yield (not params['always_ok'] and 2 or 0), "%s offline" % offline
+        if other > 0:
+            yield (not params['always_ok'] and 1 or 0), "%s in an unidentified state" % other
+    else:
+        warn, crit = params.get('active_hosts', (None, None))
+
+        if crit != None and active <= crit:
+            yield 2, "%s active" % active
+        elif warn != None and active <= warn:
+            yield 1, "%s active" % active
+        else:
+            yield 0, "%s active" % active
 
+        for ident, value in [ ('inactive', inactive),
+                              ('degraded', degraded),
+                              ('offline',  offline),
+                              ('other',    other),
+                            ]:
+            warn, crit = params.get(ident+'_hosts', (None, None))
+
+            if crit != None and value >= crit:
+                state = 2
+            if warn != None and value >= warn:
+                state = 1
+            else:
+                state = 0
+            yield state, "%s %s" % (value, ident), [ (ident, value, warn, crit) ]
 
 check_info["ibm_svc_host"] = {
     "check_function"        : check_ibm_svc_host,
     "inventory_function"    : inventory_ibm_svc_host,
     "service_description"   : "Hosts",
     "has_perfdata"          : True,
-    "default_levels_variable": "ibm_svc_host_default_levels",
     "group"                 : "ibm_svc_host",
 }
-
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index fe041c7..1ff25c4 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -4650,30 +4650,74 @@ register_check_parameters(
     "first"
 )
 
+def transform_ibm_svc_host(params):
+    if 'always_ok' in params:
+        if params['always_ok'] == False:
+            params = { 'degraded_hosts': (1,1), 'offline_hosts': (1,1), 'other_hosts': (1,1) }
+        else:
+            params = {}
+    return params
 
 register_check_parameters(
     subgroup_storage,
     "ibm_svc_host",
     _("IBM SVC: Options for SVC Hosts Check "),
-    Dictionary(
-        elements = [
-            ( "always_ok",
-             DropdownChoice(
-                  title = _("Override Service State"),
-                  choices = [
-                    ( False, _("Check shows errors in case of degraded or offline hosts")),
-                    ( True, _("Check always is in a OK State") )
-                  ],
-                  )
-            )
-        ],
-        optional_keys = None,
+    Transform(
+        Dictionary(
+            elements = [
+                ( "active_hosts",
+                    Tuple(
+                        title = _("Absolute amount of active hosts"),
+                        elements = [
+                            Integer(title = _("Warning at or below"), minvalue = 0, unit = _("active hosts")),
+                            Integer(title = _("Critical at or below"), minvalue = 0, unit = _("active hosts")),
+                        ]
+                    ),
+                ),
+                ( "inactive_hosts",
+                    Tuple(
+                        title = _("Absolute amout of inactive hosts"),
+                        elements = [
+                            Integer(title = _("Warning at or above"), minvalue = 0, unit = _("inactive hosts")),
+                            Integer(title = _("Critical at or above"), minvalue = 0, unit = _("inactive hosts")),
+                        ]
+                    ),
+                ),
+                ( "degraded_hosts",
+                    Tuple(
+                        title = _("Absolute amout of degraded hosts"),
+                        elements = [
+                            Integer(title = _("Warning at or above"), minvalue = 0, unit = _("degraded hosts")),
+                            Integer(title = _("Critical at or above"), minvalue = 0, unit = _("degraded hosts")),
+                        ]
+                    ),
+                ),
+                ( "offline_hosts",
+                    Tuple(
+                        title = _("Absolute amout of offline hosts"),
+                        elements = [
+                            Integer(title = _("Warning at or above"), minvalue = 0, unit = _("offline hosts")),
+                            Integer(title = _("Critical at or above"), minvalue = 0, unit = _("offline hosts")),
+                        ]
+                    ),
+                ),
+                ( "other_hosts",
+                    Tuple(
+                        title = _("Absolute amout of other hosts"),
+                        elements = [
+                            Integer(title = _("Warning at or above"), minvalue = 0, unit = _("other hosts")),
+                            Integer(title = _("Critical at or above"), minvalue = 0, unit = _("other hosts")),
+                        ]
+                    ),
+                ),
+            ]
+        ),
+        forth = transform_ibm_svc_host,
     ),
     None,
-    "first"
+    "dict",
 )
 
-
 register_check_parameters(
     subgroup_storage,
     "disk_io",



More information about the checkmk-commits mailing list