examples/instance_statistics.sh
author Mikael Berthe <mikael@lilotux.net>
Sun, 28 May 2017 10:36:07 +0200
changeset 157 908a433f02c0
parent 122 6f318b094b78
permissions -rwxr-xr-x
Version 1.2.0
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
122
6f318b094b78 Update statistic examples
Mikael Berthe <mikael@lilotux.net>
parents: 42
diff changeset
    19
TMPL='{{.date | fromunix}} {{.instance_name}}: {{printf "%.0f users, %.0f statuses\n" .users .statuses}}'
42
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")"