Skip to content

Commit 296d858

Browse files
authored
Initial recode of output to iostat style
- Initial recode of output to iostat style - change from hardcoded target to command-line argument: lvmcachestat VG/LV
1 parent 52d5c58 commit 296d858

1 file changed

Lines changed: 31 additions & 17 deletions

File tree

lvmcachestat

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/bin/bash
22
#
3-
# lvmcache-statistics.sh displays the LVM cache statistics
4-
# in a user friendly manner
3+
# lvmcachestat displays the LVM cache statistics in the iostat style
54
#
65
# Copyright (C) 2014 Armin Hammer
76
#
@@ -19,16 +18,27 @@
1918
# with this program. If not, see http://www.gnu.org/licenses/.
2019
#
2120
# History:
22-
# 20141220 hammerar, initial version
21+
# 20141220: hammerar: initial version
22+
# 20161230: rocketraman: Fix core and policy args count
23+
# 20230309: poddmo: rename to lvmcachestat. Begin to recode the output in
24+
# the style of iostat
25+
#
26+
#
2327
#
2428
##################################################################
2529
set -o nounset
2630

27-
LVCACHED=/dev/vg00/lvol0
31+
## create list of logical volumes to report
32+
# from command line arguments otherwise lvs | grep cache
33+
34+
LVCACHED="$1"
35+
2836

37+
## poll for logical volume details
2938
RESULT=$(dmsetup status ${LVCACHED})
3039
if [ $? -ne 0 ]; then
31-
echo "Unsuccessfull readout of <${LVCACHED}>! Abort...!"
40+
echo "Unsuccessful readout of ${LVCACHED}"
41+
echo "Usage: lvmcachestat VG/LV"
3242
exit 1
3343
fi
3444

@@ -80,11 +90,11 @@ CoreArgs=""
8090

8191
if [ ${NrCoreArgs} -ne 0 ]; then
8292

83-
for ITEM in $(seq $((INDEX+1)) $((2*NrCoreArgs+INDEX)) ); do
93+
for ITEM in $(seq $((INDEX+1)) $((NrCoreArgs+INDEX)) ); do
8494
CoreArgs="${CoreArgs}${RESULTS[${ITEM}]} "
8595
done
8696

87-
INDEX=$((INDEX+2*NrCoreArgs))
97+
INDEX=$((INDEX+NrCoreArgs))
8898
fi
8999

90100
INDEX=$((INDEX+1))
@@ -95,29 +105,33 @@ PolicyArgs=""
95105

96106
if [ ${NrPolicyArgs} -ne 0 ]; then
97107

98-
for ITEM in $(seq $((INDEX+1)) $((2*NrPolicyArgs+INDEX)) ); do
108+
for ITEM in $(seq $((INDEX+1)) $((NrPolicyArgs+INDEX)) ); do
99109
PolicyArgs="${PolicyArgs}${RESULTS[${ITEM}]} "
100110
done
101111

102-
INDEX=$((INDEX+2*NrPolicyArgs))
112+
INDEX=$((INDEX+NrPolicyArgs))
103113
fi
104114

105115
##################################################################
106116
# human friendly output
107117
##################################################################
108-
echo "------------------------------------"
109-
echo "LVM Cache report of ${LVCACHED}"
110-
echo "------------------------------------"
118+
#echo "------------------------------------"
119+
#echo "LVM Cache report of ${LVCACHED}"
120+
#echo "------------------------------------"
111121

112122
MetaUsage=$( echo "scale=1;($NrUsedMetadataBlocks * 100) / $NrTotalMetadataBlocks" | bc)
113123
CacheUsage=$( echo "scale=1;($NrUsedCacheBlocks * 100) / $NrTotalCacheBlocks" | bc)
114-
echo "- Cache Usage: ${CacheUsage}% - Metadata Usage: ${MetaUsage}%"
124+
#echo "- Cache Usage: ${CacheUsage}% - Metadata Usage: ${MetaUsage}%"
115125

116126
ReadRate=$( echo "scale=1;($NrReadHits * 100) / ($NrReadMisses + $NrReadHits)" | bc)
117127
WriteRate=$( echo "scale=1;($NrWriteHits * 100) / ($NrWriteMisses + $NrWriteHits)" | bc)
118-
echo "- Read Hit Rate: ${ReadRate}% - Write Hit Rate: ${WriteRate}%"
119-
echo "- Demotions/Promotions/Dirty: ${NrDemotions}/${NrPromotions}/${NrDirty}"
120-
echo "- Features in use: ${FeatureArgs}"
128+
#echo "- Read Hit Rate: ${ReadRate}% - Write Hit Rate: ${WriteRate}%"
129+
#echo "- Demotions/Promotions/Dirty: ${NrDemotions}/${NrPromotions}/${NrDirty}"
130+
#echo "- Features in use: ${FeatureArgs}"
131+
132+
##################################################################
133+
# iostat style output
134+
##################################################################
121135

122-
#### EOF #########################################################
136+
echo "${LVCACHED} CacheUsage:${CacheUsage}% MetaUsage:${MetaUsage}% ReadHitRate:${ReadRate}% WriteHitRate:${WriteRate}% DPD:${NrDemotions}/${NrPromotions}/${NrDirty}"
123137

0 commit comments

Comments
 (0)