Ticket #7167: munin-node.2.patch

File munin-node.2.patch, 7.1 KB (added by L.Schmidt <l.openwrt at scarydevilmonastery.net>, 7 years ago)

bumped version number. output of diff -urN, not just of diff -u

  • munin-node

    old new  
    1212# $Id: $ 
    1313# 
    1414 
    15 VERSION="1.0.2" 
     15VERSION="1.0.2a" 
    1616 
    1717NTP_PEER="pool.ntp.org"; 
    1818 
    1919# Remove unwanted plugins from this list 
     20# netstat doesn't work with busybox netstat - needs net-tools netstat 
     21# if_ needs ethtool. 
     22 
    2023PLUGINS="cpu if_ if_err_ load memory processes netstat uptime interrupts irqstats" 
    2124# ===== LIB FUNCTIONS ===== 
    2225clean_fieldname() { 
     
    3639  SYSWARNING=$(($PERCENT * 30 / 100)) 
    3740  SYSCRITICAL=$(($PERCENT * 50 / 100)) 
    3841  USRWARNING=$(($PERCENT * 80 / 100)) 
    39   echo "graph_title CPU usage" 
    40   echo "graph_order system user nice idle" $extinfo 
    41   echo "graph_args --base 1000 -r --lower-limit 0 --upper-limit $graphlimit" 
    42   echo "graph_vlabel %" 
    43   echo "graph_scale no" 
    44   echo "graph_info This graph shows how CPU time is spent." 
    45   echo "graph_category system" 
    46   echo "graph_period second" 
    47   echo "system.label system" 
    48   echo "system.draw AREA" 
    49   echo "system.max 5000" 
    50   echo "system.min 0" 
    51   echo "system.type DERIVE" 
    52   echo "system.warning $SYSWARNING" 
    53   echo "system.critical $SYSCRITICAL" 
    54   echo "system.info CPU time spent by the kernel in system activities" 
    55   echo "user.label user" 
    56   echo "user.draw STACK" 
    57   echo "user.min 0" 
    58   echo "user.max 5000" 
    59   echo "user.warning $USRWARNING" 
    60   echo "user.type DERIVE" 
    61   echo "user.info CPU time spent by normal programs and daemons" 
    62   echo "nice.label nice" 
    63   echo "nice.draw STACK" 
    64   echo "nice.min 0" 
    65   echo "nice.max 5000" 
    66   echo "nice.type DERIVE" 
    67   echo "nice.info CPU time spent by nice(1)d programs" 
    68   echo "idle.label idle" 
    69   echo "idle.draw STACK" 
    70   echo "idle.min 0" 
    71   echo "idle.max 5000" 
    72   echo "idle.type DERIVE" 
    73   echo "idle.info Idle CPU time" 
    74   if [ ! -z "$extinfo" ]; then 
    75     echo "iowait.label iowait" 
    76     echo "iowait.draw STACK" 
    77     echo "iowait.min 0" 
    78     echo "iowait.max 5000" 
    79     echo "iowait.type DERIVE" 
    80     echo "iowait.info CPU time spent waiting for I/O operations to finish" 
    81     echo "irq.label irq" 
    82     echo "irq.draw STACK" 
    83     echo "irq.min 0" 
    84     echo "irq.max 5000" 
    85     echo "irq.type DERIVE" 
    86     echo "irq.info CPU time spent handling interrupts" 
    87     echo "softirq.label softirq" 
    88     echo "softirq.draw STACK" 
    89     echo "softirq.min 0" 
    90     echo "softirq.max 5000" 
    91     echo "softirq.type DERIVE" 
    92     echo "softirq.info CPU time spent handling "batched" interrupts" 
    93   fi 
     42echo "graph_title CPU usage 
     43graph_order system user nice idle $extinfo 
     44graph_args --base 1000 -r --lower-limit 0 --upper-limit $graphlimit 
     45graph_vlabel % 
     46graph_scale no 
     47graph_info This graph shows how CPU time is spent. 
     48graph_category system 
     49graph_period second 
     50system.label system 
     51system.draw AREA 
     52system.max 5000 
     53system.min 0 
     54system.type DERIVE 
     55system.warning $SYSWARNING 
     56system.critical $SYSCRITICAL 
     57system.info CPU time spent by the kernel in system activities 
     58user.label user 
     59user.draw STACK 
     60user.min 0 
     61user.max 5000 
     62user.warning $USRWARNING 
     63user.type DERIVE 
     64user.info CPU time spent by normal programs and daemons 
     65nice.label nice 
     66nice.draw STACK 
     67nice.min 0 
     68nice.max 5000 
     69nice.type DERIVE 
     70nice.info CPU time spent by nice(1)d programs 
     71idle.label idle 
     72idle.draw STACK 
     73idle.min 0 
     74idle.max 5000 
     75idle.type DERIVE 
     76idle.info Idle CPU time" 
     77if [ ! -z "$extinfo" ]; then 
     78echo "iowait.label iowait 
     79iowait.draw STACK 
     80iowait.min 0 
     81iowait.max 5000 
     82iowait.type DERIVE 
     83iowait.info CPU time spent waiting for I/O operations to finish 
     84irq.label irq 
     85irq.draw STACK 
     86irq.min 0 
     87irq.max 5000 
     88irq.type DERIVE 
     89irq.info CPU time spent handling interrupts 
     90softirq.label softirq 
     91softirq.draw STACK 
     92softirq.min 0 
     93softirq.max 5000 
     94softirq.type DERIVE 
     95softirq.info CPU time spent handling \"batched\" interrupts" 
     96fi 
    9497} 
     98 
    9599fetch_cpu() { 
    96100  extinfo="" 
    97101  if grep '^cpu \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\}' /proc/stat >/dev/null 2>&1; then 
    98102    extinfo="iowait irq softirq" 
    99103  fi 
    100   CINFO=$(grep '^cpu ' /proc/stat | cut -c6-) 
    101   echo "user.value" $(echo "$CINFO" | cut -d\  -f1) 
    102   echo "nice.value" $(echo "$CINFO" | cut -d\  -f2) 
    103   echo "system.value" $(echo "$CINFO" | cut -d\  -f3) 
    104   echo "idle.value" $(echo "$CINFO" | cut -d\  -f4) 
    105   if [ ! -z "$extinfo" ]; then 
    106     echo "iowait.value" $(echo "$CINFO" | cut -d\  -f5) 
    107     echo "irq.value" $(echo "$CINFO" | cut -d\  -f6) 
    108     echo "softirq.value" $(echo "$CINFO" | cut -d\  -f7) 
    109   fi 
     104 
     105# this speeded up fetching data of this plugin considerably. Avoiding two subshell invocations per line 
     106i=0 
     107for reading in $(grep '^cpu ' /proc/stat | cut -c6-); do 
     108  let reading$i=$reading 
     109  i=$((i+1)) 
     110done 
     111echo "user.value $reading0 
     112nice.value $reading1 
     113system.value $reading2 
     114idle.value $reading3" 
     115if [ ! -z "$extinfo" ]; then 
     116echo "iowait.value $reading4 
     117irq.value $reading5 
     118softirq.value $reading6" 
     119fi 
    110120} 
     121 
    111122config_if() { 
    112123  echo "graph_order down up" 
    113124  echo "graph_title $1 traffic" 
     
    125136  echo "up.min 0" 
    126137  echo "up.negative down" 
    127138  echo "up.cdef up,8,*" 
    128   if ethtool $1 | grep -q Speed; then 
     139# ethtool would come up with an error message on my eth0 here, causing the polling machine to send an error mail  
     140# after each acquisition. Rather than commenting out this section completely (it doesn't make any difference on 
     141# my router), I reckon that hiding the error message will have less impact. 
     142  if ethtool $1 2> /dev/null | grep -q Speed; then 
    129143    MAX=$(($(ethtool $1 | grep Speed | sed -e 's/[[:space:]]\{1,\}/ /g' -e 's/^ //' -e 's/M.*//' | cut -d\  -f2) * 1000000)) 
    130144    echo "up.max $MAX" 
    131145    echo "down.max $MAX" 
     
    172186fetch_load() { 
    173187  echo "load.value" $(cut -f2 -d\  /proc/loadavg) 
    174188} 
     189# looks like here's room for improvement too, but I got sidetracked by bug hunting 
     190# - unneeded cats. unneeded echoes.  reduces new shells. grep+cut can probably combined into one sed 
     191# result would probably be st like  LABEL=$(sed -n 's/...//p' <<< .. ehm no here strings for sh.. oh well. 
    175192config_memory() { 
    176193  MINFO=$(cat /proc/meminfo | sed 's/ \{1,\}/ /g;') 
    177194  MEMTOTAL=$(echo "$MINFO" | grep "^MemTotal:" | cut -d\  -f2) 
     
    282299    echo "inact_clean.info Memory not currently used." 
    283300  fi 
    284301} 
     302# same: sed should be faster than grep+cut. should measure before changing 
    285303fetch_memory() { 
    286304  MINFO=$(cat /proc/meminfo | sed 's/ \{1,\}/ /g;') 
    287305  MEMTOTAL=$(echo "$MINFO" | grep "^MemTotal:" | cut -d\  -f2) 
     
    370388fetch_processes() { 
    371389  echo "processes.value" $(echo /proc/[0-9]* | wc -w) 
    372390} 
     391 
    373392config_netstat() { 
    374393  echo "graph_title Netstat" 
    375394  echo "graph_args -l 0 --base 1000" 
     
    402421  echo "established.max 50000" 
    403422  echo "established.info The number of currently open connections." 
    404423} 
     424 
     425# doesn't work with busybox netstat - needs net-tools netstat 
    405426fetch_netstat() { 
    406427  NINFO=$(netstat -s | sed 's/ \{1,\}/ /g') 
    407428  echo "active.value" $(echo "$NINFO" | grep "active connections" | cut -d\  -f2) 
     
    410431  echo "resets.value" $(echo "$NINFO" | grep "connection resets" | cut -d\  -f2) 
    411432  echo "established.value" $(echo "$NINFO" | grep "connections established" | cut -d\  -f2) 
    412433} 
     434 
    413435config_uptime() { 
    414436  echo "graph_title Uptime" 
    415437  echo "graph_args --base 1000 -l 0 "