--- a/examples/instance_statistics.sh Thu May 11 18:48:22 2017 +0200
+++ b/examples/instance_statistics.sh Thu May 11 21:03:45 2017 +0200
@@ -16,7 +16,7 @@
start=${1:-1 hour ago}
end=${2:-now}
-TMPL='{{.date | fromunix}}: {{.users}} users, {{.statuses}} statuses{{"\n"}}'
+TMPL='{{.date | fromunix}} {{.instance_name}}: {{printf "%.0f users, %.0f statuses\n" .users .statuses}}'
madonctl instance --stats --template "$TMPL" \
--start "$(date +%s -d "$start")" \
--end "$(date +%s -d "$end")"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/instance_statistics_evolution.sh Thu May 11 21:03:45 2017 +0200
@@ -0,0 +1,28 @@
+#! /bin/zsh
+#
+# Instance statistics for a given period (default: 4 last weeks)
+#
+# Usage: $0 [[--server INSTANCE] Number_of_weeks]
+#
+# Mikael
+
+if [[ $1 == "--server" || $1 == "-i" ]]; then
+ opt=("--server" "$2")
+ shift 2
+fi
+
+w=${1:-4}
+
+TMPL='({{(.date | fromunix).Format "2006-01-02"}}) {{.instance_name}}: {{printf "%.0f users, %.0f statuses\n" .users .statuses}}'
+
+typeset -i wa="$w"
+while (( wa >= 0 )); do
+ when="$wa weeks ago"
+ s=$(date +%s -d "$when")
+ stats="$(madonctl instance ${opt[*]} --stats --template "$TMPL" \
+ --start "$(( s-3600 ))" --end "$s" | tail -1)"
+ if [[ -n $stats ]]; then
+ echo "$when $stats"
+ fi
+ (( wa-=1 ))
+done