Module: check_mk
Branch: master
Commit: 10cecc5504f15259a77fd10ddc3c709922ca964d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=10cecc5504f152…
Author: Goetz Golla <gg(a)mathias-kettner.de>
Date: Mon Aug 18 14:27:21 2014 +0200
#0646 brocade_fcport: the administrative states for which ports are inventorized can now
be configured in WATO
---
.werks/646 | 7 +++++
ChangeLog | 1 +
checks/brocade_fcport | 17 ++++++++-----
web/plugins/wato/check_mk_configuration.py | 8 +++++-
web/plugins/wato/check_parameters.py | 38 ++++++++++++++++++++++++++--
5 files changed, 62 insertions(+), 9 deletions(-)
diff --git a/.werks/646 b/.werks/646
new file mode 100644
index 0000000..16c8fbc
--- /dev/null
+++ b/.werks/646
@@ -0,0 +1,7 @@
+Title: brocade_fcport: the administrative states for which ports are inventorized can now
be configured in WATO
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i6
+Date: 1408364635
+Class: feature
diff --git a/ChangeLog b/ChangeLog
index 82c8865..1a75065 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -24,6 +24,7 @@
* 0644 adva_fsp_if: instead of lower warning and critical levels check now supports
lower and upper levels
NOTE: Please refer to the migration notes!
* 1006 printer_pages: add Perf-O-Meter and PNP template
+ * 0646 brocade_fcport: the administrative states for which ports are inventorized can
now be configured in WATO
* 1051 FIX: tcp_conn_stats: fix missing performance data...
* 1142 FIX: winperf_ts_sessions: fix computation, check has never really worked
* 1090 FIX: zfsget: fixed exception which happened on incomplete zfs entries
diff --git a/checks/brocade_fcport b/checks/brocade_fcport
index f4bc421..150d9d6 100644
--- a/checks/brocade_fcport
+++ b/checks/brocade_fcport
@@ -42,7 +42,7 @@ brocade_fcport_inventory_opstates = [ 1, 2, 3, 4, ]
brocade_fcport_inventory_admstates = [ 1, 3, 4, ]
brocade_fcport_inventory_use_portname = True # use swFCPortName as part of service
description
brocade_fcport_inventory_show_isl = True # add "ISL" to service description
for interswitch links
-
+brocade_fcport_inventory = []
factory_settings["brocade_fcport_default_levels"] = {
@@ -55,12 +55,12 @@ factory_settings["brocade_fcport_default_levels"] = {
# Helper function for computing item from port number
-def brocade_fcport_getitem(ports, index, portname, is_isl):
+def brocade_fcport_getitem(ports, index, portname, is_isl, uses_portname, shows_isl):
int_len = str(len(str(len(ports))))
itemname = ("%0" + int_len + "d") % (index - 1)
- if is_isl and brocade_fcport_inventory_show_isl:
+ if is_isl and shows_isl:
itemname += " ISL"
- if portname.strip() and brocade_fcport_inventory_use_portname:
+ if portname.strip() and uses_portname:
itemname += " " + portname.strip()
return itemname
@@ -70,6 +70,11 @@ def inventory_brocade_fcport(info):
if len(info) < 2:
return
+ settings = host_extra_conf_merged(g_hostname, brocade_fcport_inventory)
+ uses_portname = settings.get('use_portname',
brocade_fcport_inventory_use_portname)
+ shows_isl = settings.get('show_isl',
brocade_fcport_inventory_show_isl)
+ admstates = settings.get('admstates',
brocade_fcport_inventory_admstates)
+
inventory = []
isl_ports = {}
if len(info) > 1:
@@ -87,11 +92,11 @@ def inventory_brocade_fcport(info):
portname = line[13]
is_isl = line[0] in isl_ports
- if admstate in brocade_fcport_inventory_admstates and \
+ if admstate in admstates and \
opstate in brocade_fcport_inventory_opstates and \
phystate in brocade_fcport_inventory_phystates:
- inventory.append(( brocade_fcport_getitem(info[0], index, portname,
is_isl),
+ inventory.append(( brocade_fcport_getitem(info[0], index, portname,
is_isl, uses_portname, shows_isl),
'{ "phystate": [%d], "opstate": [%d],
"admstate": [%d] }'
% (phystate, opstate, admstate) ))
diff --git a/web/plugins/wato/check_mk_configuration.py
b/web/plugins/wato/check_mk_configuration.py
index 370efdb..5aaa2a7 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -1247,7 +1247,6 @@ register_configvar(group,
-
_if_portstate_choices = [
( '1', 'up(1)'),
( '2', 'down(2)'),
@@ -1258,6 +1257,13 @@ _if_portstate_choices = [
( '7', 'lowerLayerDown(7)'),
]
+_brocade_fcport_adm_choices = [
+ ( 1, 'online(1)'),
+ ( 2, 'offline(2)'),
+ ( 3, 'testing(3)'),
+ ( 4, 'faulty(4)'),
+ ]
+
_if_porttype_choices = [
("1", "other(1)" ), ("2", "regular1822(2)" ),
("3", "hdh1822(3)" ), ("4", "ddnX25(4)" ),
("5", "rfc877x25(5)" ), ("6",
"ethernetCsmacd(6)" ), ("7", "iso88023Csmacd(7)" ),
("8",
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 4a69f77..c186757 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -141,7 +141,7 @@ register_rule(group + '/' + subgroup_inventory,
match = 'all',
)
-#dublicate: check_mk_configuration.py
+#duplicate: check_mk_configuration.py
_if_portstate_choices = [
( '1', 'up(1)'),
( '2', 'down(2)'),
@@ -152,7 +152,7 @@ _if_portstate_choices = [
( '7', 'lowerLayerDown(7)'),
]
-#dublicate: check_mk_configuration.py
+#duplicate: check_mk_configuration.py
_if_porttype_choices = [
("1", "other(1)" ), ("2", "regular1822(2)" ),
("3", "hdh1822(3)" ), ("4", "ddnX25(4)" ),
("5", "rfc877x25(5)" ), ("6",
"ethernetCsmacd(6)" ), ("7", "iso88023Csmacd(7)" ),
("8",
@@ -273,6 +273,40 @@ register_rule(group + '/' + subgroup_inventory,
)
register_rule(group + '/' + subgroup_inventory,
+ varname = "brocade_fcport_inventory",
+ title = _("Brocade Port Inventory"),
+ valuespec = Dictionary(
+ elements = [
+ ("use_portname", Checkbox(
+ title = _("Use port name as service name"),
+ label = _("use port name"),
+ default_value = True,
+ help = _("This option lets Check_MK use the port name as item
instead of the "
+ "port number. If no description is available then the port
number is "
+ "used anyway."))),
+ ("show_isl", Checkbox(
+ title = _("add \"ISL\" to service description for
interswitch links"),
+ label = _("add ISL"),
+ default_value = True,
+ help = _("This option lets Check_MK add the string \"ISL\"
to the service "
+ "description for interswitch links."))),
+ ("admstates", ListChoice(title = _("Administrative port states to
inventorize"),
+ help = _("When doing inventory on brocade switches only ports with
the given administrative "
+ "states will be added to the monitoring system."),
+ choices = _brocade_fcport_adm_choices,
+ columns = 1,
+ toggle_all = True,
+ default_value = ['1', '3', '4' ],
+ )),
+ ],
+ help = _('This mule can be used to control the inventory for brocade ports.
'
+ 'You can configure the port states for inventory '
+ 'and the use of the description as service name.'),
+ ),
+ match = 'dict',
+)
+
+register_rule(group + '/' + subgroup_inventory,
varname = "inventory_processes_rules",
title = _('Process Inventory'),
help = _("Keep in mind that all configuration parameters in this rule are
only applied during the hosts inventory. "