mirror of
https://github.com/mosbth/cimage.git
synced 2025-08-06 16:16:39 +02:00
Adding utility to ease gathering stats on cache usage. #21
This commit is contained in:
@@ -133,6 +133,7 @@ Revision history
|
|||||||
|
|
||||||
v0.5.x (latest)
|
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-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.
|
* Cache now uses same file extension as original image #37.
|
||||||
* Can output image as json format using `json` #11.
|
* Can output image as json format using `json` #11.
|
||||||
|
36
cache.bash
Executable file
36
cache.bash
Executable 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"
|
Reference in New Issue
Block a user