Usually I’m monitoring stuff with Icinga (Nagios in the past). But for my small network, I primary needed monitoring of bandwidth.

In our commercial environment we are using a closed source software for accounting traffic. There is also a license for testing purpose with a reduced number of sensors available. But I’m neither running windows in this network nor feeling happy with this.

Cacti is a bit bloated for this small network and zabbix is (caused by what?) removed in wheezy, beside that I’m not getting the concept behind it. So I thought I could give munin a try and on the first view it doesn’t look so bad. Monitoring my half dozens openwrt devices works like a charm by installing muninlite just the package.

One central part of the network is a QNAP TS-459 Pro+, hosting a BackupPC and TimeMachine service, proving SMB/AFS data store and running SqueezeBox Server for another half dozen streaming devices. Unfortunately there is no optware package to provide a munin node. So I just copied the shell script of muninlite and the xinet config over from an openwrt device. At first it looked not bad, but than munin wasn’t able to collect the data. After a while I realized, that munin was failing when collecting the network informations. A look into the muninlite script revealed that it was failing when trying to discover the interface speed of eth1 via ethtool.

In my setup the QNAP is just connected with with one network interface, the second one is unconnected. Unfortunately all network interfaces on QNAP devices are up and therefore listed in /proc/net/dev where muninlite is discovering the network interfaces:

[~] # grep '^ *\(ppp\|eth\|wlan\|ath\|ra\|ipsec\|tap\|br-\)\([^:]\)\{1,\}:' /proc/net/dev | cut -f1 -d: | sed 's/ //g
> s/\-/_/g'
eth1
eth0

Let’s look into it:

[~] # ethtool eth0| grep Speed:
    Speed: 1000Mb/s
[~] # ethtool eth0| grep "Link detected:"
    Link detected: yes
[~] # ethtool eth1| grep Speed:
    Speed: Unknown! (65535)
[~] # ethtool eth1| grep "Link detected:"
    Link detected: no

Maybe you see .. the interface eth1 is up but has no link, so there is no speed negotiated and muninlite is failing. Thus I hacked the scripted and now it’s working like a charme.

(muninlite_fix-unused-up_interface.diff) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--- /opt/sbin/munin-node.orig   2013-01-27 15:13:51.869007214 +0100
+++ /opt/sbin/munin-node 2013-01-27 16:11:20.536006950 +0100
@@ -133,7 +133,7 @@
   if [ -n "$(which ethtool)" ]; then
  if [ -x "$(which ethtool)" ]; then
          if ethtool $1 | grep -q Speed; then
-                MAX=$(($(ethtool $1 | grep Speed | sed -e 's/[[:space:]]\{1,\}/ /g' -e 's/^ //' -e 's/M.*//' | cut -d\  -f2) * 1000000))
+                MAX=$(($(ethtool $1 | grep Speed | sed -e 's/[[:space:]]\{1,\}/ /g' -e 's/^ //' -e 's/M.*//' | sed -e 's/Unknown\!/0/' | cut -d\  -f2) * 1000000))
              echo "up.max $MAX"
              echo "down.max $MAX"
      fi
@@ -535,19 +535,31 @@
     for INTER in $(grep '^ *\(ppp\|eth\|wlan\|ath\|ra\|ipsec\|tap\|br-\)\([^:]\)\{1,\}:' /proc/net/dev | cut -f1 -d: | sed 's/ //g
 s/\-/_/g');
     do
-      INTERRES=$(echo $INTER | sed 's/\./VLAN/')
-      RES="$RES if_$INTERRES"
-      eval "fetch_if_${INTERRES}() { fetch_if $INTER $@; };"
-      eval "config_if_${INTERRES}() { config_if $INTER $@; };"
+      if [ -n "$(which ethtool)" ]; then
+        if [ -x "$(which ethtool)" ]; then
+          if [ -n "$(ethtool $INTER | grep 'Link detected: yes')" ]; then
+            INTERRES=$(echo $INTER | sed 's/\./VLAN/')
+            RES="$RES if_$INTERRES"
+            eval "fetch_if_${INTERRES}() { fetch_if $INTER $@; };"
+            eval "config_if_${INTERRES}() { config_if $INTER $@; };"
+          fi
+        fi
+      fi
     done
   elif [ "$PLUG" = "if_err_" ]; then
     for INTER in $(grep '^ *\(ppp\|eth\|wlan\|ath\|ra\|ipsec\|tap\|br-\)\([^:]\)\{1,\}:' /proc/net/dev | cut -f1 -d: | sed 's/ //g
 s/\-/_/g');
     do
-      INTERRES=$(echo $INTER | sed 's/\./VLAN/')
-      RES="$RES if_err_$INTERRES"
-      eval "fetch_if_err_${INTERRES}() { fetch_if_err $INTER $@; };"
-      eval "config_if_err_${INTERRES}() { config_if_err $INTER $@; };"
+      if [ -n "$(which ethtool)" ]; then
+        if [ -x "$(which ethtool)" ]; then
+          if [ -n "$(ethtool $INTER | grep 'Link detected: yes')" ]; then
+            INTERRES=$(echo $INTER | sed 's/\./VLAN/')
+            RES="$RES if_err_$INTERRES"
+            eval "fetch_if_err_${INTERRES}() { fetch_if_err $INTER $@; };"
+            eval "config_if_err_${INTERRES}() { config_if_err $INTER $@; };"
+          fi
+        fi
+      fi
     done
   elif [ "$PLUG" = "netstat" ]; then
     if netstat -s >/dev/null 2>&1; then