examples/instance_statistics.sh
author convert-repo
Fri, 05 May 2017 21:55:09 +0000
changeset 69 7217174c217a
parent 42 7aa54f7e9868
child 122 6f318b094b78
permissions -rwxr-xr-x
update tags
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     1
#! /bin/sh
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     2
#
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     3
# Instance statistics for a given period (default: the last hour)
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     4
#
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     5
# Usage: $0 [startdate [enddate]]
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     6
# (The timestamps must be accepted by date -d)
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     7
#
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     8
# Examples:
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     9
# ./instance_statistics.sh
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    10
# ./instance_statistics.sh "30 minutes ago"
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    11
# ./instance_statistics.sh "1 hour ago" "30 minutes ago"
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    12
# ./instance_statistics.sh "2017-04-30 18:55:00" "2017-04-30 19:05:00"
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    13
#
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    14
# Mikael
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    15
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    16
start=${1:-1 hour ago}
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    17
end=${2:-now}
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    18
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    19
TMPL='{{.date | fromunix}}: {{.users}} users, {{.statuses}} statuses{{"\n"}}'
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    20
madonctl instance --stats --template "$TMPL" \
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    21
    --start "$(date +%s -d "$start")" \
7aa54f7e9868 Add sample script for instance statistics
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    22
    --end   "$(date +%s -d "$end")"