PluginOutdatedCatalog: xen_traffic_

File xen_traffic_, 1.6 KB (added by mm, at 2006-09-29T05:12:49+02:00)

Graph for one domain only

Line 
1#!/bin/sh
2# Author: mario manno <mail@manno.name>
3# Description: measure traffic for one xen host
4# Get xen host name from symlink
5#
6#%# family=auto
7#%# capabilities=autoconf suggest
8
9
10DOMAIN=$( basename $0 | sed 's/^xen_traffic_//g' )
11NAME=$( echo $DOMAIN | sed -e's/-/_/g' )
12
13if [ "$1" = "autoconf" ]; then
14    if which xm > /dev/null ; then
15        echo yes
16    else
17        echo "no (xm not found)"
18        exit 1
19    fi
20    if [ -r /proc/net/dev ]; then
21        echo yes
22    else
23        echo "no (/proc/net/dev not found)"
24        exit 1
25    fi
26    exit 0
27fi
28
29if [ "$1" = "suggest" ]; then
30    xm list | awk '{print $1}' | egrep -v "^(Name|Domain-0)"
31    exit 0
32fi
33
34if [ "$1" = "config" ]; then
35    echo "graph_title Xen Traffic for $NAME"
36    echo 'graph_vlabel bits in (-) / out (+) per ${graph_period}'
37    echo 'graph_args --base 1024 -l 0'
38    echo 'graph_category xen'
39    echo 'out.label sent'
40    echo 'out.type DERIVE'
41    echo 'out.min 0'
42    echo 'out.cdef out,8,*'
43    echo 'in.label received'
44    echo 'in.type DERIVE'
45    echo 'in.min 0'
46    echo 'in.cdef in,8,*'
47    exit 0
48fi
49
50dev=$( xm network-list $DOMAIN | egrep "^[0-9]+" | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@')#awk -v interface="$dev" -F'[: \t]+' \ '{ sub(/^ */,""); if ($1 == interface) print "down.value "$2"\nup.value "$10; }' /proc/net/dev
51
52# Escape dots in the interface name (eg. vlans) before using it as a regex
53awk -v interface="$dev" \
54    'BEGIN { gsub(/\./, "\\.", interface) } \
55    $1 ~ "^" interface ":" {
56        split($0, a, /: */); $0 = a[2]; \
57        print "in.value " $1 "\nout.value " $9 \
58    }' \
59    /proc/net/dev
60