Created
February 10, 2019 20:14
-
-
Save teopost/6e6be203ee0dc198b60b0352d7c7eab3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function displaytime { | |
local T=$1 | |
local D=$((T/60/60/24)) | |
local H=$((T/60/60%24)) | |
local M=$((T/60%60)) | |
local S=$((T%60)) | |
printf "%s days, %s hours, %s mins, %s secs" "$D" "$H" "$M" "$S" | |
} | |
date_converter(){ | |
echo $1 | awk ' { printf "%s-%s-%s %s:%s:%s", | |
substr($0,1,4), | |
substr($0,5,2), | |
substr($0,7,2), | |
substr($0,9,2), | |
substr($0,11,2), | |
substr($0,13,2) | |
} ' | |
} | |
fakefun() { | |
a=$(head -2 $1 | tail -1 | cut -f1 -d"|" | sed -r 's/[-]+//g' ) | |
a=$(date_converter $a) | |
a2=$(date -d "$a" +%s) | |
b=$(tail -1 $1 | cut -f1 -d"|" | sed -r 's/[-]+//g' ) | |
b=$(date_converter $b) | |
b2=$(date -d "$b" +%s) | |
c=$(expr $b2 - $a2) | |
# considero solo i log > 10 minuti | |
if [ $c -gt 600 ]; then | |
dtime=$(displaytime $c) | |
# i log > 1 ora li coloro di blu | |
if [ "$c" -gt 36000 ]; then | |
bc="\e[1;31m" | |
ec="\e[0m" | |
elif [ "$c" -gt 18000 ]; then | |
bc="\e[1;33m" | |
ec="\e[0m" | |
elif [ "$c" -gt 3600 ]; then | |
bc="\e[1;34m" | |
ec="\e[0m" | |
else | |
bc="" | |
ec="" | |
f | |
printf "%b%s%b - %s, %s %-5s" "$bc" "$1" "$ec" "$c" "$b" "$dtime" | |
#displaytime $c | |
echo "" | |
fi | |
return | |
} | |
for a in $(ls stagingprop_*log) | |
do | |
fakefun $a | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment