Module: check_mk
Branch: master
Commit: aa0f043002d9345bd3a8190e9f64dec9954120e7
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=aa0f043002d934…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Jan 2 10:59:57 2012 +0100
if/if64/lnx_if: pad port numbers with zeros in order to sort correctly.
---
.bugs/131 | 7 +++++--
ChangeLog | 2 ++
checkman/if | 5 +++++
checkman/if64 | 5 +++++
checkman/lnx_if | 5 +++++
checks/if.include | 20 +++++++++++++++++---
web/plugins/wato/check_mk_configuration.py | 12 ++++++++++++
7 files changed, 51 insertions(+), 5 deletions(-)
diff --git a/.bugs/131 b/.bugs/131
index cd10ed2..b826b71 100644
--- a/.bugs/131
+++ b/.bugs/131
@@ -1,10 +1,10 @@
Title: if checks: Add 0 prefix on port numbers below 10
Component: core
+State: done
+Class: todo
Benefit: 3
-State: open
Cost: 5
Date: 2011-02-11 11:17:50
-Class: todo
Targetversion: 1.2.0
When monitoring switches the services are ordered as follows:
@@ -28,3 +28,6 @@ Look at brocade_fcport for details.
Also we could make this configurable in order not to break existing
checks.
+
+2012-01-02 10:59:50: changed state open -> done
+Is done and switchable off with if_inventory_pad_portnumbers
diff --git a/ChangeLog b/ChangeLog
index e83dba2..7805173 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,8 @@
If you have changed the trend range, then your historic values will
be displayed in a wrong scale. On the other hand - from now on changes
in the range-setting will not affect the graph anymore.
+ * if/if64/lnx_if: pad port numbers with zeros in order to sort correctly.
+ This can be turned off with if_inventory_pad_portnumbers = False.
1.1.13i2:
Core, Setup, etc.:
diff --git a/checkman/if b/checkman/if
index f31f46d..f65ab36 100644
--- a/checkman/if
+++ b/checkman/if
@@ -107,6 +107,11 @@ if_inventory_portstates (list of strings): Per default this variable is set to {
only ports found in the state {up} are being added to the monitoring. If you set this to {['1', '2', '5']} then
also ports in state {down} and {dormant} will be monitored.
+if_inventory_pad_portnumbers (boolean): If this is set to {True} (the default), then port numbers used as
+ items are padded with zeroes so that all items have the same length and ports will sort correctly in
+ the GUI. You can set this to {False} if you want to keep the same service descriptions as in versions
+ prior to 1.1.13i3.
+
if_inventory_uses_description (boolean): Whether inventory should use the interface description as item (instead
of the interface index). Default is {False}.
diff --git a/checkman/if64 b/checkman/if64
index 6980812..23c3666 100644
--- a/checkman/if64
+++ b/checkman/if64
@@ -108,6 +108,11 @@ if_inventory_portstates (list of strings): Per default this variable is set to {
only ports found in the state {up} are being added to the monitoring. If you set this to {['1', '2', '5']} then
also ports in state {down} and {dormant} will be monitored.
+if_inventory_pad_portnumbers (boolean): If this is set to {True} (the default), then port numbers used as
+ items are padded with zeroes so that all items have the same length and ports will sort correctly in
+ the GUI. You can set this to {False} if you want to keep the same service descriptions as in versions
+ prior to 1.1.13i3.
+
if_inventory_uses_description (boolean): Whether inventory should use the interface description as item (instead
of the interface index). Default is {False}.
diff --git a/checkman/lnx_if b/checkman/lnx_if
index 272fe36..020e273 100644
--- a/checkman/lnx_if
+++ b/checkman/lnx_if
@@ -114,6 +114,11 @@ if_inventory_portstates (list of strings): Per default this variable is set to {
only ports found in the state {up} are being added to the monitoring. If you set this to {['1', '2', '4']} then
also ports in state {down} and {unknown} will be monitored.
+if_inventory_pad_portnumbers (boolean): If this is set to {True} (the default), then port numbers used as
+ items are padded with zeroes so that all items have the same length and ports will sort correctly in
+ the GUI. You can set this to {False} if you want to keep the same service descriptions as in versions
+ prior to 1.1.13i3.
+
if_inventory_uses_description (boolean): Whether inventory should use the interface name as item (instead
of the interface index). Default is {False}.
diff --git a/checks/if.include b/checks/if.include
index 85c57a0..1c96cbc 100644
--- a/checks/if.include
+++ b/checks/if.include
@@ -30,6 +30,7 @@ if_inventory_porttypes = [ '6', '32', '117' ]
if_inventory_portstates = [ '1' ]
if_inventory_uses_description = False
if_inventory_uses_alias = False
+if_inventory_pad_portnumbers = True
if_inventory_monitor_speed = True
if_inventory_monitor_state = True
@@ -71,6 +72,18 @@ def if_statename(st):
'7': 'lowerLayerDown' }
return names.get(st, st)
+
+# Pads port numbers with zeroes, so that items
+# nicely sort alphabetically
+def if_pad_with_zeroes(info, ifIndex):
+ if if_inventory_pad_portnumbers:
+ max_index = max([int(line[0]) for line in info])
+ digits = len(str(max_index))
+ return ("%0"+str(digits)+"d") % int(ifIndex)
+ else:
+ return ifIndex
+
+
def inventory_if_common(info):
if len(info) == 0 or len(info[0]) != 19:
return []
@@ -91,7 +104,7 @@ def inventory_if_common(info):
elif if_inventory_uses_alias and ifAlias:
item = ifAlias
else:
- item = ifIndex
+ item = if_pad_with_zeroes(info, ifIndex)
if item in seen_items: # duplicate
duplicate.add(item)
@@ -147,7 +160,7 @@ def check_if_common(item, params, info):
ifDescr = cleanup_if_strings(ifDescr)
ifAlias = cleanup_if_strings(ifAlias)
- if item == ifIndex \
+ if item.lstrip("0") == ifIndex \
or item == ifAlias \
or item == ifDescr \
or item == "%s %s" % (ifAlias, ifIndex) \
@@ -155,7 +168,8 @@ def check_if_common(item, params, info):
# Display port number or alias in infotext if that is not part
# of the service description anyway
- if item == ifIndex and (item == ifAlias or ifAlias == '') \
+ if item.lstrip("0") == ifIndex \
+ and (item == ifAlias or ifAlias == '') \
and (item == ifDescr or ifDescr == ''): # description trivial
infotext = ""
elif item == "%s %s" % (ifAlias, ifIndex) and ifDescr != '': # non-unique Alias
diff --git a/web/plugins/wato/check_mk_configuration.py b/web/plugins/wato/check_mk_configuration.py
index 468f594..78caade 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -368,6 +368,18 @@ register_configvar(group,
"parameters via a rule.")))
register_configvar(group,
+ "if_inventory_pad_portnumbers",
+ Checkbox(title = _("Pad port numbers with zeroes"),
+ label = _("pad port numbers"),
+ help = _("If this option is activated then Check_MK will pad port numbers of "
+ "network interfaces with zeroes so that all port descriptions from "
+ "all ports of a host or switch have the same length and thus sort "
+ "currectly in the GUI. In versions prior to 1.1.13i3 there was no "
+ "padding. You can switch back to the old behaviour by disabling this "
+ "option. This will retain the old service descriptions and the old "
+ "performance data.")))
+
+register_configvar(group,
"if_inventory_uses_description",
Checkbox(title = _("Use description as service name for network interface checks"),
label = _("use description"),
Module: check_mk
Branch: master
Commit: 2a2ac976f37a6309798707b36e10fd00389d7bf5
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2a2ac976f37a63…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Jan 2 10:32:08 2012 +0100
Updated bug entries #0128
---
.bugs/128 | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/.bugs/128 b/.bugs/128
index ff2b7b6..47dca1e 100644
--- a/.bugs/128
+++ b/.bugs/128
@@ -1,12 +1,12 @@
Title: df trends: Peak values after changing the trend_range
Component: checks
-State: open
-Class: bug
-Date: 2011-02-10 09:45:24
Benefit: 1
-Cost: 2
Fun: 0
+State: done
+Cost: 2
+Date: 2011-02-10 09:45:24
Targetversion: 1.2.0
+Class: bug
After changing the trend_range to a larger time the check reports a peak
value which is wrong. It might be needed to detect such a change and reset
@@ -44,3 +44,7 @@ range than 24h.
We will do this after 1.1.11i3 is out.
+
+2012-01-02 10:32:06: changed state open -> done
+Is done like described. Throrough testing will need some time,
+though...