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 90c4727a Lutz Reinhardt
#!/usr/bin/env bash
2 d9722c22 Yoann Moulin
#
3
# Plugin to monitor a ZFS Filesystem
4
#
5 17f78427 Lars Kruse
# Wildcard-plugin to monitor a zfs filesystems.
6 4d80dc5a Yoann Moulin
#
7 d9722c22 Yoann Moulin
# 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 17f78427 Lars Kruse
#
11 d9722c22 Yoann Moulin
# ...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 17f78427 Lars Kruse
#
20 4d80dc5a Yoann Moulin
# ** WARNING **
21
# For now this plugin does not allow "_" in the name of a zpool or filesystems
22 d9722c22 Yoann Moulin
#
23 e68a0308 Lars Kruse
#  #%# capabilities=autoconf
24
#
25 d9722c22 Yoann Moulin
26 7fed3b97 Lars Kruse
myname=$(basename "$0" | sed 's/^zfs_fs_//g' | sed -e 's/_/\//g')
27 d9722c22 Yoann Moulin
28
if [ "$1" = "autoconf" ]; then
29 e68a0308 Lars Kruse
    if which zfs >/dev/null; then
30
        echo yes
31
    else
32
        echo "no (missing executable 'zfs')"
33
    fi
34 d9722c22 Yoann Moulin
    exit 0
35
fi
36
37
38 7fed3b97 Lars Kruse
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 d9722c22 Yoann Moulin
42
if [ "$1" = "config" ]; then
43
44 4d80dc5a Yoann Moulin
	echo <<EOF "graph_title zfs $myname
45
graph_order usedbydataset usedbychildren usedbysnapshots usedbyrefreservation available total quota
46 9fd750df Wouter Verhelst
graph_args --base 1024 -r -l 0 --vertical-label Bytes
47 4d80dc5a Yoann Moulin
graph_info This graph shows how is used a zfs filesystems.
48 65652aa0 dipohl
graph_category fs
49 4d80dc5a Yoann Moulin
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 d9722c22 Yoann Moulin
	exit 0
80
fi
81
82 4d80dc5a Yoann Moulin
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 d9722c22 Yoann Moulin
91
exit 0