# # 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 " function echo_ts { printf "%(%Y-%m-%d %H:%M:%S)T | %s\n" -1 "$@" } # 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} }