Module: check_mk
Branch: master
Commit: b806fb4c10573655702ef02e1eda470268fbb278
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b806fb4c105736…
Author: Florian Heigl <fh(a)mathias-kettner.de>
Date: Thu Jul 14 00:10:31 2011 +0200
revert my patch for review
Revert "if/if64 fixed operstate monitoring"
This reverts commit 9c84661c2adf6a05e1d075624b957dbf8cd0f89e.
Conflicts:
ChangeLog
---
ChangeLog | 10 ------
checks/if.include | 87 ++++++++++++++++++++++++++++++++++-------------------
2 files changed, 56 insertions(+), 41 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 68824e7..93f605f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,8 @@
1.1.11i2:
Core, Setup, etc.:
* FIX: sort output of cmk --list-hosts alphabetically
- * FIX: Fixed .* in SNMP scan function when using stored SNMP walks
- * FIX: Fixed OID_END handling in SNMP based checks (e.g. canon_pages)
Checks & Agents:
- * FIX: Problems with { and } in manpage parsing has been fixed
* FIX: apc_symmetra: fix remaining runtime calculation (by factor 100)
* FIX: Added PNP-template for winperf_phydisk
* FIX: if64: fix UNKNOWN in case of non-unique ifAlias
@@ -23,7 +20,6 @@
* vbox_guest: new check for checking guest additions of Linux virtual box hosts
* if/if64: Fixed bug in operstate detection when using old tuple based params
* if/if64: Fixed bug in operstate detection when using tuple of valid operstates
- * windows_updates: Added missing manpage
Multisite:
* FIX: make non-Ascii characters in services names work again
@@ -35,8 +31,6 @@
* Introduced basic infrastructure for multilanguage support in Multisite
* Make 'Views' snapin foldable
* Replace old main view by dashboard.
- * new filter for WATO folder of host
- * added icons to context buttons
WATO:
* Configration files can now be administered via the WEB UI
@@ -54,10 +48,6 @@
MK Livestatus:
* FIX: fix compile problem on Debian unstable (Thanks to Sven Velt)
* Column aggregation (Stats) now also works for perf_data
- * hosts, services & contacts: new column custom_variables (this is
- a dictionary of all custom variables)
- * new column 'filename' in table host (value of variable _FILENAME)
- * Updated Python-API to most current version
1.1.11i1:
Core, Setup, etc.:
diff --git a/checks/if.include b/checks/if.include
index 9dcf206..8213c17 100644
--- a/checks/if.include
+++ b/checks/if.include
@@ -68,20 +68,29 @@ def inventory_if_common(info):
if len(info) == 0 or len(info[0]) != 19:
return []
pre_inventory = []
+
+ seen_items = set([])
+ duplicate = set([])
for ifIndex, ifDescr, ifType, ifSpeed, ifOperStatus, ifInOctets, inucast, inmcast,
inbcast, ifInDiscards, \
ifInErrors, ifOutOctets, outucast, outmcast, outbcast, ifOutDiscards,
ifOutErrors, ifOutQLen, ifAlias in info:
ifDescr = cleanup_if_strings(ifDescr)
ifAlias = cleanup_if_strings(ifAlias)
- if ifType in if_inventory_porttypes and ifOperStatus in if_inventory_portstates:
- if if_inventory_uses_description and ifDescr:
- item = ifDescr
- elif if_inventory_uses_alias and ifAlias:
- item = ifAlias
- else:
- item = ifIndex
+ # compute item now - also for unmonitored ports - in order to see if it
+ # is uninque.
+ if if_inventory_uses_description and ifDescr:
+ item = ifDescr
+ elif if_inventory_uses_alias and ifAlias:
+ item = ifAlias
+ else:
+ item = ifIndex
+ if item in seen_items: # duplicate
+ duplicate.add(item)
+ seen_items.add(item)
+
+ if ifType in if_inventory_porttypes and ifOperStatus in if_inventory_portstates:
paramstring = '{ "errors" : if_default_error_levels, ' \
'"traffic" : if_default_traffic_levels, ' \
'"average" : if_default_average '
@@ -95,13 +104,6 @@ def inventory_if_common(info):
pre_inventory.append( (item, paramstring, int(ifIndex)) )
# Check for duplicate items (e.g. when using Alias as item and the alias is not
unique)
- seen_items = set([])
- duplicate = set([])
- for item, params, index in pre_inventory:
- if item in seen_items: # duplicate
- duplicate.add(item)
- seen_items.add(item)
-
inventory = []
for item, params, index in pre_inventory:
if item in duplicate:
@@ -109,6 +111,7 @@ def inventory_if_common(info):
else:
new_item = item
inventory.append((new_item, params))
+
return inventory
@@ -133,21 +136,25 @@ def check_if_common(item, params, info):
elif len(params) == 5:
err_warn, err_crit, targetspeed, bw_warn, bw_crit = params
elif len(params) == 6:
- err_warn, err_crit, targetspeed, bw_warn, bw_crit, targetstate = params
+ err_warn, err_crit, targetspeed, bw_warn, bw_crit, allowed_operstates = params
- for ifIndex, ifDescr, ifType, ifSpeed, ifOperStatus, ifInOctets, inucast, inmcast,
inbcast, ifInDiscards, \
- ifInErrors, ifOutOctets, outucast, outmcast, outbcast, ifOutDiscards,
ifOutErrors, ifOutQLen, ifAlias in info:
+ for ifIndex, ifDescr, ifType, ifSpeed, ifOperStatus, ifInOctets, \
+ inucast, inmcast, inbcast, ifInDiscards, ifInErrors, ifOutOctets, \
+ outucast, outmcast, outbcast, ifOutDiscards, ifOutErrors, \
+ ifOutQLen, ifAlias in info:
ifDescr = cleanup_if_strings(ifDescr)
ifAlias = cleanup_if_strings(ifAlias)
if item == ifIndex \
or item == ifAlias \
or item == ifDescr \
- or item == "%s %s" % (ifAlias, ifIndex):
+ or item == "%s %s" % (ifAlias, ifIndex) \
+ or item == "%s %s" % (ifDescr, ifIndex):
# 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 == '') and (item
== ifDescr or ifDescr == ''): # description trivial
+ if item == 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
infotext = "[%s/%s]" % (ifAlias, ifDescr)
@@ -158,23 +165,20 @@ def check_if_common(item, params, info):
else:
infotext = "[%s] " % ifIndex
+ state = 0
+
operstatus = if_statename(str(ifOperStatus))
if targetstate and \
(ifOperStatus != targetstate
- and not (type(targetstate) in [ list, tuple ] and ifOperStatus in
targetstate)):
- return (2, "CRIT - %soperstatus: %s (CRIT)" % (infotext,
operstatus))
- infotext += "(%s) " % operstatus
+ and not (type(targetstate) == list and ifOperStatus in targetstate)):
+ state = 2
+ infotext += "(%s!!) " % operstatus
+ else:
+ infotext += "(%s) " % operstatus
- state = 0
- # Check speed
+ # prepare reference speed for computing relative bandwidth usage
speed = saveint(ifSpeed)
- infotext += get_nic_speed_human_readable(speed)
- if not targetspeed is None and speed != targetspeed:
- infotext += " (wrong speed! expected: %s)" %
get_nic_speed_human_readable(targetspeed)
- state = 1
-
- # convert percentages to absolute values and vice verca - if possible
if speed:
ref_speed = speed / 8.0
elif targetspeed:
@@ -182,13 +186,34 @@ def check_if_common(item, params, info):
else:
ref_speed = None
- # convert percentages to absolute values if reference speed available
+ # Check speed settings of interface, but only if speed information
+ # is available. This is not always the case.
+ if speed:
+ infotext += get_nic_speed_human_readable(speed)
+ if not targetspeed is None and speed != targetspeed:
+ infotext += " (wrong speed! expected: %s)" %
get_nic_speed_human_readable(targetspeed)
+ state = max(state, 1)
+ elif targetspeed:
+ infotext += "assuming %s" %
get_nic_speed_human_readable(targetspeed)
+ else:
+ infotext += "speed unknown"
+
+ # convert percentages to absolute values if levels are float
+ # this is only possible if a reference speed is available.
if ref_speed:
if bw_warn != None and type(bw_warn) == float:
bw_warn = bw_warn / 100.0 * ref_speed
if bw_crit != None and type(bw_crit) == float:
bw_crit = bw_crit / 100.0 * ref_speed
+ # Ignore percentual levels if no reference speed is available
+ else:
+ if bw_warn != None and type(bw_warn) == float:
+ bw_warn = None
+
+ if bw_crit != None and type(bw_crit) == float:
+ bw_crit = None
+
# Performance counters
this_time = time.time()
rates = []