-
Notifications
You must be signed in to change notification settings - Fork 0
/
architratio.sh
executable file
·57 lines (45 loc) · 1.25 KB
/
architratio.sh
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
52
53
54
55
56
57
#!/bin/bash
# print ZFS arc cache hits
INTERVAL="$1"
if [ -z $INTERVAL ]
then
INTERVAL=5
fi
OLDHITS=0
OLDMISS=0
L2OLDHITS=0
L2OLDMISS=0
i=0
while true
do
RAW=`cat /proc/spl/kstat/zfs/arcstats`
HITS=`echo "$RAW" | grep -w hits | awk '{ print $3}'`
L2HITS=`echo "$RAW" | grep -w l2_hits | awk '{ print $3}'`
MISSES=`echo "$RAW" | grep -w misses | awk '{ print $3}'`
L2MISSES=`echo "$RAW" | grep -w l2_misses | awk '{ print $3}'`
HITRATE=$(((HITS-OLDHITS)/INTERVAL))
L2HITRATE=$(((L2HITS-L2OLDHITS)/INTERVAL))
MISSRATE=$(((MISSES-OLDMISS)/INTERVAL))
L2MISSRATE=$(((L2MISSES-L2OLDMISS)/INTERVAL))
OLDHITS=$HITS
L2OLDHITS=$L2HITS
OLDMISS=$MISSES
L2OLDMISS=$L2MISSES
REQS=$((HITRATE+MISSRATE))
if [ "$HITRATE" != 0 ] && [ "$REQS" != 0 ]
then
HITPERCENT=`echo "scale=2; (($HITRATE / $REQS) * 100)" | bc`
L2HITPERCENT=`echo "scale=2; (($L2HITRATE / $REQS) * 100)" | bc`
else
HITPERCENT=0
L2HITPERCENT=0
fi
if [ "$i" -gt 0 ]
then
echo "IOPs: $REQS | ARC cache hit ratio: $HITPERCENT % | Hitrate: $HITRATE / Missrate: $MISSRATE | L2ARC $L2HITPERCENT $L2HITRATE / $L2MISSRATE"
else
echo "..."
fi
((i++))
sleep $INTERVAL
done