From 403a5c41cf9ed78f17a74c377ce6ee2c1f8d5d66 Mon Sep 17 00:00:00 2001 From: askiiart Date: Mon, 5 Feb 2024 10:15:44 -0600 Subject: [PATCH] Fix running updog from any location, fix and update docs --- .vscode/launch.json | 0 docs/README.md | 64 ++++++++++++++++++++++++++++++++++++++ docs/extensions/logging.md | 2 +- updog.py | 8 ++--- 4 files changed, 69 insertions(+), 5 deletions(-) mode change 100644 => 100755 .vscode/launch.json create mode 100644 docs/README.md diff --git a/.vscode/launch.json b/.vscode/launch.json old mode 100644 new mode 100755 diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..48b1bfb --- /dev/null +++ b/docs/README.md @@ -0,0 +1,64 @@ +# Docs + +Welcome to the docs. Not docks, [no docker yet](#docker). + +## Usage + +### Extensions + +First, find some extensions. You'll need a checker to check whether something is up, a logging extension to log stuff, and optionally an extension to send alerts. Extensions are specified on a per-service basis, so you can mix-and-match extensions as much as you want. Once there are some real extensions I'll list some here. + +### Config + +Then create a `services.json` file for your config, like this: + +```json +{ + "site": { + "name": "A Website", + "checker": "CheckerTemplate", + "checker-args": { + "url": "https://example.net", + "port": 443, + "lol": "CheckerTemplate ignores these options lol" + }, + "rate": 1, + "alerts": "AlertsTemplate", + "alerts-args": { + "url": "https://example.com/webhook-url-or-whatever-goes-here", + "lol": "irrelevant, AlertsTemplate ignores these options lol" + }, + "logging": "LoggingTemplate", + "logging-args": { + "file": "/home/askiiart/Documents/updog/logs/site-log" + } + } +} +``` + +Required arguments: + +- The key (in this case `site`): A unique string to identify the service in logs, also used internally. +- `checker`: The name of the checker extension's *class*. +- `checker-args`: Arguments for the checker. Check the checker's docs for what to put here. +- `rate`: How often to check if the service is up (every *x* seconds) +- `alerts`: The name of the alerting extension's *class*. +- `alerts-args`: Arguments for the alerting extension. Check the alerter's docs for what to put here. +- `logging`: The name of the logging extension's *class*. +- `logging-args`: Arguments for the logging extension. Check the logger's docs for what to put here. + +Optional arguments: + +- `name`: A human-friendly name for the service; currently unused. + +--- + +This example uses the template extensions, [askiiart/updog-checker_template](https://git.askiiart.net/askiiart/updog-checker_template), [askiiart/updog-logging_template](https://git.askiiart.net/askiiart/updog-logging_template), and [askiiart/updog-alerts_template](https://git.askiiart.net/askiiart/updog-alerts_template), so the arguments for them are mostly irrelevant. For each extension, check its docs for what arguments to use. + +### Running it + +Just run it with `python3 updog.py` + +### Docker + +No Docker yet, Updog throws `RuntimeError: can't create new thread at interpreter shutdown` when I try to run it in Docker. So no Docker until I figure that out. diff --git a/docs/extensions/logging.md b/docs/extensions/logging.md index 1c72a4f..7615d1e 100644 --- a/docs/extensions/logging.md +++ b/docs/extensions/logging.md @@ -1,4 +1,4 @@ -# Alerts Extensions +# Logging Extensions Updog doesn't do any monitoring by itself. Instead, extensions are used to check the status of whatever thing, send alerts, and log stuff. Updog just chains them together. diff --git a/updog.py b/updog.py index 2484411..7e5d45f 100644 --- a/updog.py +++ b/updog.py @@ -65,10 +65,10 @@ for ext in [importlib.import_module(ext) for ext in logging_extension_imports]: logging[name] = obj # get config from services.json -if 'services.json' in os.listdir(): - config_filename = 'services.json' -elif 'services-example.json' in os.listdir(): - config_filename = 'services-example.json' +if 'services.json' in os.listdir(path): + config_filename = f'{path}/services.json' +elif 'services-example.json' in os.listdir(path): + config_filename = f'{path}/services-example.json' with open(config_filename, 'rt') as config_file: config = json.loads(''.join(config_file.readlines()))