Projet

Général

Profil

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

root / plugins / zfs / zfs-filesystem-graph @ 94434e4b

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 94434e4b Lars Kruse
    cat <<EOF
45
graph_title zfs $myname
46 4d80dc5a Yoann Moulin
graph_order usedbydataset usedbychildren usedbysnapshots usedbyrefreservation available total quota
47 9fd750df Wouter Verhelst
graph_args --base 1024 -r -l 0 --vertical-label Bytes
48 4d80dc5a Yoann Moulin
graph_info This graph shows how is used a zfs filesystems.
49 65652aa0 dipohl
graph_category fs
50 4d80dc5a Yoann Moulin
graph_period second
51
usedbydataset.label UsedByDataset
52
usedbydataset.draw AREA
53
usedbydataset.info Used space by Dataset
54
usedbydataset.colour FF0000
55
usedbychildren.label UsedByChildren
56
usedbychildren.draw STACK
57
usedbychildren.info Used space by children
58
usedbychildren.colour FFCC33
59
usedbysnapshots.label UsedBySnapshots
60
usedbysnapshots.draw STACK
61
usedbysnapshots.info Used space by snapshot
62
usedbysnapshots.colour 0000FF
63
usedbyrefreservation.label Usedbyrefreservation
64
usedbyrefreservation.draw STACK
65
usedbyrefreservation.info Used space by Ref Reservation
66
usedbyrefreservation.colour 33CCFF
67
available.label Available
68
available.draw STACK
69
available.info Free space
70
available.colour 00FF00
71
total.label Total
72
total.draw LINE1
73
total.info Total
74
total.colour 000000
75
quota.label Quota
76
quota.draw LINE1
77
quota.info Quota
78
quota.colour 555555"
79
EOF
80 94434e4b Lars Kruse
    exit 0
81 d9722c22 Yoann Moulin
fi
82
83 94434e4b Lars Kruse
cat <<EOF
84
usedbydataset.value ${values[0]}
85 4d80dc5a Yoann Moulin
usedbysnapshots.value ${values[2]}
86
usedbychildren.value ${values[1]}
87
usedbyrefreservation.value ${values[3]}
88
available.value ${values[4]}
89
total.value ${values[6]}
90 94434e4b Lars Kruse
quota.value ${values[5]}
91 4d80dc5a Yoann Moulin
EOF
92 d9722c22 Yoann Moulin
93
exit 0