Projet

Général

Profil

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

root / plugins / disk / lvm_ @ da50b3f8

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

1 531a1882 Patrick Domack
#!/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 005ab0c7 Niall Donegan
#	    suggest
12
#
13
# Needs to be run as root, so the following needs to be added to the config:
14
# 
15 4bcd18fe Niall Donegan
#   [lvm_*]
16 005ab0c7 Niall Donegan
#    user root
17 531a1882 Patrick Domack
#
18
# $Log$
19
#
20
# Magic markers (optional - used by munin-config and installation
21
# scripts):
22
#
23
#%# family=auto
24 005ab0c7 Niall Donegan
#%# capabilities=autoconf suggest
25 531a1882 Patrick Domack
26
if [ "$1" = "autoconf" ]; then
27 da50b3f8 Niall Donegan
    if ! which lvs 2>/dev/null; then
28
        echo "no (lvs not found)"
29
    elif ! which vgs 2>/dev/null; then
30
        echo "no (vgs not found)"
31
    else
32
        echo "yes"
33
    fi
34
    exit 0
35 531a1882 Patrick Domack
fi
36
37 005ab0c7 Niall Donegan
if [ "$1" = "suggest" ]; then
38
	vgs -o vg_name --noheadings | sed -e 's/\ *//'
39
	exit 0
40
fi
41
42
43
vg=`echo $0 | awk '{ sub(".*lvm_","",\$1); print \$1; }'`
44 531a1882 Patrick Domack
45
clean_name() {
46
    echo $1 | sed 's/[\/.-]/_/g'
47
}
48
49
50
if [ "$1" = "config" ]; then
51
52 f0122d13 Niall Donegan
        echo "graph_title Logical Volume Usage($vg)"
53 344c1917 Niall Donegan
        echo 'graph_args --base 1024 -l 0'
54 531a1882 Patrick Domack
        echo 'graph_category disk'
55
        echo 'graph_info This graph shows disk usage on the machine.'
56
        echo "free.label free"
57
        echo "free.draw AREA"
58
        lvs --units b --nosuffix --noheadings | grep "$vg" | while read i; do
59
                name=`clean_name $i`
60
                echo -n "$name.label "
61
                echo $i | awk '{ print $1 }'
62
                echo "$name.draw STACK"
63
        done
64
        exit 0
65
fi
66
67
i=`vgs --units b --nosuffix --noheadings | grep "$vg"`
68
echo -n "free.value "
69
echo $i | awk '{ print $7 }'
70
71
lvs --units b --nosuffix --noheadings | grep "$vg" | while read i; do
72
        name=`clean_name $i`
73
        echo -n "$name.value "
74
        echo $i | awk '{ print $4 }'
75
done