Module: check_mk
Branch: master
Commit: 295ec57af52f7fc700dc7ea1846f9f3ad7082808
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=295ec57af52f7f…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Dec 14 10:52:06 2011 +0100
FIX: lnx_if: assume interfaces as up if ethtool is missing
---
ChangeLog | 7 +++++++
checks/lnx_if | 28 ++++++++++++++++++----------
2 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 82b7b5a..ff8c06a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,6 +31,13 @@
man page of logwatch for details)
* fileinfo: new check for monitoring age and size of files
+1.1.12p5:
+ Checks & Agents:
+ * FIX: lnx_if: assume interfaces as up if ethtool is missing or
+ not working but interface has been used since last reboot. This
+ fixes the problem where interface are not found by inventory.
+
+1.1.12p4:
Multisite:
* New nifty sidebar snapin "Speed-O-Meter"
* Implemented new cookie based login mechanism including a fancy login GUI
diff --git a/checks/lnx_if b/checks/lnx_if
index 58bc201..642a376 100644
--- a/checks/lnx_if
+++ b/checks/lnx_if
@@ -69,6 +69,7 @@ def if_lnx_convert_to_if64(info):
if_table = []
for nic, attr in nic_info.items():
+ import pprint ; pprint.pprint(attr)
counters = attr.get("counters", [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
ifIndex = attr["index"]
@@ -97,16 +98,6 @@ def if_lnx_convert_to_if64(info):
else:
ifSpeed = ''
- # Link state from ethtool. If ethtool has no information about
- # this NIC, we set the state to unknown.
- ld = attr.get("Link detected")
- if ld == "yes":
- ifOperStatus = 1
- elif ld == "no":
- ifOperStatus = 2
- else:
- ifOperStatus = 4 # unknown
-
# Performance counters
ifInOctets = counters[0]
inucast = counters[1] + counters[7]
@@ -122,6 +113,22 @@ def if_lnx_convert_to_if64(info):
ifOutErrors = counters[10]
ifOutQLen = counters[12]
+ # Link state from ethtool. If ethtool has no information about
+ # this NIC, we set the state to unknown.
+ ld = attr.get("Link detected")
+ if ld == "yes":
+ ifOperStatus = 1
+ elif ld == "no":
+ ifOperStatus = 2
+ else:
+ # No information from ethtool. We consider interfaces up
+ # if they have been used at least some time since the
+ # system boot.
+ if ifInOctets > 0:
+ ifOperStatus = 1 # assume up
+ else:
+ ifOperStatus = 4 # unknown (NIC has never been used)
+
if_table.append(map(str, [
ifIndex, ifDescr, ifType, ifSpeed, ifOperStatus,
ifInOctets, inucast, inmcast, inbcast, ifInDiscards,
@@ -131,6 +138,7 @@ def if_lnx_convert_to_if64(info):
return if_table
def inventory_lnx_if(info):
+ import pprint ; pprint.pprint(info)
if linux_nic_check == "legacy":
return []
return inventory_if_common(if_lnx_convert_to_if64(info))