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
#!/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
    cat <<EOF
45
graph_title zfs $myname
46
graph_order usedbydataset usedbychildren usedbysnapshots usedbyrefreservation available total quota
47
graph_args --base 1024 -r -l 0 --vertical-label Bytes
48
graph_info This graph shows how is used a zfs filesystems.
49
graph_category fs
50
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
    exit 0
81
fi
82

    
83
cat <<EOF
84
usedbydataset.value ${values[0]}
85
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
quota.value ${values[5]}
91
EOF
92

    
93
exit 0