Module: check_mk
Branch: master
Commit: f983aea3e62c7517bf98bebc1e04f9f1f50f7fa3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f983aea3e62c75…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Nov 11 18:05:29 2010 +0100
if/if64: targetspeed can now be None to disable target speed check
---
ChangeLog | 1 +
checkman/if | 3 ++-
checks/if | 6 +++---
checks/if64 | 4 +++-
4 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b83d75d..3efcf45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -42,6 +42,7 @@
Checks & Agents:
* megaraid_pdisks: Using the real enclosure number as check item now
* if/if64: Added expected interface speed to warning output
+ * if/if64: Expected speed can also be None to disable interface speed checking
* wut_webtherm: handle more variants of WuT Webtherms (thanks to Lefty)
* cisco_fan: Does not inventorize 'notPresent' sensors anymore. Improved
output
* cisco_power: Not using power source as threshold anymore. Improved output
diff --git a/checkman/if b/checkman/if
index 271b9ee..34134e6 100644
--- a/checkman/if
+++ b/checkman/if
@@ -42,7 +42,8 @@ err_warn (float): The percentage of errors + discards at which a warning
should
triggered. Default is {0.01} percent (one of 10.000).
err_crit (float): The percentage of errors + discards at which a critical state is
reached. Default is {0.1} percent (one of 1.000).
-targetspeed (int): The target speed in bits per second of the interface.
+targetspeed (int): The target speed in bits per second of the interface. Can be {None} to
disable the
+ interface speed check.
bw_warn (float): Optional: The in/out rate to raise a WARNING state. Defaults to {None}.
bw_crit (float): Optional: The in/out rate to raise a CRITICAL state. Defaults to
{None}.
allowed_operstates (tuple): Optional: A list of allowed operstates. All other states
diff --git a/checks/if b/checks/if
index e08c247..2f15977 100644
--- a/checks/if
+++ b/checks/if
@@ -37,7 +37,7 @@ if_default_levels = (0.01, 0.1, None, None, ('1',
'up',))
# Stupid fix: Remove all 0 bytes. Hope this causes no problems.
def cleanup_if_strings(s):
if s and s != '':
- return "".join([ c for c in s if c not in nagios_illegal_chars+chr(0)
]).strip()
+ return "".join([ c for c in s if c not in nagios_illegal_chars+chr(0)
]).strip()
else:
return s
@@ -87,7 +87,7 @@ def check_if(item, params, info):
for ifIndex, ifDescr, ifType, ifSpeed, ifOperStatus, ifInOctets, ifInUcastPkts,
ifInNUcastPkts, ifInDiscards, \
ifInErrors, ifOutOctets, ifOutUcastPkts, ifOutNUcastPkts, ifOutDiscards,
ifOutErrors, ifOutQLen in info:
ifDescr = cleanup_if_strings(ifDescr)
-
+
if item == ifIndex or item == ifDescr:
# Display port number or alias in infotext if that is not part
@@ -109,7 +109,7 @@ def check_if(item, params, info):
# Check speed
speed = saveint(ifSpeed)
bandwidth = speed / 8.0 # in Bytes / sec
- if speed != targetspeed:
+ if not targetspeed is None and speed != targetspeed:
infotext += "%s (wrong speed! expected: %s)" % (speed,
get_nic_speed_human_readable(targetspeed))
state = 1
else:
diff --git a/checks/if64 b/checks/if64
index 897787b..0f91652 100644
--- a/checks/if64
+++ b/checks/if64
@@ -122,9 +122,11 @@ def check_if64(item, params, info):
speed = saveint(ifSpeed)
infotext += get_nic_speed_human_readable(speed)
bandwidth = speed / 8.0 # in Bytes / sec
- if speed != targetspeed:
+ if not targetspeed is None and speed != targetspeed:
infotext += " (wrong speed! expected: %s)" %
get_nic_speed_human_readable(targetspeed)
state = 1
+ else:
+ infotext += get_bytes_human_readable(speed, 1000)+'it/s'
# Performance counters
this_time = time.time()