From 83bcea98dcec33b18cceb1c3077df9cd1f4f7725 Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Fri, 21 Jun 2024 16:57:20 +0100 Subject: [PATCH] WIP added some schema info for uptime kuma --- borgmatic/config/schema.yaml | 37 +++++++++++++++++++++++++++++++++++ borgmatic/hooks/uptimekuma.py | 7 ++++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/borgmatic/config/schema.yaml b/borgmatic/config/schema.yaml index d8a3548..0acffbf 100644 --- a/borgmatic/config/schema.yaml +++ b/borgmatic/config/schema.yaml @@ -1676,6 +1676,43 @@ properties: an account at https://healthchecks.io (or self-host Healthchecks) if you'd like to use this service. See borgmatic monitoring documentation for details. + uptimekuma: + type: object + required: ['ping_url', 'push_code'] + additionalProperties: false + properties: + ping_url: + type: string + description: | + Uptime Kuma base URL or UUID to notify when a backup + begins, ends, or errors + example: https://example.uptime.kuma + push_code: + type: string + description: | + Uptime Kuma "Push Code" from the push URL you have been given. + For example, the push code for: + 'https://uptime.kuma/api/push/0evpM0MIdE?status=up&msg=OK&ping=' + would be '0evpM0MIdE' + states: + type: array + items: + type: string + enum: + - start + - finish + - fail + uniqueItems: true + description: | + List of one or more monitoring states to ping for: "start", + "finish", and/or "fail". Defaults to pinging for all + states. + example: + - start, finish, fail + description: | + Configuration for a monitoring integration with Uptime Kuma using + the 'Push' monitor type. + See more information here: https://uptime.kuma.pet cronitor: type: object required: ['ping_url'] diff --git a/borgmatic/hooks/uptimekuma.py b/borgmatic/hooks/uptimekuma.py index 5990f60..02317ef 100644 --- a/borgmatic/hooks/uptimekuma.py +++ b/borgmatic/hooks/uptimekuma.py @@ -20,13 +20,14 @@ def ping_monitor(hook_config, config, config_filename, state, monitoring_log_lev If this is a dry run, then don't actually ping anything. ''' - run_states = hook_config.get('states', ['success','fail']) + run_states = hook_config.get('states', ['start','finish','fail']) if state.name.lower() in run_states: + dry_run_label = ' (dry run; not actually pinging)' if dry_run else '' status = state.name.lower() == "fail" ? "down" : "up" - + base_url = hook_config.get('server', 'https://example.uptime.kuma') & "/api/push" push_code = hook_config.get('push_code') @@ -41,7 +42,7 @@ def ping_monitor(hook_config, config, config_filename, state, monitoring_log_lev if not response.ok: response.raise_for_status() except requests.exceptions.RequestException as error: - logger.warning(f'{config_filename}: ntfy error: {error}') + logger.warning(f'{config_filename}: Uptime Kuma error: {error}') def destroy_monitor(