notify-prom-stats.sh 1.0 KB

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. [ -z "$PROM_URL" ] && exit
  3. json=`borg info --last 1 --json`
  4. cat <<EOF | curl --data-binary @- $PROM_URL
  5. # TYPE borg_run_duration_seconds gauge
  6. # HELP borg_run_duration_seconds duration between start and end
  7. `echo -n 'borg_run_duration_seconds ' && \
  8. echo $json | grep -o '"duration": [0-9]*' | grep -o '[0-9]*'`
  9. # TYPE borg_run_size_deduplicated_bytes gauge
  10. # HELP borg_run_size_deduplicated_bytes deduplicated size of the last run
  11. `echo -n 'borg_run_size_deduplicated_bytes ' && \
  12. echo $json | grep -o '"compressed_size": [0-9]*' | grep -o '[0-9]*'`
  13. # TYPE borg_run_size_original_bytes gauge
  14. # HELP borg_run_size_original_bytes original size of the last run
  15. `echo -n 'borg_run_size_original_bytes ' && \
  16. echo $json | grep -o '"original_size": [0-9]*' | grep -o '[0-9]*'`
  17. # TYPE borg_cache_chunks_size_total_compressed_bytes gauge
  18. # HELP borg_cache_chunks_size_total_compressed_bytes total size of all chunks
  19. `echo -n 'borg_cache_chunks_size_total_compressed_bytes ' && \
  20. echo $json | grep -o '"unique_csize": [0-9]*' | grep -o '[0-9]*'`
  21. EOF