Module: check_mk
Branch: master
Commit: 7021e302b8e2720dda3ab9129a8deaa3f2df1a9d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7021e302b8e272…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Mar 5 13:41:30 2013 +0100
cisco_qos: drop supports percentage values
fixed bug with worst state
---
ChangeLog | 4 ++--
checks/cisco_qos | 33 ++++++++++++++++++++-------------
web/plugins/wato/check_parameters.py | 20 +++++++++++++++-----
3 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 208dd4d..8b70289 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -38,8 +38,8 @@
* if.include: new configurable parameters for assumed input and output speed
* cisco_qos: new param unit: switches between bit/byte display
new param average: average the values over the given minute
- new param post can now be configured via int and float, now
- supports percentage values
+ new params post/drop can be configured via int and float
+ fixed incorrect worst state if different parameters exceed limit
* logwatch.ec: Added optional spooling to the check to prevent dataloss
when processing of current lines needs more time than max execution time
* mounts: ignore multiple occurrances of the same device
diff --git a/checks/cisco_qos b/checks/cisco_qos
index 5a20bea..a87963f 100644
--- a/checks/cisco_qos
+++ b/checks/cisco_qos
@@ -157,14 +157,6 @@ def check_cisco_qos(item, params, info):
post_warn, post_crit = params.get("post",(None, None))
drop_warn, drop_crit = params.get("drop",(None, None))
- # Convert the drop levels to byte
- if unit == "bit":
- # But only if our params where already provided in the new format
- if not had_legacy_params:
- if type(drop_warn) == int:
- drop_warn = drop_warn / 8.0
- if type(drop_crit) == int:
- drop_crit = drop_crit / 8.0
# Load values and format them
ifs = dict(info[0])
@@ -230,6 +222,20 @@ def check_cisco_qos(item, params, info):
post_warn = post_warn / 8
post_crit = post_crit / 8
+ # Determine drop warn/crit levels
+ if type(drop_warn) == float and not had_legacy_params:
+ drop_warn = bw / 100.0 * drop_warn
+ drop_crit = bw / 100.0 * drop_crit
+ # Convert the drop levels to byte
+ elif unit == "bit":
+ # But only if our params where already provided in the new format
+ if not had_legacy_params:
+ if type(drop_warn) == int:
+ drop_warn = drop_warn / 8.0
+ if type(drop_crit) == int:
+ drop_crit = drop_crit / 8.0
+
+
# Handle counter values
state = 0
infotext = ''
@@ -240,17 +246,17 @@ def check_cisco_qos(item, params, info):
perfdata_avg = []
min_value = ("0", "0.0")[unit == 'bit']
- for name, counter, warn, crit, min, max in [ ( "post", post_b, post_warn,
post_crit, min_value, bw),
+ for name, counter, warn, crit, min_val, max_val in [ ( "post", post_b,
post_warn, post_crit, min_value, bw),
( "drop", drop_b, drop_warn,
drop_crit, min_value, bw) ]:
try:
timedif, rate = get_counter("cisco_qos.%s.%s" % (name, item),
this_time, saveint(counter))
rates.append(rate)
- perfdata.append( (name, rate, warn, crit, min, max) )
+ perfdata.append( (name, rate, warn, crit, min_val, max_val) )
if average:
timedif, avg_value = get_average("cisco_qos.%s.%s.avg" % (name,
item), this_time, rate, average)
rates.append(avg_value)
- perfdata_avg.append( ("%s_avg_%d" % (name, average), avg_value,
warn, crit, min, max) )
+ perfdata_avg.append( ("%s_avg_%d" % (name, average), avg_value,
warn, crit, min_val, max_val) )
except MKCounterWrapped, e:
wrapped = True
@@ -273,14 +279,15 @@ def check_cisco_qos(item, params, info):
else:
post_rate = rates[0]
drop_rate = rates[1]
+
for what, rate, warn, crit in [ ("post", post_rate, post_warn,
post_crit),
("drop", drop_rate, drop_warn,
drop_crit) ]:
infotext += ', %s: %s' % (what, format_value(rate))
if crit is not None and rate >= crit:
- state = 2
+ state = max(2, state)
infotext += '(!!)'
elif warn is not None and rate >= warn:
- state = 1
+ state = max(1, state)
infotext += '(!)'
infotext += ', Policy-Name: %s, Int-Bandwidth: %s' % (policy_name,
format_value(bw))
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 569c6a6..30db9ea 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -1392,15 +1392,25 @@ checkgroups.append((
)
),
( "drop",
- Tuple(
+ Alternative(
title = _("Number of dropped bits or bytes per second"),
help = _("Depending on the measurement unit (defaults to bit)
you can set the warn and crit "
"levels for the number of dropped bits or
bytes"),
elements = [
- Float(title = _("Warning at"), size = 8, label =
_("bits / bytes per second")),
- Float(title = _("Critical at"), size = 8, label =
_("bits / bytes per second")),
- ]
- )
+ Tuple(
+ title = _("Percentual levels (in relation to policy
speed)"),
+ elements = [
+ Percentage(title = _("Warning at"),
max_value=1000, label = _("% of port speed")),
+ Percentage(title = _("Critical at"),
max_value=1000, label = _("% of port speed")),
+ ]
+ ),
+ Tuple(
+ elements = [
+ Integer(title = _("Warning at"), size = 8,
label = _("bits / bytes per second")),
+ Integer(title = _("Critical at"), size = 8,
label = _("bits / bytes per second")),
+ ]
+ )
+ ])
),
]),
TextAscii(