123456789101112131415161718192021222324252627282930 |
- #!/bin/bash
- # Exit if no Prometheus Pushgateway URL is defined
- [ -z "$PROM_URL" ] && exit
- # Get latest backup status as json
- json=`borg info --last 1 --json`
- # Parse json in the Prometheus exposition formatand and transmit
- cat <<EOF | curl --data-binary @- $PROM_URL
- # TYPE borg_run_duration_seconds gauge
- # HELP borg_run_duration_seconds duration between start and end
- `echo -n 'borg_run_duration_seconds ' && \
- echo $json | grep -o '"duration": [0-9]*' | grep -o '[0-9]*'`
- # TYPE borg_run_size_deduplicated_bytes gauge
- # HELP borg_run_size_deduplicated_bytes deduplicated size of the last run
- `echo -n 'borg_run_size_deduplicated_bytes ' && \
- echo $json | grep -o '"compressed_size": [0-9]*' | grep -o '[0-9]*'`
- # TYPE borg_run_size_original_bytes gauge
- # HELP borg_run_size_original_bytes original size of the last run
- `echo -n 'borg_run_size_original_bytes ' && \
- echo $json | grep -o '"original_size": [0-9]*' | grep -o '[0-9]*'`
- # TYPE borg_cache_chunks_size_total_compressed_bytes gauge
- # HELP borg_cache_chunks_size_total_compressed_bytes total size of all chunks
- `echo -n 'borg_cache_chunks_size_total_compressed_bytes ' && \
- echo $json | grep -o '"unique_csize": [0-9]*' | grep -o '[0-9]*'`
- EOF
|