---
check_interval: 30s
default_alert_down: [log, mailgun]
default_alert_up: [log, mailgun_up]
default_alert_after: 20     # 20 * 30s = 10 min
default_alert_every: 1440   # 12hrs / 30s = 1440 checks

monitors:
  - name: Cloudron
    command:
      - '/app/scripts/curl_ok.sh'
      - 'https://my.iamthefij.com'

  - name: Grafana (public)
    command:
      - '/app/scripts/curl_ok.sh'
      - 'https://grafana.iamthefij.com'

  - name: Grafana (internal)
    command:
      - '/app/scripts/curl_ok.sh'
      - 'https://grafana.thefij.rocks'

  - name: Plex
    command:
      - 'curl'
      - '--silent'
      - '--show-error'
      - '-o'
      - '/dev/null'
      - 'http://192.168.2.10:32400'

  - name: NZBget
    command:
      - '/app/scripts/curl_ok.sh'
      - 'https://nzbget.thefij.rocks'

  - name: Sonarr
    command:
      - '/app/scripts/curl_ok.sh'
      - 'https://sonarr.thefij.rocks'

  - name: Lidarr
    command:
      - '/app/scripts/curl_ok.sh'
      - 'https://lidarr.thefij.rocks'

  - name: Authelia
    command:
      - '/app/scripts/curl_ok.sh'
      - 'https://authelia.thefij.rocks'

  - name: Photoprism
    command:
      - '/app/scripts/curl_ok.sh'
      - 'https://photoprism.thefij.rocks'

alerts:
  log:
    command:
      - echo
      - "{{.MonitorName}} {{if .IsUp}}has recovered{{else}}check has failed {{.FailureCount}} times{{end}}"
  mailgun:
    command: >
      curl -sS -X POST
      -F subject="ALERT! {{.MonitorName}} is Down"
      -F from="Minitor <minitor@iamthefij.com>"
      -F to=ian@iamthefij.com
      -F text=$'{{.MonitorName}} has failed {{.FailureCount}} checks. Alert count: {{.AlertCount}}. Last success was {{RFC1123Z .LastSuccess}}.\n\n-Nomad Minitor'
      https://api.mailgun.net/v3/mg.iamthefij.com/messages
      -u "api:$MAILGUN_API_KEY"

  mailgun_up:
    command: >
      curl -sS -X POST
      -F subject="RECOVERED! {{.MonitorName}} is back Up"
      -F from="Minitor <minitor@iamthefij.com>"
      -F to=ian@iamthefij.com
      -F text=$'{{.MonitorName}} has recovered.\n\n-Nomad Minitor'
      https://api.mailgun.net/v3/mg.iamthefij.com/messages
      -u "api:$MAILGUN_API_KEY"