Module: check_mk
Branch: master
Commit: b1a8837827db75486eac0ba58d679986f3d89f96
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b1a8837827db75…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue May 14 13:04:07 2013 +0200
lnx_if: show MAC address for interfaces (needs also agent update)
---
ChangeLog | 1 +
agents/check_mk_agent.linux | 5 +++--
checks/lnx_if | 7 +++++--
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f4bc640..678a8e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -95,6 +95,7 @@
* uptime, snmp_uptime, esx_vsphere_counters.uptime: allow to set lower and upper
levels
* winperf_processor: Now displays (and scales) to number of cpus in pnpgraph
* mk_postgres plugin: replace select * with list of explicit columns (fix for PG
9.1)
+ * lnx_if: show MAC address for interfaces (needs also agent update)
Notifications:
* notify.py: unique spoolfiles name no longer created with uuid
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 78902ca..9c80562 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -166,8 +166,9 @@ if type ethtool > /dev/null
then
for eth in $(sed -e 1,2d < /proc/net/dev | cut -d':' -f1 | sort)
do
- echo "[$eth]"
- ethtool $eth | egrep '(Speed|Duplex|Link detected|Auto-negotiation):'
+ echo "[$eth]"
+ ethtool $eth | egrep '(Speed|Duplex|Link detected|Auto-negotiation):'
+ echo -en "\tAddress: " ; cat /sys/class/net/$eth/address
done
fi
diff --git a/checks/lnx_if b/checks/lnx_if
index 0099d8c..516407a 100644
--- a/checks/lnx_if
+++ b/checks/lnx_if
@@ -37,6 +37,7 @@
# Duplex: Unknown! (255)
# Auto-negotiation: on
# Link detected: no
+# Address: de:ad:be:af:00:01
# [eth1]
# Speed: 1000Mb/s
# Duplex: Full
@@ -60,7 +61,7 @@ def if_lnx_convert_to_if64(info):
nic = line[0]
nic_info[nic] = { "counters": map(int, line[1].split()) }
else:
- nic_info[current_nic][line[0].strip()] = line[1].strip()
+ nic_info[current_nic][line[0].strip()] =
":".join(line[1:]).strip()
# if index is 0 we either have found no nics or no information
# from ethtool is present. In the latter case we continue and
@@ -130,7 +131,9 @@ def if_lnx_convert_to_if64(info):
ifOperStatus = 4 # unknown (NIC has never been used)
# There is no mac adress data available for the moment
- ifPhysAddress = ''
+ def hextobin(x):
+ return chr(int(x, 16))
+ ifPhysAddress = "".join([chr(int(x, 16)) for x in
attr.get("Address", "").split(":")])
if_table.append(map(str, [
ifIndex, ifDescr, ifType, ifSpeed, ifOperStatus,