Projet

Général

Profil

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

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

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

1 498e871d yoannmoulin
#!/usr/local/bin/bash
2 d9722c22 Yoann Moulin
#
3
# Plugin to monitor a ZFS Filesystem
4
#
5
# 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
# 
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 4d80dc5a Yoann Moulin
# 
20
# ** WARNING **
21
# For now this plugin does not allow "_" in the name of a zpool or filesystems
22 d9722c22 Yoann Moulin
#
23
24 b6c8c559 yoannmoulin
myname=`basename $0 | sed 's/^zfs_fs_//g' | sed -e 's/_/\//g'`
25 d9722c22 Yoann Moulin
26
if [ "$1" = "autoconf" ]; then
27
    # Makes little sense to autoconf if you can't suggest
28
    echo no
29
    exit 0
30
fi
31
32
if [ "$1" = "suggest" ]; then
33
	exit 0
34
fi
35
36 498e871d yoannmoulin
values=( $(zfs get -p usedbydataset,usedbychildren,usedbysnapshots,usedbyrefreservation,available,quota $myname | awk 'BEGIN {total=0;} { if( NR==1 ) next; } !/quota/ {total=total+$3;} {print $3} END{print total;}') )
37 d9722c22 Yoann Moulin
38
if [ "$1" = "config" ]; then
39
40 4d80dc5a Yoann Moulin
	echo <<EOF "graph_title zfs $myname
41
graph_order usedbydataset usedbychildren usedbysnapshots usedbyrefreservation available total quota
42
graph_args --base 1024 -r -l 0 --vertical-label Bytes --upper-limit ${values[6]}
43
graph_info This graph shows how is used a zfs filesystems.
44
graph_category Zfs
45
graph_period second
46
usedbydataset.label UsedByDataset
47
usedbydataset.draw AREA
48
usedbydataset.info Used space by Dataset
49
usedbydataset.colour FF0000
50
usedbychildren.label UsedByChildren
51
usedbychildren.draw STACK
52
usedbychildren.info Used space by children
53
usedbychildren.colour FFCC33
54
usedbysnapshots.label UsedBySnapshots
55
usedbysnapshots.draw STACK
56
usedbysnapshots.info Used space by snapshot
57
usedbysnapshots.colour 0000FF
58
usedbyrefreservation.label Usedbyrefreservation
59
usedbyrefreservation.draw STACK
60
usedbyrefreservation.info Used space by Ref Reservation
61
usedbyrefreservation.colour 33CCFF
62
available.label Available
63
available.draw STACK
64
available.info Free space
65
available.colour 00FF00
66
total.label Total
67
total.draw LINE1
68
total.info Total
69
total.colour 000000
70
quota.label Quota
71
quota.draw LINE1
72
quota.info Quota
73
quota.colour 555555"
74
EOF
75 d9722c22 Yoann Moulin
	exit 0
76
fi
77
78 4d80dc5a Yoann Moulin
echo <<EOF "usedbydataset.value ${values[0]}
79
usedbysnapshots.value ${values[2]}
80
usedbychildren.value ${values[1]}
81
usedbyrefreservation.value ${values[3]}
82
available.value ${values[4]}
83
total.value ${values[6]}
84
quota.value ${values[5]}"
85
EOF
86 d9722c22 Yoann Moulin
87
exit 0