-
Notifications
You must be signed in to change notification settings - Fork 3
/
glusterfsd_throughput
executable file
·52 lines (45 loc) · 1.3 KB
/
glusterfsd_throughput
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
#
# Plugin created by Adrian Rollett, based on nfsd plugin
#%# family=auto
#%# capabilities=autoconf
DAEMON='glusterfsd'
CLIENTFS='/gluster/gluster'
LOGFILE='/var/log/glusterfs/glusterfsd.vol.log'
throughput='BytesRead BytesWritten'
if [ "$1" = "autoconf" ]; then
if ps -C "$DAEMON" >/dev/null; then
echo yes
exit 0
else
echo "no (no $DAEMON)"
exit 1
fi
fi
if [ "$1" = "config" ]; then
echo 'graph_title GlusterFS Server Throughput'
echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel bytes / ${graph_period}'
echo 'graph_total total'
echo 'graph_category GlusterFS Throughput'
for a in $throughput ; do echo "$a.label $a" ; echo "$a.type DERIVE"; echo "$a.min 0"; done
exit 0
fi
if ps -C "$DAEMON" >/dev/null;
then
TMPFILE=`tempfile`
# The io-debug xlator requires us to set a file xattr in order to dump stats.
setfattr -n trusted.io-stats-dump $CLIENTFS
# Now we immediately get the last 200 lines of the server's logfile. This should
# almost certainly get the stats we need.
tail -200 $LOGFILE > $TMPFILE
FIRSTLINE=`sed -n '/=== Cumulative stats ===/ =' $TMPFILE|tail -1`
for a in $throughput; do
echo -n "$a.value "
tail -n +$FIRSTLINE $TMPFILE | grep "${a} : [0-9]\+$" | head -1 | awk '{print $NF}'
done
rm $TMPFILE
else
echo "Cannot read $DAEMON" >&2
exit -1
fi