Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 288293 Details for
Bug 384921
net-analyzer/munin: merge request for two more patches
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Fixed if_ patch
munin-if.patch (text/plain), 3.97 KB, created by
Diego Elio Pettenò (RETIRED)
on 2011-09-29 23:03:37 UTC
(
hide
)
Description:
Fixed if_ patch
Filename:
MIME Type:
Creator:
Diego Elio Pettenò (RETIRED)
Created:
2011-09-29 23:03:37 UTC
Size:
3.97 KB
patch
obsolete
>diff --git a/plugins/node.d.linux/if_.in b/plugins/node.d.linux/if_.in >index 31b554a..2f08709 100755 >--- a/plugins/node.d.linux/if_.in >+++ b/plugins/node.d.linux/if_.in >@@ -43,7 +43,9 @@ monitored with this plugin. > > =head1 AUTHOR > >-Unknown author >+Original author unknown >+ >+Copyright (C) 2011 Diego Elio Petteno' <flameeyes@flameeyes.eu> > > =head1 LICENSE > >@@ -64,86 +66,65 @@ Unknown license > > INTERFACE=${0##*if_} > >-findspeed () { >- > # Who whould have thought it's so much work to determine the > # maximum speed of a network interface. Buckle up! >- >- IWLIST="$(type -p iwlist)" >- >- WIRELESS=0 >+findspeed_mbps() { > # Do not use interface name to guess technology. Many many > # wifi drivers use "eth*" names. >- case $IWLIST in >- >- '') >- # Used to use iwconfig to look for "no wireless >- # extentions" message - but this seemed un-needed. If we >- # don't have iwlist we can't find out if # the interface >- # is wireless >- :;; >- *) IWO="$($IWLIST $INTERFACE rate 2>&1)" >- case $IWO in >- *no*) :;; >- *) WIRELESS=1;; >- esac >- ;; >- esac >+ IWLIST="$(type -p iwlist)" >+ if [ -x "$IWLIST" ]; then >+ SPEED=$($IWLIST $INTERFACE rate 2>&1 | >+ awk 'BEGIN { RATE=U } >+ { if ($2 == "Mb/s") RATE=$1; } >+ END { print RATE; }') >+ >+ if [ "$SPEED" != "U" ]; then >+ echo $SPEED >+ return >+ fi >+ fi >+ >+ # sysfs can report the speed if the driver supports it (but it >+ # doesn't work as well for wireless cards, thus why we check for >+ # iwlist first) >+ if [ -r /sys/class/net/$INTERFACE/speed ]; then >+ SPEED="$(cat /sys/class/net/$INTERFACE/speed 2>/dev/null)" >+ if [ -n "$SPEED" ]; then >+ echo $SPEED >+ return >+ fi >+ fi > >- SPEED=U >- # Find speed in Mbps. - or not >- case $WIRELESS:$IWLIST in >- 0:*) > ETHTOOL="$(type -p ethtool)" > if [ -x "$ETHTOOL" ]; then > SPEED="$($ETHTOOL $INTERFACE 2>&1 | > awk '/Speed:/ { gsub(/[^0-9]*/,"",$2); print $2; }')" >- case $SPEED in >- [0-9]*) :;; # OK >- *) SPEED=U;; # Could be "unknown" >- esac >- else >- INSTALL="ethtool" >- fi >- ;; >- 1:/*) >- # Current bit rate is not very interesting, it varies too often >- SPEED=$(echo "$IWO" | >- awk 'BEGIN { RATE=U } >- { if ($2 == "Mb/s") RATE=$1; } >- END { print RATE; }') > >- ;; >- *) >- # Wireless interface, cannot find iwlist >- INSTALL="wireless-tools" >- ;; >- esac >+ if [ $SPEED = [0-9]* ]; then >+ echo $SPEED >+ return >+ fi >+ fi > > MIITOOL="$(type -p mii-tool)" >- case $SPEED:$MIITOOL in >- U:/*) >- SPEED="$($MIITOOL $INTERFACE 2>&1)" >- case $SPEED in >- *1000base*) SPEED=1000;; # as if... >- *100base*) SPEED=100;; >- *10base*) SPEED=10;; >- *) SPEED=U;; >- esac >- ;; >+ if [ -x $MIITOOL ]; then >+ case $($MIITOOL $INTERFACE 2>&1) in >+ *1000base*) echo 1000; return ;; >+ *100base*) echo 100; return ;; >+ *10base*) echo 10; return ;; > esac >- >- # sysfs can report the speed if the driver supports it >- SYSFS="$(cat /sys/class/net/$INTERFACE/speed 2>/dev/null)" >- # If it can't, it fails on I/O, so we check cat's return value >- if [ $? -eq 0 -a "$SPEED" = "U" -a -n "$SYSFS" ]; then >- SPEED="$SYSFS" > fi > >- case $SPEED in >- U) echo "up.info Traffic of the $INTERFACE interface. Unable to determine interface speed. Please install ethtool, wireless-tools (or mii-tool), whatever is appropriate for the interface." >- return;; >- esac >+ echo U >+} >+ >+findspeed() { >+ SPEED=$(findspeed_mbps) >+ >+ if [ -z $SPEED ]; then >+ echo "up.info Traffic of the $INTERFACE interface. Unable to determine interface speed. Please install ethtool, wireless-tools, mii-tool or whatever is appropriate for the interface." >+ return >+ fi > > BPS=$(( $SPEED * 1000 * 1000 )) >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 384921
:
288217
|
288219
| 288293