Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Quick shell script to quickly gather a CSV with RP CG replication stats
RP="192.168.100.101"
out="./cg_stats.out"
groups="./groups.in"
#plink -l admin -pw admin $RP "get_groups" | egrep -v "Production|DRSite|Copies|Groups" | sed -e '/^$/d' | awk -F\: '{print $1}' | sed '$d' > $GroupTmp
echo "CGName,JournalUsage,JournalLag,ReplicationLag,CurrentProtectionWindow,PredictedProtectionWindow"
echo "CGName,JournalUsage,JournalLag,ReplicationLag,CurrentProtectionWindow,PredictedProtectionWindow" > $out
for name in `cat $groups`; do
#JournalTotal=`plink -l admin -pw admin $RP "get_group_statistics $name" | egrep "Total:" | tail -n1 | awk '{for (i=2; i<NF; i++) printf $i " "; print $NF}'`
JournalUsage=`plink -l admin -pw admin $RP "get_group_statistics $name" | egrep "Usage:" | tail -n1 | awk '{for (i=2; i<NF; i++) printf $i " "; print $NF}'`
JournalLag=`plink -l admin -pw admin $RP "get_group_statistics $name" | egrep "Journal lag:" | tail -n1 | awk '{for (i=3; i<NF; i++) printf $i " "; print $NF}'`
ReplicaLag=`plink -l admin -pw admin $RP "get_group_statistics $name" | egrep "Time:" | tail -n1 | awk '{for (i=2; i<NF; i++) printf $i " "; print $NF}'`
CurProtectWindow=`plink -l admin -pw admin $RP "get_group_statistics $name" | egrep "Value:" | head -n1 | awk '{for (i=2; i<NF; i++) printf $i " "; print $NF}'`
PredictedProtectWindow=`plink -l admin -pw admin $RP "get_group_statistics $name" | egrep "Value:" | tail -n1 | awk '{for (i=2; i<NF; i++) printf $i " "; print $NF}'`
echo $name,$JournalUsage,$JournalLag,$ReplicaLag,$CurProtectWindow,$PredictedProtectWindow
echo $name,$JournalUsage,$JournalLag,$ReplicaLag,$CurProtectWindow,$PredictedProtectWindow >> $out
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment