Skip to content

Instantly share code, notes, and snippets.

@oernii
Created August 19, 2014 09:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save oernii/85b446c67db974e9c74c to your computer and use it in GitHub Desktop.
Save oernii/85b446c67db974e9c74c to your computer and use it in GitHub Desktop.
#!/bin/bash
# $Id: dm-cache-status,v 1.1 2014/08/19 09:02:46 oernii Exp $
# Status
# ------
#
# <metadata block size> <#used metadata blocks>/<#total metadata blocks>
# <cache block size> <#used cache blocks>/<#total cache blocks>
# <#read hits> <#read misses> <#write hits> <#write misses>
# <#demotions> <#promotions> <#dirty> <#features> <features>*
# <#core args> <core args>* <policy name> <#policy args> <policy args>*
#
# metadata block size : Fixed block size for each metadata block in
# sectors
# #used metadata blocks : Number of metadata blocks used
# #total metadata blocks : Total number of metadata blocks
# cache block size : Configurable block size for the cache device
# in sectors
# #used cache blocks : Number of blocks resident in the cache
# #total cache blocks : Total number of cache blocks
# #read hits : Number of times a READ bio has been mapped
# to the cache
# #read misses : Number of times a READ bio has been mapped
# to the origin
# #write hits : Number of times a WRITE bio has been mapped
# to the cache
# #write misses : Number of times a WRITE bio has been
# mapped to the origin
# #demotions : Number of times a block has been removed
# from the cache
# #promotions : Number of times a block has been moved to
# the cache
# #dirty : Number of blocks in the cache that differ
# from the origin
# #feature args : Number of feature args to follow
# feature args : 'writethrough' (optional)
# #core args : Number of core arguments (must be even)
# core args : Key/value pairs for tuning the core
# e.g. migration_threshold
# policy name : Name of the policy
# #policy args : Number of policy arguments to follow (must be even)
# policy args : Key/value pairs
# e.g. sequential_threshold
pool=${1:-rhel-BigCachedPool}
line=`dmsetup status $pool`
arrIN=(${line/ / })
let count=3
echo -n "<metadata block size> :"
echo ${arrIN[$count]}; let count++
echo -n "<#used metadata blocks>/<#total> :"
echo "${arrIN[$count]} [$(echo "scale=3; ${arrIN[$count]}*100"|bc)%]"; let count++
echo -n "<cache block size> :"
echo ${arrIN[$count]}; let count++
echo -n "<#used cache blocks>/<#total> :"
echo "${arrIN[$count]} [$(echo "scale=3; ${arrIN[$count]}*100"|bc)%]"; let count++
echo -n "<#read hits> :"
hits=${arrIN[$count]}
echo ${arrIN[$count]}; let count++
echo -n "<#read misses> :"
echo "${arrIN[$count]} [$(echo "scale=3; $hits/${arrIN[$count]}*100"|bc)%]"; let count++
echo -n "<#write hits> :"
hits=${arrIN[$count]}
echo ${arrIN[$count]}; let count++
echo -n "<#write misses> :"
echo "${arrIN[$count]} [$(echo "scale=3; $hits/${arrIN[$count]}*100"|bc)%]"; let count++
echo -n "<#demotions> :"
echo ${arrIN[$count]}; let count++
echo -n "<#promotions> :"
echo ${arrIN[$count]}; let count++
echo -n "<#dirty> :"
echo ${arrIN[$count]}; let count++
echo -n "<#features> :"
let loop=${arrIN[$count]}
echo ${arrIN[$count]}; let count++
for x in `seq 1 $loop`;
do
echo -n " <features>* :"
echo ${arrIN[$count]}; let count++
done
echo -n "<#core args> :"
let loop=${arrIN[$count]}
echo ${arrIN[$count]}; let count++
for x in `seq 1 $loop`;
do
echo -n " <core args>* :"
echo ${arrIN[$count]}; let count++
done
echo -n "<policy name> :"
echo ${arrIN[$count]}; let count++
echo -n "<#policy args> :"
let loop=${arrIN[$count]}
echo ${arrIN[$count]}; let count++
for x in `seq 1 $loop`;
do
echo -n " <policy args>* :"
echo ${arrIN[$count]}; let count++
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment