Projet

Général

Profil

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

root / plugins / other / zfs-filesystem-graph @ d9722c22

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

1
#!/bin/sh
2
#
3
# Plugin to monitor a ZFS Filesystem
4
#
5
# Wildcard-plugin to monitor a zfs filesystems. 
6
# To monitor a filesystem, link zfs_fs_<zpool>_<filesystem> to this file. E.g.
7
#
8
#    ln -s /usr/share/munin/node/plugins-auto/zfs_fs_ /etc/munin/node.d/zfs_fs_tank_foo
9
# 
10
# ...will monitor tank/foo fs.
11
#
12
# You can monitor zpool as well by a link on zfs_fs_<zpool>
13
#
14
# Parameters understood:
15
#
16
# 	config   (required)
17
# 	autoconf (optional - used by munin-config)
18
#
19
# Magic markers - optional - used by installation scripts and
20
# munin-config:
21
#
22
#%# family=auto
23
#%# capabilities=autoconf
24

    
25
myname=`basename $0 | sed 's/^zfs_fs_//g' | sed -e 's/_/\//'`
26

    
27
name="${name-\<$myname\>}"
28
REGEX="${regex-\<$name\>}"
29

    
30
if [ "$1" = "autoconf" ]; then
31
    # Makes little sense to autoconf if you can't suggest
32
    echo no
33
    exit 0
34
fi
35

    
36
if [ "$1" = "suggest" ]; then
37
	exit 0
38
fi
39

    
40
usedbydataset=`zfs get -p usedbydataset $myname | grep $myname | awk '{print $3}'`
41
usedbysnapshots=`zfs get -p usedbysnapshots $myname | grep $myname | awk '{print $3}'`
42
available=`zfs get -p available $myname | grep $myname | awk '{print $3}'`
43
usedbychildren=`zfs get -p usedbychildren $myname | grep $myname | awk '{print $3}'`
44
quota=`zfs get -p quota $myname | grep $myname | awk '{print $3}'`
45
total=$((usedbydataset+usedbysnapshots+available+usedbychildren))
46

    
47

    
48
if [ "$1" = "config" ]; then
49

    
50
	echo "graph_title zfs $myname"
51
	echo 'graph_order usedbydataset usedbysnapshots usedbychildren available total quota'
52
	echo "graph_args --base 1024 -r -l 0 --vertical-label Bytes --upper-limit $total"
53
	echo 'graph_info This graph shows how is used a zfs filesystems.'
54
	echo 'graph_category Zfs'
55
	echo 'graph_period second'
56
	echo 'usedbydataset.label Used'
57
	echo 'usedbydataset.draw AREA'
58
	echo 'usedbydataset.info Used space by Dataset'
59
	echo 'usedbydataset.colour FF0000'
60
	echo 'usedbysnapshots.label Snapshots'
61
	echo 'usedbysnapshots.draw STACK'
62
	echo 'usedbysnapshots.info Used space by snapshot'
63
	echo 'usedbysnapshots.colour 0000FF'
64
	echo 'usedbychildren.label Children'
65
	echo 'usedbychildren.draw STACK'
66
	echo 'usedbychildren.info Used space by children'
67
	echo 'usedbychildren.colour FFCC33'
68
	echo 'available.label Available'
69
	echo 'available.draw STACK'
70
	echo 'available.info Free space'
71
	echo 'available.colour 00FF00'
72
	echo 'total.label Total'
73
	echo 'total.draw LINE1'
74
	echo 'total.info Total'
75
	echo 'total.colour 000000'
76
	echo 'quota.label Quota'
77
	echo 'quota.draw LINE1'
78
	echo 'quota.info Quota'
79
	echo 'quota.colour 555555'
80
	exit 0
81
fi
82

    
83

    
84

    
85
echo "usedbydataset.value $usedbydataset"
86
echo "usedbysnapshots.value $usedbysnapshots"
87
echo "usedbychildren.value $usedbychildren"
88
echo "available.value $available"
89
echo "total.value $total"
90
echo "quota.value $quota"
91

    
92

    
93
exit 0