12345678910111213141516171819 |
- #!/bin/bash
- # Exit if no Pushgateway URL is defined
- [ -z "$PROM_URL" ] && exit
- case $1 in
- start) state='1'; status='started' ;;
- stop|0) state='0'; status='stopped' ;;
- info|1) state='0'; status='stopped with info' ;;
- fail|2|*) state='-1'; status='failed' ;;
- esac
- cat <<EOF | curl --data-binary @- $PROM_URL
- # TYPE borg_hook_state gauge
- # HELP borg_hook_state 1=started 0=stopped -1=failed
- borg_hook_state $state
- # TYPE borg_hook_state_timestamp gauge
- borg_hook_state_timestamp{label="$status"} `date +%s`
- EOF
|