notify-prom-status.sh 527 B

12345678910111213141516
  1. #!/bin/sh -xe
  2. case $1 in
  3. start) state='1'; status='started' ;;
  4. stop) state='0'; status='stopped' ;;
  5. incomplete) state='-3'; status='incomplete' ;;
  6. fail|*) state='-1'; status='failed' ;;
  7. esac
  8. [ ! -z $PROM_GW_URL ] && cat <<EOF | curl --data-binary @- $PROM_GW_URL
  9. # TYPE restic_hook_state gauge
  10. # HELP restic_hook_state 1=started 0=stopped -1=failed -3=incomplete
  11. restic_hook_state $state
  12. # TYPE restic_hook_state_timestamp gauge
  13. restic_hook_state_timestamp{label="$status"} `date +%s`
  14. EOF