Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / disk / lvm_ @ f0122d13

Historique | Voir | Annoter | Télécharger (1,51 ko)

1
#!/bin/sh
2
#
3
# Script to monitor disk usage.
4
#
5
# By PatrickDK
6
#
7
# Parameters understood:
8
#
9
#       config   (required)
10
#       autoconf (optional - used by munin-config)
11
#	    suggest
12
#
13
# Needs to be run as root, so the following needs to be added to the config:
14
# 
15
#   [lvm_]
16
#    user root
17
#
18
# $Log$
19
#
20
# Magic markers (optional - used by munin-config and installation
21
# scripts):
22
#
23
#%# family=auto
24
#%# capabilities=autoconf suggest
25

    
26
if [ "$1" = "autoconf" ]; then
27
        echo yes
28
        exit 0
29
fi
30

    
31
if [ "$1" = "suggest" ]; then
32
	vgs -o vg_name --noheadings | sed -e 's/\ *//'
33
	exit 0
34
fi
35

    
36

    
37
vg=`echo $0 | awk '{ sub(".*lvm_","",\$1); print \$1; }'`
38

    
39
clean_name() {
40
    echo $1 | sed 's/[\/.-]/_/g'
41
}
42

    
43

    
44
if [ "$1" = "config" ]; then
45

    
46
        echo "graph_title Logical Volume Usage($vg)"
47
        echo 'graph_args --base 1024 -l 0'
48
        echo 'graph_category disk'
49
        echo 'graph_info This graph shows disk usage on the machine.'
50
        echo "free.label free"
51
        echo "free.draw AREA"
52
        lvs --units b --nosuffix --noheadings | grep "$vg" | while read i; do
53
                name=`clean_name $i`
54
                echo -n "$name.label "
55
                echo $i | awk '{ print $1 }'
56
                echo "$name.draw STACK"
57
        done
58
        exit 0
59
fi
60

    
61
i=`vgs --units b --nosuffix --noheadings | grep "$vg"`
62
echo -n "free.value "
63
echo $i | awk '{ print $7 }'
64

    
65
lvs --units b --nosuffix --noheadings | grep "$vg" | while read i; do
66
        name=`clean_name $i`
67
        echo -n "$name.value "
68
        echo $i | awk '{ print $4 }'
69
done