diff options
author | Bill <bill@billserver.senders.io> | 2021-04-08 16:57:30 -0400 |
---|---|---|
committer | Bill <bill@billserver.senders.io> | 2021-04-08 16:57:30 -0400 |
commit | 57937673ebbafe7cd81884708e8916013abff063 (patch) | |
tree | 14fec3d4f5232c6c8573ee940945dc3ede6584fe /stats | |
parent | 643c8b29741f19accf13836148befe1f31c12011 (diff) |
Devlog 5 and stats CLI
Diffstat (limited to 'stats')
-rwxr-xr-x | stats/calc.sh | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/stats/calc.sh b/stats/calc.sh new file mode 100755 index 0000000..e0005bf --- /dev/null +++ b/stats/calc.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +LOGFILE=$1 +OUTFILE=$2 + +if [ $# -lt 2 ]; then + echo "Usage: + ./calc.sh logs/access.log gemini/stats.gmi + " +fi + +TODAY=$(date -Id) +echo -e "Stats for day:\t$TODAY" > $OUTFILE +echo -e "Total Reqs:\t"$(grep 'OUT' ${LOGFILE} | grep "${TODAY}" | wc -l) >> $OUTFILE +echo -e "Gemlog Reads:\t"$(grep 'IN' ${LOGFILE} | grep "${TODAY}" | grep "gemlog" | grep "gmi" | wc -l) >> $OUTFILE +echo "Top 5 Gemlogs" >> $OUTFILE +echo "--------------" >> $OUTFILE +grep "IN" ${LOGFILE} | grep "${TODAY}" | cut -f4 | grep "gemlog" | grep ".gmi" | sort | uniq -c | sort -rn | head -n5 >> $OUTFILE +echo -e "\n// generated $(date -u -Is)" >> $OUTFILE + + |