From d21da4d9353eaa1615f6a4d4d4ac73db36b37796 Mon Sep 17 00:00:00 2001 From: Rhys Smith Date: Sat, 29 Oct 2016 11:37:16 +0100 Subject: [PATCH] Add automatic data unit scaling to stats script --- utilities/stats-generate.sh | 71 +++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/utilities/stats-generate.sh b/utilities/stats-generate.sh index 635eb014..4b70f4ed 100755 --- a/utilities/stats-generate.sh +++ b/utilities/stats-generate.sh @@ -13,17 +13,38 @@ # ===== -# = Preamble +# = Some common functions # ===== +bytestohr() +{ + value=$1 + i=0 + suffix=" KMGTPEZY" + while [ $value -gt 1024 ]; do + i=$((i+1)) + value=$((value/1024)) + done + echo $value ${suffix:$i:1}B +} + + + + +# ===== +# = Set some common options +# ===== -# -# Set some common options -# logslocation="/var/stats" usageerrormsg="usage: generate-stats.sh