From 9dd9c2ec2e0e0f34db95d9650ea253c147f8c7d3 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 11 Jan 2022 00:19:35 +0100 Subject: zfs/syncoid: add duration of job to prometheus metrics --- roles/storage/zfs/syncoid/templates/syncoid_finalize.j2 | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'roles/storage/zfs/syncoid/templates/syncoid_finalize.j2') diff --git a/roles/storage/zfs/syncoid/templates/syncoid_finalize.j2 b/roles/storage/zfs/syncoid/templates/syncoid_finalize.j2 index 5ddc691b..3869e975 100644 --- a/roles/storage/zfs/syncoid/templates/syncoid_finalize.j2 +++ b/roles/storage/zfs/syncoid/templates/syncoid_finalize.j2 @@ -3,7 +3,7 @@ echo "running sanoid --prune to cleanup old snapshots" sleep 5 -echo systemctl start --wait sanoid-prune.service +systemctl start --wait sanoid-prune.service echo "wait 30s (autosuspend cooldown period)" sleep 30 @@ -27,8 +27,19 @@ for line in $(cat "$RUNTIME_DIRECTORY/exit_codes"); do fi done +now=$(date +"%s") +starttime=$(cat "$RUNTIME_DIRECTORY/start") +duration=0 +if [[ $starttime =~ [^[:digit:]] ]]; then + ret=-1 + echo "invalid starttime from pull script: $starttime" +else + duration=$(( now - starttime )) +fi + cat <> "$RUNTIME_DIRECTORY/metrics" -syncoid_pull_last_run{backup_server="{{ inventory_hostname }}"} $(date +"%s") +syncoid_pull_run{backup_server="{{ inventory_hostname }}"} $now +syncoid_pull_duration_seconds{backup_server="{{ inventory_hostname }}"} $duration EOF -- cgit v1.2.3