examples/instance_statistics.sh
author Mikael Berthe <mikael@lilotux.net>
Sat, 13 May 2017 12:36:38 +0200
changeset 132 4bf4f6ce268e
parent 122 6f318b094b78
permissions -rwxr-xr-x
html2text: Try and handle one more mention case + switch to devel version

#! /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}} {{.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")"