Projet

Général

Profil

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

root / plugins / disk / lvm_ @ ef960abc

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

1 531a1882 Patrick Domack
#!/bin/sh
2 7e736ea7 Niall Donegan
# -*- sh -*-
3
4
: << EOF
5
=head1 NAME
6
7
lvm_ - Wildcard plugin for monitoring disk usage on LVM. Each Volume Group is graphed separately.
8
9
=head1 CONFIGURATION
10
11
This plugin needs to run as the root user in order to have permission to run lvs and vgs
12
13
  [lvm_*]
14
    user root
15
16
=head1 AUTHOR
17
18
=over 4
19
20
=item * PatrickDK (Original Author)
21
22
=item * Niall Donegan
23
24
=back
25
26
=head1 LICENSE
27
28
Unknown license
29
30
31
=head1 MAGIC MARKERS
32
33
=begin comment
34
35
These magic markers are used by munin-node-configure when installing
36
munin-node.
37
38
=end comment
39
40
  #%# family=auto
41
  #%# capabilities=autoconf suggest
42
43
=cut
44
45
EOF
46 531a1882 Patrick Domack
47
if [ "$1" = "autoconf" ]; then
48 7b5183c7 Niall Donegan
    if ! command -v lvs >/dev/null; then
49 da50b3f8 Niall Donegan
        echo "no (lvs not found)"
50 7b5183c7 Niall Donegan
    elif ! command -v vgs >/dev/null; then
51 da50b3f8 Niall Donegan
        echo "no (vgs not found)"
52
    else
53
        echo "yes"
54
    fi
55
    exit 0
56 531a1882 Patrick Domack
fi
57
58 005ab0c7 Niall Donegan
if [ "$1" = "suggest" ]; then
59
	vgs -o vg_name --noheadings | sed -e 's/\ *//'
60
	exit 0
61
fi
62
63
64
vg=`echo $0 | awk '{ sub(".*lvm_","",\$1); print \$1; }'`
65 531a1882 Patrick Domack
66
clean_name() {
67
    echo $1 | sed 's/[\/.-]/_/g'
68
}
69
70
71
if [ "$1" = "config" ]; then
72
73 f0122d13 Niall Donegan
        echo "graph_title Logical Volume Usage($vg)"
74 344c1917 Niall Donegan
        echo 'graph_args --base 1024 -l 0'
75 531a1882 Patrick Domack
        echo 'graph_category disk'
76
        echo 'graph_info This graph shows disk usage on the machine.'
77
        echo "free.label free"
78
        echo "free.draw AREA"
79
        lvs --units b --nosuffix --noheadings | grep "$vg" | while read i; do
80
                name=`clean_name $i`
81
                echo -n "$name.label "
82
                echo $i | awk '{ print $1 }'
83
                echo "$name.draw STACK"
84
        done
85
        exit 0
86
fi
87
88
i=`vgs --units b --nosuffix --noheadings | grep "$vg"`
89
echo -n "free.value "
90
echo $i | awk '{ print $7 }'
91
92
lvs --units b --nosuffix --noheadings | grep "$vg" | while read i; do
93
        name=`clean_name $i`
94
        echo -n "$name.value "
95
        echo $i | awk '{ print $4 }'
96
done