system-config/playbooks/roles/mirror-update/files/functions.sh
Ian Wienand 339cbf4c3d mirror-update: stats for vos release of mirrors
It's difficult to know if a release process is running too long when
we don't have a history of how long it should run for.

This is mostly the stats function from run_all.sh that has been
sending stats about runtimes there.  Wrap it in a vos_release function
with some minor refactoring, and update the scripts.

As noted inline, there's already release timer stats going to
afs.release.<volume> for the periodic release of docs/tarballs etc.

Change-Id: I3d79d1a0997af8977050b7f6e7cf3b7578cc8491
2020-04-09 14:34:35 +10:00

49 lines
1.2 KiB
Bash

#
# Common definitions and functions for mirror-update scripts
#
AFS_SERVER=afs01.dfw.openstack.org
VOS_RELEASE="ssh -i /root/.ssh/id_vos_release vos_release@${AFS_SERVER} vos release "
# Send a timer stat to statsd
# send_timer metric [start_time]
# * uses timer metric afs.release.<$1> normalised for stats
# * time will be taken from last call of start_timer, or $2 if set
function send_timer {
# Only send stats under cron conditions
if [[ ${UNDER_CRON} != 1 ]]; then
return
fi
local current
current=$(date '+%s')
local name
# "." is a separator, replace with _
name=${1//./_}
local start
start=${2-$_START_TIME}
local elapsed_ms
elapsed_ms=$(( (current - start) * 1000 ))
# See also the release-volumes.py script which sends stats to the
# same place for doc, etc. volumes.
echo "afs.release.${name}:${elapsed_ms}|ms" | nc -w 1 -u graphite.opendev.org 8125
echo "End timer for $name"
}
# See send_timer
function start_timer {
_START_TIME=$(date '+%s')
}
# Run vos release via ssh on the AFS server, and report the timing
# back to graphite
function vos_release {
local name
name=$1
start_timer
$VOS_RELEASE ${name}
send_timer ${name}
}