munin /proc/user_beancounters

raw

vebc_.sh

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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
#
# plugin to monitor OpenVZ bean counters.
#
#
#%# family=auto
#%# capabilities=autoconf suggest
 
ATTR=`basename $0 | sed -e 's/^vebc_.*_//'`
STATS=`basename $0 | sed -e 's/^vebc_//' -e 's/_[0-9]*$//' -e 's/_/ /g'`
 
if [ "$1" = "autoconf" ]; then
    if [ -r /proc/bc/0/resources ]; then
        echo yes
        exit 0
    else
        echo "no (/proc/bc/0/resources not found)"
        exit 1
    fi
fi
 
if [ "$1" = "suggest" ]; then
    if [ -r /proc/bc/0/resources ]; then
        cat /proc/bc/0/resources |
            while read str; do
                vals=($str)
                echo ${vals[0]}
            done
        exit 0
    else
        exit 1
    fi
fi
 
if [ "$1" = "config" ]; then
    #       echo "graph_order down up"
    echo "graph_title beancounter for CT$ATTR: $STATS"
    echo "graph_category CT$ATTR"
    echo "graph_info 'Container bean counters info'"
 
    readme="false"
    cat /proc/user_beancounters | while read myid stuff; do
        line=""
        if [ "$myid" == "$ATTR:" ]; then
            readme="true"
            line="$stuff"
            echo $line
        else
            loid=`echo $myid | sed -e 's/.*:/:/'`
            if [ "$loid" == ":" ]; then
                readme="false"
            fi
            if [ "$readme" == "true" ]; then
                line="$myid $stuff"
                echo $line
            fi
        fi
    done | while read name value top warn max failcnt; do
        okname="dummy"
        for statname in $STATS; do
            if [ "$name" == "$statname" ]; then
                okname=$name
            fi
        done
 
        if [ "$okname" != "dummy" ]; then
            echo $okname.label $name
            echo $okname.warning $warn
            echo $okname.critical $max
        fi
    done
    exit 0
fi;
 
readme="false"
cat /proc/user_beancounters | while read myid stuff; do
    line=""
    if [ "$myid" == "$ATTR:" ]; then
        readme="true"
        line="$stuff"
        echo $line
    else
        loid=`echo $myid | sed -e 's/.*:/:/'`
        if [ "$loid" == ":" ]; then
            readme="false"
        fi
        if [ "$readme" == "true" ]; then
            line="$myid $stuff"
            echo $line
        fi
    fi
done | while read name value x; do
    okname="dummy"
    for statname in $STATS; do
        if [ "$name" == "$statname" ]; then
            okname=$name
        fi
    done
    if [ "$okname" != "dummy" ]; then
        echo $okname.value $value
    fi
 
done
 
Christian Weiske Christian Weiske
owner

History