Ticket #7507: 0001-translate-hyphens-to-underscores.patch

File 0001-translate-hyphens-to-underscores.patch, 3.6 KB (added by russell.sim@…, 7 years ago)
  • munin-node.in

    From 549fb84d630d968eee31adef2da94d0e9ded150f Mon Sep 17 00:00:00 2001
    From: Russell Sim <russell.sim@gmail.com>
    Date: Sat, 5 Mar 2011 11:43:03 +1100
    Subject: [PATCH 1/3] translate hyphens to underscores
    
    ---
     munin-node.in   |    4 ++--
     plugins/if_     |   10 ++++++----
     plugins/if_err_ |    8 +++++---
     3 files changed, 13 insertions(+), 9 deletions(-)
    
    diff --git a/munin-node.in b/munin-node.in
    index 98819ab..c25a928 100755
    a b RES="" 
    7272for PLUG in $PLUGINS 
    7373do  
    7474  if [ "$PLUG" = "if_" ]; then   
    75     for INTER in $(grep '^ *\(ppp\|eth\|wlan\|ath\|ra\|ipsec\)\([^:]\)\{1,\}:' /proc/net/dev | cut -f1 -d: | sed 's/ //g'); 
     75    for INTER in $(grep '^ *\(ppp\|eth\|wlan\|ath\|ra\|ipsec\)\([^:]\)\{1,\}:' /proc/net/dev | cut -f1 -d: | sed 's/ //g' | tr '-' '_'); 
    7676    do 
    7777      INTERRES=$(echo $INTER | sed 's/\./VLAN/') 
    7878      RES="$RES if_$INTERRES" 
    do 
    8080      eval "config_if_${INTERRES}() { config_if $INTER $@; };" 
    8181    done 
    8282  elif [ "$PLUG" = "if_err_" ]; then 
    83     for INTER in $(grep '^ *\(ppp\|eth\|wlan\|ath\|ra\|ipsec\)\([^:]\)\{1,\}:' /proc/net/dev | cut -f1 -d: | sed 's/ //g'); 
     83    for INTER in $(grep '^ *\(ppp\|eth\|wlan\|ath\|ra\|ipsec\)\([^:]\)\{1,\}:' /proc/net/dev | cut -f1 -d: | sed 's/ //g' | tr '-' '_'); 
    8484    do 
    8585      INTERRES=$(echo $INTER | sed 's/\./VLAN/') 
    8686      RES="$RES if_err_$INTERRES" 
  • plugins/if_

    diff --git a/plugins/if_ b/plugins/if_
    index 250fea9..03a2ef7 100644
    a b  
    11config_if() { 
     2  if=$(echo "$1" | tr '_' '-') 
    23  echo "graph_order down up" 
    3   echo "graph_title $1 traffic" 
     4  echo "graph_title $if traffic" 
    45  echo "graph_args --base 1000" 
    56  echo "graph_vlabel bits in (-) / out (+) per \${graph_period}" 
    67  echo "graph_category network" 
    config_if() { 
    1516  echo "up.min 0" 
    1617  echo "up.negative down" 
    1718  echo "up.cdef up,8,*" 
    18   if ethtool $1 | grep -q Speed; then 
    19     MAX=$(($(ethtool $1 | grep Speed | sed -e 's/[[:space:]]\{1,\}/ /g' -e 's/^ //' -e 's/M.*//' | cut -d\  -f2) * 1000000)) 
     19  if ethtool $if | grep -q Speed; then 
     20    MAX=$(($(ethtool $if | grep Speed | sed -e 's/[[:space:]]\{1,\}/ /g' -e 's/^ //' -e 's/M.*//' | cut -d\  -f2) * 1000000)) 
    2021    echo "up.max $MAX" 
    2122    echo "down.max $MAX" 
    2223  fi 
    2324} 
    2425fetch_if() { 
    25   IINFO=$(grep "$1:" /proc/net/dev | cut -d: -f2 | sed -e 's/  / /g') 
     26  if=$(echo "$1" | tr '_' '-') 
     27  IINFO=$(grep "$if:" /proc/net/dev | cut -d: -f2 | sed -e 's/  / /g') 
    2628  echo "down.value" $(echo $IINFO | cut -d\  -f1) 
    2729  echo "up.value" $(echo $IINFO | cut -d\  -f9) 
    2830} 
  • plugins/if_err_

    diff --git a/plugins/if_err_ b/plugins/if_err_
    index 8f699f7..0f475dd 100644
    a b  
    11config_if_err() { 
     2  if=$(echo "$1" | tr '_' '-') 
    23  echo "graph_order rcvd trans" 
    3   echo "graph_title $1 errors" 
     4  echo "graph_title $if errors" 
    45  echo "graph_args --base 1000" 
    56  echo "graph_vlabel packets in (-) / out (+) per \${graph_period}" 
    67  echo "graph_category network" 
    7   echo "graph_info This graph shows the amount of errors on the $1 network interface." 
     8  echo "graph_info This graph shows the amount of errors on the $if network interface." 
    89  echo "rcvd.label packets" 
    910  echo "rcvd.type COUNTER" 
    1011  echo "rcvd.graph no" 
    config_if_err() { 
    1516  echo "trans.warning 1" 
    1617} 
    1718fetch_if_err() { 
    18   IINFO=$(grep "$1:" /proc/net/dev | cut -d: -f2 | sed -e 's/  / /g') 
     19  if=$(echo "$1" | tr '_' '-') 
     20  IINFO=$(grep "$if:" /proc/net/dev | cut -d: -f2 | sed -e 's/  / /g') 
    1921  echo "rcvd.value" $(echo $IINFO | cut -d\  -f3) 
    2022  echo "trans.value" $(echo $IINFO | cut -d\  -f11) 
    2123}