Module: check_mk
Branch: master
Commit: c25d5d2b44eae3ae34e360c939dcd1ef1a002ecd
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c25d5d2b44eae3…
Author: Bernd Stroessenreuther <bs(a)mathias-kettner.de>
Date: Mon Dec 2 12:59:40 2013 +0100
brocade_mlx: naming of checks and items better complies to standards now
---
checkman/brocade_mlx.module_cpu | 4 ++--
checkman/brocade_mlx.module_mem | 4 ++--
checkman/brocade_mlx_temp | 6 +++---
checks/brocade_mlx | 17 +++++++++--------
checks/brocade_mlx_temp | 14 +++++---------
5 files changed, 21 insertions(+), 24 deletions(-)
diff --git a/checkman/brocade_mlx.module_cpu b/checkman/brocade_mlx.module_cpu
index ec8be8b..c23c98a 100644
--- a/checkman/brocade_mlx.module_cpu
+++ b/checkman/brocade_mlx.module_cpu
@@ -24,12 +24,12 @@ examples:
# Check Module with ID 33 on a box called my-mlx-device with default levels
checks += [
- ("my-mlx-device", "brocade_mlx.module_cpu", '33 NI-MLX-32_MR
Management Module', brocade_mlx_cpu_default_levels),
+ ("my-mlx-device", "brocade_mlx.module_cpu", '33 NI-MLX-32_MR
Management', brocade_mlx_cpu_default_levels),
]
# or use individual levels for warn and crit
checks += [
- ("my-mlx-device", "brocade_mlx.module_cpu", '33 NI-MLX-32_MR
Management Module', { "levels": (75.0, 85.0) }),
+ ("my-mlx-device", "brocade_mlx.module_cpu", '33 NI-MLX-32_MR
Management', { "levels": (75.0, 85.0) }),
]
perfdata:
diff --git a/checkman/brocade_mlx.module_mem b/checkman/brocade_mlx.module_mem
index bf20e69..e2bff6e 100644
--- a/checkman/brocade_mlx.module_mem
+++ b/checkman/brocade_mlx.module_mem
@@ -20,12 +20,12 @@ examples:
# Check Module with ID 33 on a box called my-mlx-device with default levels
checks += [
- ("my-mlx-device", "brocade_mlx.module_mem", '33 NI-MLX-32_MR
Management Module', brocade_mlx_mem_default_levels),
+ ("my-mlx-device", "brocade_mlx.module_mem", '33 NI-MLX-32_MR
Management', brocade_mlx_mem_default_levels),
]
# or use individual levels for warn and crit
checks += [
- ("my-mlx-device", "brocade_mlx.module_mem", '33 NI-MLX-32_MR
Management Module', { "levels": (75.0, 85.0) }),
+ ("my-mlx-device", "brocade_mlx.module_mem", '33 NI-MLX-32_MR
Management', { "levels": (75.0, 85.0) }),
]
perfdata:
diff --git a/checkman/brocade_mlx_temp b/checkman/brocade_mlx_temp
index 3f89697..4d555aa 100644
--- a/checkman/brocade_mlx_temp
+++ b/checkman/brocade_mlx_temp
@@ -12,7 +12,7 @@ description:
{OK} is returned otherwise.
item:
- The description of the module as provided by SNMP.
+ The description of the module together with its ID as provided by SNMP.
examples:
# set default levels to 30°C and 40°C:
@@ -21,12 +21,12 @@ examples:
# Check sensors of Switch Fabric module 0 on a box called my-mlx-device with
# default levels
checks += [
- ("my-mlx-device", "brocade_mlx.temperature", 'Switch Fabric
module 0', brocade_mlx_temperature_default_levels)
+ ("my-mlx-device", "brocade_mlx.temperature", 'Switch Fabric
Module 35', brocade_mlx_temperature_default_levels)
]
# or use individual levels for warn and crit
checks += [
- ("my-mlx-device", "brocade_mlx.temperature", 'Switch Fabric
module 0', (40, 50)
+ ("my-mlx-device", "brocade_mlx.temperature", 'Switch Fabric
Module 35', (40, 50)
]
perfdata:
diff --git a/checks/brocade_mlx b/checks/brocade_mlx
index 9b792ab..8d7ccf4 100644
--- a/checks/brocade_mlx
+++ b/checks/brocade_mlx
@@ -33,10 +33,11 @@ brocade_mlx_info = [ ('.1.3.6.1.4.1.1991.1.1.2.2.1.1', [ 1, 2,
12, 24, 25 ]),
def brocade_mlx_scan(oid):
return
oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.1991.1.")
-def combine_item(id, descr):
+def combine_item_default(id, descr):
if descr == "":
return id
else:
+ descr = re.sub(" *Module", "", descr)
return "%s %s" % (id, descr)
@@ -49,12 +50,12 @@ def inventory_brocade_mlx_module(info):
for module_id, module_descr, module_state, mem_total, mem_avail in info[0]:
# do not inventorize modules reported as empty
if module_state != "0":
- inventory.append( (combine_item(module_id, module_descr), None) )
+ inventory.append( (combine_item_default(module_id, module_descr), None) )
return inventory
def check_brocade_mlx_module(item, _no_params, info):
for module_id, module_descr, module_state, mem_total, mem_avail in info[0]:
- if combine_item(module_id, module_descr) == item:
+ if combine_item_default(module_id, module_descr) == item:
if module_state == "0":
return 1, "Module reports status 0 (empty)"
elif module_state == "2":
@@ -74,7 +75,7 @@ def check_brocade_mlx_module(item, _no_params, info):
check_info["brocade_mlx.module_status"] = {
"check_function" : check_brocade_mlx_module,
"inventory_function" : inventory_brocade_mlx_module,
- "service_description" : "Line module %s Status",
+ "service_description" : "Status Module %s",
"snmp_info" : brocade_mlx_info,
"snmp_scan_function" : brocade_mlx_scan,
"has_perfdata" : False,
@@ -92,13 +93,13 @@ def inventory_brocade_mlx_module_mem(info):
# do not inventorize modules reported as empty
# and: monitor memory only on NI-MLX modules
if module_state != "0" and
module_descr.startswith("NI-MLX"):
- inventory.append( (combine_item(module_id, module_descr),
"brocade_mlx_mem_default_levels") )
+ inventory.append( (combine_item_default(module_id, module_descr),
"brocade_mlx_mem_default_levels") )
return inventory
def check_brocade_mlx_module_mem(item, params, info):
warn, crit = params["levels"]
for module_id, module_descr, module_state, mem_total, mem_avail in info[0]:
- if combine_item(module_id, module_descr) == item:
+ if combine_item_default(module_id, module_descr) == item:
if module_state != "10":
return 3, "Module is not in state running"
@@ -153,13 +154,13 @@ def inventory_brocade_mlx_module_cpu(info):
# do not inventorize modules reported as empty
# and: monitor cpu only on NI-MLX modules
if module_state != "0" and
module_descr.startswith("NI-MLX"):
- inventory.append( (combine_item(module_id, module_descr),
"brocade_mlx_cpu_default_levels") )
+ inventory.append( (combine_item_default(module_id, module_descr),
"brocade_mlx_cpu_default_levels") )
return inventory
def check_brocade_mlx_module_cpu(item, params, info):
warn, crit = params["levels"]
for module_id, module_descr, module_state, mem_total, mem_avail in info[0]:
- if combine_item(module_id, module_descr) == item:
+ if combine_item_default(module_id, module_descr) == item:
if module_state != "10":
return 3, "Module is not in state running"
diff --git a/checks/brocade_mlx_temp b/checks/brocade_mlx_temp
index 09aae0f..60658bd 100644
--- a/checks/brocade_mlx_temp
+++ b/checks/brocade_mlx_temp
@@ -30,27 +30,23 @@ brocade_mlx_temp_info = ('.1.3.6.1.4.1.1991.1.1.2.13.1.1', [
3, OID_END, 4 ])
def brocade_mlx_scan(oid):
return
oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.1991.1.")
-def combine_item(id, descr):
- if descr == "":
- return id
- else:
- return "%s %s" % (id, descr)
-
#############################################################################
# Temperature Sensors
#############################################################################
brocade_mlx_temperature_default_levels = (50, 60)
-def compose_item(name):
+def compose_item(id, name):
+ id = re.sub("\.[0-9]+", "", id)
name = re.sub(" *temperature", "", name)
name = re.sub(", sensor [0-9]+", "", name)
+ name = re.sub("module ?[0-9]*", "Module %s" % id, name)
return name
def inventory_brocade_mlx_temp(info):
inventory = []
for temp_descr, temp_id, temp_value in info:
- temp_descr = compose_item(temp_descr)
+ temp_descr = compose_item(temp_id, temp_descr)
if ((temp_descr, "brocade_mlx_temperature_default_levels") not in
inventory):
inventory.append( (temp_descr,
"brocade_mlx_temperature_default_levels") )
return inventory
@@ -64,7 +60,7 @@ def check_brocade_mlx_temp(item, params, info):
for temp_descr, temp_id, temp_value in info:
# Info from the MIB: "Each unit is 0.5 degrees Celcius."
temp_value = int(temp_value) / 2
- current_item = compose_item(temp_descr)
+ current_item = compose_item(temp_id, temp_descr)
if current_item == item:
# OID_END needs to be used for sensor id because especially
# Active management modules may have more temperature sensors