added new xen plugin
authorMarcel Haerry <haerry@puzzle.ch>
Tue, 22 Apr 2008 13:41:02 +0000 (15:41 +0200)
committerMarcel Haerry <haerry@puzzle.ch>
Tue, 22 Apr 2008 13:41:02 +0000 (15:41 +0200)
files/plugins/xen_traffic_all [new file with mode: 0644]
manifests/plugin.pp

diff --git a/files/plugins/xen_traffic_all b/files/plugins/xen_traffic_all
new file mode 100644 (file)
index 0000000..1216a7d
--- /dev/null
@@ -0,0 +1,63 @@
+#!/bin/sh
+# Author: mario manno <projects@manno.name>
+# Description: measure traffic for all xen hosts
+#
+#%# family=auto
+#%# capabilities=autoconf
+
+if [ "$1" = "autoconf" ]; then
+    if which xm > /dev/null ; then
+        echo yes
+    else
+        echo "no (xm not found)"
+        exit 1
+    fi
+    if [ -r /proc/net/dev ]; then
+        echo yes
+    else
+        echo "no (/proc/net/dev not found)"
+        exit 1
+    fi
+    exit 0
+fi
+
+if [ "$1" = "config" ]; then
+    echo 'graph_title Xen Traffic'
+    echo 'graph_vlabel bits received (-) / sent (+) per ${graph_period}'
+    echo 'graph_args --base 1024 -l 0'
+    echo 'graph_category xen'
+    DOMAINS=$(xm list | awk '{print $1}' | egrep -v "^(Name|Domain-0)")
+    for dom in $DOMAINS; do
+        name=$( echo $dom | sed -e's/-/_/g' )
+        #echo $name"UP.label $name"
+        #echo $name"DOWN.label $name"
+        
+        echo $name'Down.label received'
+        echo $name'Down.type COUNTER'
+        echo $name'Down.graph no'
+        echo "${name}Down.cdef ${name}Down,8,*"
+        echo "${name}Up.label ${name}"
+        echo $name'Up.type COUNTER'
+        echo "${name}Up.negative ${name}Down"
+        echo "${name}Up.cdef ${name}Up,8,*"
+    done
+    exit 0
+fi
+
+DOMAINS=$(xm list | awk '{print $1}' | egrep -v "^(Name|Domain-0)")
+for dom in $DOMAINS; do
+    dev=$( xm network-list $dom |\
+        egrep "^[0-9]+" | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@')
+    name=$( echo $dom | sed -e's/-/_/g' ) 
+    #awk -v name="$name" -v interface="$dev" -F'[: \t]+' \
+    #'{ sub(/^ */,""); if ($1 == interface) \
+    #print name"DOWN.value "$2"\n"name"UP.value "$10; }' /proc/net/dev
+    awk -v name="$name" -v interface="$dev" \
+        'BEGIN { gsub(/\./, "\\.", interface) } \
+        $1 ~ "^" interface ":" {
+            split($0, a, /: */); $0 = a[2]; \
+            print name"Down.value " $1 "\n"name"Up.value " $9 \
+        }' \
+        /proc/net/dev
+done
+
index 40e7f47..d7fad3d 100644 (file)
@@ -195,6 +195,7 @@ class munin::plugins::dom0 inherits munin::plugins::physical {
     munin::plugin::deploy { "xen-cpu": config => "user root"}
     munin::plugin::deploy { "xen_memory": config => "user root"}
     munin::plugin::deploy { "xen_vbd": config => "user root"}
+    munin::plugin::deploy { "xen_traffic_all": config => "user root"}
 }
 
 class munin::plugins::physical inherits munin::plugins::base {