Projet

Général

Profil

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

root / plugins / zfs / zfs-filesystem-graph @ e68a0308

Historique | Voir | Annoter | Télécharger (2,41 ko)

1
#!/usr/bin/env bash
2
#
3
# Plugin to monitor a ZFS Filesystem
4
#
5
# Wildcard-plugin to monitor a zfs filesystems.
6
#
7
# To monitor a filesystem, link zfs_fs_<zpool>_<filesystem> to this file. E.g.
8
#
9
#    ln -s /usr/share/munin/node/plugins-auto/zfs_fs_ /etc/munin/node.d/zfs_fs_tank_foo
10
#
11
# ...will monitor tank/foo fs.
12
#
13
# You can monitor zpool as well by a link on zfs_fs_<zpool>
14
#
15
# Parameters understood:
16
#
17
# 	config   (required)
18
# 	autoconf (optional - used by munin-config)
19
#
20
# ** WARNING **
21
# For now this plugin does not allow "_" in the name of a zpool or filesystems
22
#
23
#  #%# capabilities=autoconf
24
#
25

    
26
myname=$(basename "$0" | sed 's/^zfs_fs_//g' | sed -e 's/_/\//g')
27

    
28
if [ "$1" = "autoconf" ]; then
29
    if which zfs >/dev/null; then
30
        echo yes
31
    else
32
        echo "no (missing executable 'zfs')"
33
    fi
34
    exit 0
35
fi
36

    
37

    
38
read -r -a values <<<"$(zfs get -p usedbydataset,usedbychildren,usedbysnapshots,usedbyrefreservation,available,quota "$myname" \
39
    | awk 'BEGIN {total=0;} { if( NR==1 ) next; } !/quota/ {total=total+$3;} {print $3} END{print total;}')"
40

    
41

    
42
if [ "$1" = "config" ]; then
43

    
44
	echo <<EOF "graph_title zfs $myname
45
graph_order usedbydataset usedbychildren usedbysnapshots usedbyrefreservation available total quota
46
graph_args --base 1024 -r -l 0 --vertical-label Bytes
47
graph_info This graph shows how is used a zfs filesystems.
48
graph_category fs
49
graph_period second
50
usedbydataset.label UsedByDataset
51
usedbydataset.draw AREA
52
usedbydataset.info Used space by Dataset
53
usedbydataset.colour FF0000
54
usedbychildren.label UsedByChildren
55
usedbychildren.draw STACK
56
usedbychildren.info Used space by children
57
usedbychildren.colour FFCC33
58
usedbysnapshots.label UsedBySnapshots
59
usedbysnapshots.draw STACK
60
usedbysnapshots.info Used space by snapshot
61
usedbysnapshots.colour 0000FF
62
usedbyrefreservation.label Usedbyrefreservation
63
usedbyrefreservation.draw STACK
64
usedbyrefreservation.info Used space by Ref Reservation
65
usedbyrefreservation.colour 33CCFF
66
available.label Available
67
available.draw STACK
68
available.info Free space
69
available.colour 00FF00
70
total.label Total
71
total.draw LINE1
72
total.info Total
73
total.colour 000000
74
quota.label Quota
75
quota.draw LINE1
76
quota.info Quota
77
quota.colour 555555"
78
EOF
79
	exit 0
80
fi
81

    
82
echo <<EOF "usedbydataset.value ${values[0]}
83
usedbysnapshots.value ${values[2]}
84
usedbychildren.value ${values[1]}
85
usedbyrefreservation.value ${values[3]}
86
available.value ${values[4]}
87
total.value ${values[6]}
88
quota.value ${values[5]}"
89
EOF
90

    
91
exit 0