1
0
mirror of https://github.com/mosbth/cimage.git synced 2025-07-30 21:20:11 +02:00

Adding utility to ease gathering stats on cache usage. #21

This commit is contained in:
Mikael Roos
2014-11-21 23:14:38 +01:00
parent 08ee3064d0
commit 1f5f8c02a4
2 changed files with 37 additions and 0 deletions

View File

@@ -133,6 +133,7 @@ Revision history
v0.5.x (latest)
* Adding utility `cache.bash` to ease gathering stats on cache usage. #21
* Cache-directory can now be readonly and serve all cached files, still failing when need to save files. #5
* Cache now uses same file extension as original image #37.
* Can output image as json format using `json` #11.

36
cache.bash Executable file
View File

@@ -0,0 +1,36 @@
#!/bin/bash
#
# Specify the utilities used
#
ECHO="printf"
#
# Main, start by checking basic usage
#
if [ $# -lt 1 ]
then
$ECHO "Usage: $0 [cache-dir]\n"
exit 1
elif [ ! -d "$1" ]; then
$ECHO "Usage: $0 [cache-dir]\n"
$ECHO "$1 is not a directory.\n"
exit 1
fi
#
# Print out details on cache-directory
#
$ECHO "Total size: $( du -sh $1 | cut -f1 )"
$ECHO "\nNumber of files: $( find $1 | wc -l )"
$ECHO "\n\nTop-5 largest files:\n"
$ECHO "$( du -s $1/* | sort -nr | head -5 )"
$ECHO "\n\nLast-5 created files:\n"
$ECHO "$( find $1/* -printf '%TY-%Tm-%Td %TH:%TM %p\n' | sort -r | head -5 )"
$ECHO "\n\nLast-5 accessed files:\n"
$ECHO "$( find $1/* -printf '%AY-%Am-%Ad %AH:%AM %f\n' | sort -r | head -5 )"
$ECHO "\n"