Module: check_mk
Branch: master
Commit: b5ac0e54f245b9f7246d92683a3df20ba8115bd8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b5ac0e54f245b9…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon May 23 16:52:32 2011 +0200
brocade_fcport: add speed information to output
---
checks/brocade_fcport | 26 ++++++++++++++------------
modules/agent_simulator.py | 2 +-
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/checks/brocade_fcport b/checks/brocade_fcport
index 7da3826..fe851fd 100644
--- a/checks/brocade_fcport
+++ b/checks/brocade_fcport
@@ -98,12 +98,11 @@ def inventory_brocade_fcport(checkname, info):
def check_brocade_fcport(item, params, info):
# Accept item, even if port name or ISL state has changed
- item_index = int(item.split()[0]) + 1 # we substracted 1 at inventory
- portinfo = [ line for line in info[0] if int(line[0]) == item_index ]
+ item_index = int(item.split()[0])
+ portinfo = [ line for line in info[0] if int(line[0]) == item_index + 1]
index, phystate, opstate, admstate, txwords, rxwords, txframes, rxframes, \
notxcredits, rxcrcs, rxencoutframes, c3discards, speed = map(int,
portinfo[0][:-1])
-
summarystate = 0
output = []
perfdata = []
@@ -123,15 +122,16 @@ def check_brocade_fcport(item, params, info):
gbit = float(brocade_fcport_speed[speed].replace("Gbit",
""))
speedmsg = ("%.0fGbit/s" % gbit)
+ output.append(speedmsg)
# convert gbit netto link-rate to Byte/s (8/10 enc)
- wirespeed = gbit * 0.8 * 1000000.0 / 8
+ wirespeed = gbit * 1000000000.0 * 0.8 / 8
# Now check rates of various error counters
this_time = time.time()
try:
- timedif, rxwords_rate = get_counter("brocade_fcport.rxwords.%s" %
index, this_time, rxwords)
- timedif, txwords_rate = get_counter("brocade_fcport.txwords.%s" %
index, this_time, txwords)
+ timedif, rxwords_rate = get_counter("brocade_fcport.rxwords.%s" %
index, this_time, rxwords)
+ timedif, txwords_rate = get_counter("brocade_fcport.txwords.%s" %
index, this_time, txwords)
# compute traffic in B/s and MB/s
in_bytes = rxwords_rate * 4
@@ -148,12 +148,12 @@ def check_brocade_fcport(item, params, info):
warn, crit = bw_thresh
if type(warn) == float:
warn_bytes = wirespeed * warn / 100.0
- else:
- warn_bytes = warn / 1048576.0
+ else: # in MB
+ warn_bytes = warn * 1048576.0
if type(crit) == float:
crit_bytes = wirespeed * crit / 100.0
- else:
- crit_bytes = crit / 1048576.0
+ else: # in MB
+ crit_bytes = crit * 1048576.0
for what, value in [("In", in_bytes), ("Out", out_bytes)]:
output.append("%s: %s/s" % (what, get_bytes_human_readable(value)))
@@ -197,7 +197,8 @@ def check_brocade_fcport(item, params, info):
# if averaging is on, compute average and apply levels to average
if average:
- timedif, per_sec_avg = get_average("brocade_fcport.%s.%s.avg" %
(counter, item), this_time, per_sec, average)
+ timedif, per_sec_avg = get_average("brocade_fcport.%s.%s.avg" %
\
+ (counter, item), this_time, per_sec, average)
perfdata.append( ("%s_avg" % counter, per_sec_avg ) )
# compute error rate (errors in relation to number of frames) (from 0.0 to 1.0)
@@ -209,7 +210,8 @@ def check_brocade_fcport(item, params, info):
# Honor averaging of error rate
if average:
- timedif, rate = get_average("brocade_fcport.%s.%s.avgrate" %
(counter, item), this_time, rate, average)
+ timedif, rate = get_average("brocade_fcport.%s.%s.avgrate" %
+ (counter, item), this_time, rate, average)
text += ", Avg: %.2f%%" % (rate * 100.0)
error_percentage = rate * 100.0
diff --git a/modules/agent_simulator.py b/modules/agent_simulator.py
index 9847aec..51d7c71 100644
--- a/modules/agent_simulator.py
+++ b/modules/agent_simulator.py
@@ -37,5 +37,5 @@ def agentsim_enum(values, period = 1): # period is in seconds
return values[hit]
def agentsim_sinus(base = 50, amplitude = 50, period = 300):
- return math.sin(our_uptime() * 2.0 * math.pi / period) * amplitude + base
+ return int(math.sin(our_uptime() * 2.0 * math.pi / period) * amplitude + base)