PluginOutdatedCatalog: xen_traffic_all

File xen_traffic_all, 1.7 KB (added by human, at 2006-09-29T05:04:54+02:00)

xen traffic of all bridged interfaces

Line 
1#!/bin/sh
2# Author: mario manno <mail@manno.name>
3# Description: measure traffic for all xen hosts
4#
5#%# family=auto
6#%# capabilities=autoconf
7
8if [ "$1" = "autoconf" ]; then
9    if which xm > /dev/null ; then
10        echo yes
11    else
12        echo "no (xm not found)"
13        exit 1
14    fi
15    if [ -r /proc/net/dev ]; then
16        echo yes
17    else
18        echo "no (/proc/net/dev not found)"
19        exit 1
20    fi
21    exit 0
22fi
23
24if [ "$1" = "config" ]; then
25    echo 'graph_title Xen Traffic'
26    echo 'graph_vlabel bits received (-) / sent (+) per ${graph_period}'
27    echo 'graph_args --base 1024 -l 0'
28    echo 'graph_category xen'
29    DOMAINS=$(xm list | awk '{print $1}' | egrep -v "^(Name|Domain-0)")
30    for dom in $DOMAINS; do
31        name=$( echo $dom | sed -e's/-/_/g' )
32        #echo $name"UP.label $name"
33        #echo $name"DOWN.label $name"
34
35        echo $name'Down.label received'
36        echo $name'Down.type COUNTER'
37        echo $name'Down.graph no'
38        echo "${name}Down.cdef ${name}Down,8,*"
39        echo "${name}Up.label ${name}"
40        echo $name'Up.type COUNTER'
41        echo "${name}Up.negative ${name}Down"
42        echo "${name}Up.cdef ${name}Up,8,*"
43    done
44    exit 0
45fi
46
47DOMAINS=$(xm list | awk '{print $1}' | egrep -v "^(Name|Domain-0)")
48for dom in $DOMAINS; do
49    dev=$( xm network-list $dom |\
50        egrep "^[0-9]+" | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@')
51    name=$( echo $dom | sed -e's/-/_/g' )
52    awk -v name="$name" -v interface="$dev" \
53        'BEGIN { gsub(/\./, "\\.", interface) } \
54        $1 ~ "^" interface ":" {
55            split($0, a, /: */); $0 = a[2]; \
56            print name"Down.value " $1 "\n"name"Up.value " $9 \
57        }' \
58        /proc/net/dev
59done