Projet

Général

Profil

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

root / plugins / disk / lvm_ @ 60e9f79c

Historique | Voir | Annoter | Télécharger (1,53 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'
47
        echo 'graph_args --base 1024 -l 0'
48
#       echo 'graph_vlabel %'
49
        echo 'graph_category disk'
50
        echo 'graph_info This graph shows disk usage on the machine.'
51
        echo "free.label free"
52
        echo "free.draw AREA"
53
        lvs --units b --nosuffix --noheadings | grep "$vg" | while read i; do
54
                name=`clean_name $i`
55
                echo -n "$name.label "
56
                echo $i | awk '{ print $1 }'
57
                echo "$name.draw STACK"
58
        done
59
        exit 0
60
fi
61

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

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