Projet

Général

Profil

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

root / plugins / disk / lvm_ @ 8589c6df

Historique | Voir | Annoter | Télécharger (1,88 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 1e2bbe77 Ken-ichi Mito
. $MUNIN_LIBDIR/plugins/plugin.sh
48
49
50 531a1882 Patrick Domack
if [ "$1" = "autoconf" ]; then
51 7b5183c7 Niall Donegan
    if ! command -v lvs >/dev/null; then
52 da50b3f8 Niall Donegan
        echo "no (lvs not found)"
53 7b5183c7 Niall Donegan
    elif ! command -v vgs >/dev/null; then
54 da50b3f8 Niall Donegan
        echo "no (vgs not found)"
55
    else
56
        echo "yes"
57
    fi
58
    exit 0
59 531a1882 Patrick Domack
fi
60
61 005ab0c7 Niall Donegan
if [ "$1" = "suggest" ]; then
62
	vgs -o vg_name --noheadings | sed -e 's/\ *//'
63
	exit 0
64
fi
65
66
67
vg=`echo $0 | awk '{ sub(".*lvm_","",\$1); print \$1; }'`
68 531a1882 Patrick Domack
69
clean_name() {
70 1e2bbe77 Ken-ichi Mito
    echo "$(clean_fieldname "$1")"
71 531a1882 Patrick Domack
}
72
73
74
if [ "$1" = "config" ]; then
75
76 f0122d13 Niall Donegan
        echo "graph_title Logical Volume Usage($vg)"
77 344c1917 Niall Donegan
        echo 'graph_args --base 1024 -l 0'
78 531a1882 Patrick Domack
        echo 'graph_category disk'
79
        echo 'graph_info This graph shows disk usage on the machine.'
80
        echo "free.label free"
81
        echo "free.draw AREA"
82
        lvs --units b --nosuffix --noheadings | grep "$vg" | while read i; do
83
                name=`clean_name $i`
84
                echo -n "$name.label "
85
                echo $i | awk '{ print $1 }'
86
                echo "$name.draw STACK"
87
        done
88
        exit 0
89
fi
90
91
i=`vgs --units b --nosuffix --noheadings | grep "$vg"`
92
echo -n "free.value "
93
echo $i | awk '{ print $7 }'
94
95
lvs --units b --nosuffix --noheadings | grep "$vg" | while read i; do
96
        name=`clean_name $i`
97
        echo -n "$name.value "
98
        echo $i | awk '{ print $4 }'
99
done