Add sample script for instance statistics
authorMikael Berthe <mikael@lilotux.net>
Sun, 30 Apr 2017 19:09:04 +0200
changeset 42 7aa54f7e9868
parent 41 909c3ddd83f6
child 43 59ebd755fdc9
Add sample script for instance statistics
examples/instance_statistics.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/instance_statistics.sh	Sun Apr 30 19:09:04 2017 +0200
@@ -0,0 +1,22 @@
+#! /bin/sh
+#
+# Instance statistics for a given period (default: the last hour)
+#
+# Usage: $0 [startdate [enddate]]
+# (The timestamps must be accepted by date -d)
+#
+# Examples:
+# ./instance_statistics.sh
+# ./instance_statistics.sh "30 minutes ago"
+# ./instance_statistics.sh "1 hour ago" "30 minutes ago"
+# ./instance_statistics.sh "2017-04-30 18:55:00" "2017-04-30 19:05:00"
+#
+# Mikael
+
+start=${1:-1 hour ago}
+end=${2:-now}
+
+TMPL='{{.date | fromunix}}: {{.users}} users, {{.statuses}} statuses{{"\n"}}'
+madonctl instance --stats --template "$TMPL" \
+    --start "$(date +%s -d "$start")" \
+    --end   "$(date +%s -d "$end")"