Projet

Général

Profil

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

root / plugins / disk / lvm_snap_used @ 64089240

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

1 51c53c63 pmoranga
#!/bin/bash
2
#
3
# Plugin to monitor the % of allocated area of a LVM snapshot
4
#
5
# Parameters:
6 17f78427 Lars Kruse
#
7 51c53c63 pmoranga
# 	config
8
# 	autoconf
9
#
10
# Configuration variables
11
#    no config variables
12
#
13
#%# family=auto
14
#%# capabilities=autoconf
15 17f78427 Lars Kruse
#
16 51c53c63 pmoranga
# 2011/05/20 - pmoranga - initial version
17 8051623f Sébastien Gross
#
18
# 2012/01/27 - Sébastien Gross
19
#            - Fix lvdisplay path
20
21 1e2bbe77 Ken-ichi Mito
22
. $MUNIN_LIBDIR/plugins/plugin.sh
23
24 8051623f Sébastien Gross
lvdisplay=$(which lvdisplay)
25 51c53c63 pmoranga
26
if [ "$1" = "autoconf" ]; then
27 8051623f Sébastien Gross
    if test -n "${lvdisplay}"; then
28
        echo yes
29 2ec4e4c1 Lars Kruse
    else
30
        echo "no (lvdisplay not found)"
31 8051623f Sébastien Gross
    fi
32 2ec4e4c1 Lars Kruse
    exit 0
33 51c53c63 pmoranga
fi
34
35
36
37
if [ "$1" = "config" ]; then
38 17f78427 Lars Kruse
	echo 'graph_title Allocated space for snapshot'
39 51c53c63 pmoranga
	echo 'graph_vlabel %'
40
	echo 'graph_category disk'
41 1e2bbe77 Ken-ichi Mito
	echo 'graph_args -l 0 -u 100 -r'
42 51c53c63 pmoranga
fi
43
44
45 1e2bbe77 Ken-ichi Mito
${lvdisplay} -C | awk '$3 ~ /^s/{print}' | while read line; do
46
    name="$(echo $line | awk '{print $1}')"
47
    id="$(clean_fieldname "$name")"
48
    origin="$(echo $line | awk '{print $5}')"
49
    origin="$(clean_fieldname "$origin")"
50
    percent="$(echo $line | awk '{print $6}')"
51 17f78427 Lars Kruse
52 1e2bbe77 Ken-ichi Mito
    if [ "$1" = "config" ]; then
53
        echo "$id.label $name snapshot of $origin"
54
    else
55
        echo "$id.value $percent"
56
    fi
57
done