Browse Source

WIP added some schema info for uptime kuma

Paul Wilde 11 months ago
parent
commit
83bcea98dc
2 changed files with 41 additions and 3 deletions
  1. 37 0
      borgmatic/config/schema.yaml
  2. 4 3
      borgmatic/hooks/uptimekuma.py

+ 37 - 0
borgmatic/config/schema.yaml

@@ -1676,6 +1676,43 @@ properties:
             an account at https://healthchecks.io (or self-host Healthchecks) if
             an account at https://healthchecks.io (or self-host Healthchecks) if
             you'd like to use this service. See borgmatic monitoring
             you'd like to use this service. See borgmatic monitoring
             documentation for details.
             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:
     cronitor:
         type: object
         type: object
         required: ['ping_url']
         required: ['ping_url']

+ 4 - 3
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.
     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:
     if state.name.lower() in run_states:
+        
         dry_run_label = ' (dry run; not actually pinging)' if dry_run else ''
         dry_run_label = ' (dry run; not actually pinging)' if dry_run else ''
 
 
         status = state.name.lower() == "fail" ? "down" : "up"
         status = state.name.lower() == "fail" ? "down" : "up"
-
+        
         base_url = hook_config.get('server', 'https://example.uptime.kuma') & "/api/push"
         base_url = hook_config.get('server', 'https://example.uptime.kuma') & "/api/push"
         push_code = hook_config.get('push_code')
         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:
                 if not response.ok:
                     response.raise_for_status()
                     response.raise_for_status()
             except requests.exceptions.RequestException as error:
             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(
 def destroy_monitor(