public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-x86 commit in net-analyzer/munin/files: munin-1.4.6-if_-hardened.patch
@ 2011-11-11 11:36 Diego Petteno (flameeyes)
  0 siblings, 0 replies; only message in thread
From: Diego Petteno (flameeyes) @ 2011-11-11 11:36 UTC (permalink / raw
  To: gentoo-commits

flameeyes    11/11/11 11:36:04

  Modified:             munin-1.4.6-if_-hardened.patch
  Log:
  Complete the if_-hardened patch that was incomplete, and backport one more fix (for a bug introduced in said patch).
  
  (Portage version: 2.2.0_alpha72/cvs/Linux x86_64)

Revision  Changes    Path
1.2                  net-analyzer/munin/files/munin-1.4.6-if_-hardened.patch

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/munin/files/munin-1.4.6-if_-hardened.patch?rev=1.2&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/munin/files/munin-1.4.6-if_-hardened.patch?rev=1.2&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/munin/files/munin-1.4.6-if_-hardened.patch?r1=1.1&r2=1.2

Index: munin-1.4.6-if_-hardened.patch
===================================================================
RCS file: /var/cvsroot/gentoo-x86/net-analyzer/munin/files/munin-1.4.6-if_-hardened.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- munin-1.4.6-if_-hardened.patch	3 Nov 2011 18:08:56 -0000	1.1
+++ munin-1.4.6-if_-hardened.patch	11 Nov 2011 11:36:04 -0000	1.2
@@ -1,5 +1,5 @@
 diff --git a/plugins/node.d.linux/if_.in b/plugins/node.d.linux/if_.in
-index 31b554a..2f08709 100755
+index da0fc31..63a5dfd 100755
 --- a/plugins/node.d.linux/if_.in
 +++ b/plugins/node.d.linux/if_.in
 @@ -43,7 +43,9 @@ monitored with this plugin.
@@ -13,18 +13,20 @@
  
  =head1 LICENSE
  
-@@ -64,86 +66,65 @@ Unknown license
+@@ -64,86 +66,71 @@ 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!
+-    # 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
++# Who whould have thought it's so much work to determine the
++# maximum speed of a network interface.  Buckle up!
 +findspeed_mbps() {
      # Do not use interface name to guess technology.  Many many
      # wifi drivers use "eth*" names.
@@ -43,6 +45,21 @@
 -	    esac
 -	    ;;
 -    esac
+-
+-    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"
 +    IWLIST="$(type -p iwlist)"
 +    if [ -x "$IWLIST" ]; then
 +	SPEED=$($IWLIST $INTERFACE rate 2>&1 |
@@ -64,24 +81,7 @@
 +	    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
+ 	    fi
 -	    ;;
 -	1:/*)
 -	    # Current bit rate is not very interesting, it varies too often
@@ -89,13 +89,20 @@
 -		    awk 'BEGIN { RATE=U }
 -                               { if ($2 == "Mb/s") RATE=$1; } 
 -                         END   { print RATE; }')
- 
+-
 -	    ;;
 -	*)
 -	    # Wireless interface, cannot find iwlist
 -	    INSTALL="wireless-tools"
 -	    ;;
 -    esac
++    fi
++
++    ETHTOOL="$(type -p ethtool)"
++    if [ -x "$ETHTOOL" ]; then
++	SPEED="$($ETHTOOL $INTERFACE 2>&1 |
++                 awk '/Speed:/ { gsub(/[^0-9]*/,"",$2); print $2; }')"
++
 +        if [ $SPEED = [0-9]* ]; then
 +	    echo $SPEED
 +            return
@@ -113,18 +120,19 @@
 -		*)          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
+-    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"
++    if [ -x $MIITOOL ]; then
++	case $($MIITOOL $INTERFACE 2>&1) in
++	    *1000base*) echo 1000; return ;;
++	    *100base*)  echo 100; return ;;
++	    *10base*)   echo 10; return ;;
++	esac
      fi
  
 -    case $SPEED in
@@ -137,10 +145,67 @@
 +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."
++    if [ -z $SPEED -o $SPEED = "U" ]; then
++        printf "up.info Traffic of the %s interface. Unable to determine interface speed." $INTERFACE
++        if [ $EUID -ne 0 ]; then
++                echo " Please run the plugin as root."
++        else
++                echo " Please install ethtool, wireless-tools, mii-tool or whatever is appropriate for the interface."
++        fi
++
 +        return
 +    fi
  
      BPS=$(( $SPEED * 1000 * 1000 ))
  
+@@ -207,11 +194,15 @@ case $1 in
+ esac
+ 
+ # Escape dots in the interface name (eg. vlans) before using it as a regex
+-awk -v interface="$INTERFACE" \
+-    'BEGIN { gsub(/\./, "\\.", interface) } \
+-    $1 ~ "^" interface ":" {
+-        split($0, a, /: */); $0 = a[2]; \
+-        print "down.value " $1 "\nup.value " $9 \
+-    }' \
+-    /proc/net/dev
+-
++if [ -r /sys/class/net/$INTERFACE/statistics/rx_bytes ]; then
++    echo "down.value $(cat /sys/class/net/$INTERFACE/statistics/rx_bytes)"
++    echo "up.value $(cat /sys/class/net/$INTERFACE/statistics/tx_bytes)"
++else
++    awk -v interface="$INTERFACE" \
++        'BEGIN { gsub(/\./, "\\.", interface) } \
++        $1 ~ "^" interface ":" {
++            split($0, a, /: */); $0 = a[2]; \
++            print "down.value " $1 "\nup.value " $9 \
++        }' \
++        /proc/net/dev
++fi
+diff --git a/plugins/node.d.linux/if_err_.in b/plugins/node.d.linux/if_err_.in
+index 331866d..2e35909 100755
+--- a/plugins/node.d.linux/if_err_.in
++++ b/plugins/node.d.linux/if_err_.in
+@@ -93,10 +93,15 @@ if [ "$1" = "config" ]; then
+ fi;
+ 
+ # Escape dots in the interface name (eg. vlans) before using it as a regex
+-awk -v interface="$INTERFACE" \
+-    'BEGIN { gsub(/\./, "\\.", interface) } \
+-    $1 ~ "^" interface ":" {
+-        split($0, a, /: */); $0 = a[2]; \
+-        print "rcvd.value " $3 "\ntrans.value " $11 \
+-    }' \
+-    /proc/net/dev
++if [ -r /sys/class/net/$INTERFACE/statistics/rx_bytes ]; then
++    echo "down.value $(cat /sys/class/net/$INTERFACE/statistics/rx_errors)"
++    echo "up.value $(cat /sys/class/net/$INTERFACE/statistics/tx_errors)"
++else
++    awk -v interface="$INTERFACE" \
++        'BEGIN { gsub(/\./, "\\.", interface) } \
++        $1 ~ "^" interface ":" {
++            split($0, a, /: */); $0 = a[2]; \
++            print "rcvd.value " $3 "\ntrans.value " $11 \
++        }' \
++        /proc/net/dev
++fi






^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-11-11 11:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-11 11:36 [gentoo-commits] gentoo-x86 commit in net-analyzer/munin/files: munin-1.4.6-if_-hardened.patch Diego Petteno (flameeyes)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox