Use complete timestamp for last backup, output in epoch

This commit is contained in:
phil 2023-12-02 10:50:18 +01:00
parent 47fb292ff0
commit 8404625755

View file

@ -10,7 +10,7 @@ TMP_FILE=$PROM_FILE.$$
HOSTNAME=$(hostname)
BORG_INFO=$(borgmatic --no-color info --last 1 ) || mv $TMP_FILE $PROM_FILE
echo "backup_last_run{host=\"${HOSTNAME}\"} $(echo "$BORG_INFO" | grep "Time (start)" | awk '{print $4}')" >> $TMP_FILE
echo "backup_last_run{host=\"${HOSTNAME}\"} $(echo "$BORG_INFO" | grep "Time (start)" | awk '{print $4, $5}' | xargs -i date -d "{}" +"%s")" >> $TMP_FILE
echo "backup_files{host=\"${HOSTNAME}\"} $(echo "$BORG_INFO" | grep "Number of files" | awk '{print $4}')" >> $TMP_FILE
echo "backup_chunks_unique{host=\"${HOSTNAME}\"} $(echo "$BORG_INFO" | grep "Chunk index" | awk '{print $3}')" >> $TMP_FILE
echo "backup_chunks_total{host=\"${HOSTNAME}\"} $(echo "$BORG_INFO" | grep "Chunk index" | awk '{print $4}')" >> $TMP_FILE