Cleanup, include date of last backup
This commit is contained in:
parent
fe215782ed
commit
47fb292ff0
1 changed files with 1 additions and 25 deletions
|
@ -8,33 +8,9 @@ TEXTFILE_COLLECTOR_DIR=/var/lib/prometheus/node-exporter
|
||||||
PROM_FILE=$TEXTFILE_COLLECTOR_DIR/backup.prom
|
PROM_FILE=$TEXTFILE_COLLECTOR_DIR/backup.prom
|
||||||
TMP_FILE=$PROM_FILE.$$
|
TMP_FILE=$PROM_FILE.$$
|
||||||
HOSTNAME=$(hostname)
|
HOSTNAME=$(hostname)
|
||||||
COUNTER=0
|
|
||||||
|
|
||||||
mkdir -p $TEXTFILE_COLLECTOR_DIR
|
|
||||||
|
|
||||||
IFS=$'\n'
|
|
||||||
#for i in $LIST; do
|
|
||||||
# COUNTER=$((COUNTER+1))
|
|
||||||
#done
|
|
||||||
|
|
||||||
if [ -f "$LOGFILE" ] && [ ! $(find "$LOGFILE" -mtime +2 -print) ] ; then
|
|
||||||
RESULT_B=$(cat $LOGFILE | grep "terminating" | awk '{print $3}' | head -1 )
|
|
||||||
if [ "$RESULT_B" == 'success' ]; then RESULT_BACKUP=0; elif [ "$RESULT_B" == 'warning' ]; then RESULT_BACKUP=1; elif [ "$RESULT_B" == 'error' ]; then RESULT_BACKUP=2; else RESULT_BACKUP=3; fi
|
|
||||||
RESULT_P=$(cat $LOGFILE | grep "terminating" | awk '{print $3}' | tail -1)
|
|
||||||
if [ "$RESULT_P" == 'success' ]; then RESULT_PRUNE=0; elif [ "$RESULT_P" == 'warning' ]; then RESULT_PRUNE=1; elif [ "$RESULT_P" == 'error' ]; then RESULT_PRUNE=2; else RESULT_PRUNE=3; fi
|
|
||||||
else
|
|
||||||
RESULT_BACKUP=3
|
|
||||||
RESULT_PRUNE=3
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "backup_result{host=\"${HOSTNAME}\"} $RESULT_BACKUP"
|
|
||||||
echo "prune_result{host=\"${HOSTNAME}\"} $RESULT_PRUNE"
|
|
||||||
echo "backup_result{host=\"${HOSTNAME}\"} $RESULT_BACKUP" >> $TMP_FILE
|
|
||||||
echo "prune_result{host=\"${HOSTNAME}\"} $RESULT_PRUNE" >> $TMP_FILE
|
|
||||||
|
|
||||||
|
|
||||||
BORG_INFO=$(borgmatic --no-color info --last 1 ) || mv $TMP_FILE $PROM_FILE
|
BORG_INFO=$(borgmatic --no-color info --last 1 ) || mv $TMP_FILE $PROM_FILE
|
||||||
#echo "backup_count{host=\"${HOSTNAME}\"} $COUNTER" > $TMP_FILE
|
echo "backup_last_run{host=\"${HOSTNAME}\"} $(echo "$BORG_INFO" | grep "Time (start)" | awk '{print $4}')" >> $TMP_FILE
|
||||||
echo "backup_files{host=\"${HOSTNAME}\"} $(echo "$BORG_INFO" | grep "Number of files" | awk '{print $4}')" >> $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_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
|
echo "backup_chunks_total{host=\"${HOSTNAME}\"} $(echo "$BORG_INFO" | grep "Chunk index" | awk '{print $4}')" >> $TMP_FILE
|
||||||
|
|
Loading…
Reference in a new issue