Skip to content

Commit 11c56aa

Browse files
committed
OpenWrt agent: get interface speed from sysfs if ethtool is missing
ethtool is not default on most OpenWrt targets and these devices are typically found in networking environments, so missing interface speed is not the desired behavior. Adapt fallback from Linux agent and extract speed from sysfs if ethtool is not available.
1 parent 8dec4f6 commit 11c56aa

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

agents/check_mk_agent.openwrt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -561,13 +561,19 @@ section_lnx_if() {
561561

562562
echo '<<<lnx_if:sep(58)>>>'
563563
sed 1,2d /proc/net/dev
564-
if inpath ethtool; then
565-
sed -e 1,2d /proc/net/dev | cut -d':' -f1 | sort | while read -r eth; do
566-
echo "[${eth}]"
567-
ethtool "${eth}" | grep -E '(Speed|Duplex|Link detected|Auto-negotiation):'
568-
echo "Address: $(cat "/sys/class/net/${eth}/address")"
569-
done
570-
fi
564+
sed -e 1,2d /proc/net/dev | cut -d':' -f1 | sort | while read -r eth; do
565+
echo "[${eth}]"
566+
if inpath ethtool; then
567+
ethtool "${eth}" | grep -E '(Speed|Duplex|Link detected|Auto-negotiation):'
568+
else
569+
speed=$(cat "/sys/class/net/${eth}/speed" 2>/dev/null)
570+
if [ -n "${speed}" ] && [ "${speed}" -ge 0 ]; then
571+
echo "Speed: ${speed}Mb/s"
572+
fi
573+
fi
574+
echo "Address: $(cat "/sys/class/net/${eth}/address")"
575+
done
576+
571577
}
572578

573579
# Current state of bonding interfaces

0 commit comments

Comments
 (0)