if_: handle "Unknown" emitted by ethtool
Previously error messages were emitted due to this non-numeric value. Closes: #3
This commit is contained in:
parent
710334b615
commit
8046268893
10
plugins/if_
10
plugins/if_
|
@ -16,10 +16,12 @@ config_if() {
|
|||
echo "up.min 0"
|
||||
echo "up.negative down"
|
||||
echo "up.cdef up,8,*"
|
||||
if [ -n "$(which ethtool)" ] && [ -x "$(which ethtool)" ] && ethtool "$INTERFACE" 2>/dev/null | grep -q Speed; then
|
||||
MAX=$(($(ethtool "$INTERFACE" | grep Speed | sed -e 's/[[:space:]]\{1,\}/ /g' -e 's/^ //' -e 's/M.*//' | cut -d " " -f 2) * 1000000))
|
||||
echo "up.max $MAX"
|
||||
echo "down.max $MAX"
|
||||
if [ -n "$(which ethtool)" ] && [ -x "$(which ethtool)" ]; then
|
||||
MAX_MBPS=$(ethtool "$INTERFACE" 2>/dev/null | grep "Speed: [0-9]\+Mb/s$" | sed 's/[^0-9]//g')
|
||||
if [ -n "$MAX_MBPS" ]; then
|
||||
echo "up.max $((MAX_MBPS * 1024 * 1024))"
|
||||
echo "down.max $((MAX_MBPS * 1024 * 1024))"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
fetch_if() {
|
||||
|
|
Loading…
Reference in New Issue