examples/instance_statistics.sh
author Mikael Berthe <mikael@lilotux.net>
Thu, 11 May 2017 21:03:45 +0200
changeset 122 6f318b094b78
parent 42 7aa54f7e9868
permissions -rwxr-xr-x
Update statistic examples

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