summaryrefslogtreecommitdiff
path: root/stats
diff options
context:
space:
mode:
Diffstat (limited to 'stats')
-rwxr-xr-xstats/calc.sh21
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
+
+