Fix running updog from any location, fix and update docs

This commit is contained in:
askiiart 2024-02-05 10:15:44 -06:00
parent 9bffe2f73a
commit 403a5c41cf
Signed by untrusted user who does not match committer: askiiart
GPG key ID: BC3800E55FB54D67
4 changed files with 69 additions and 5 deletions

0
.vscode/launch.json vendored Normal file → Executable file
View file

64
docs/README.md Normal file
View file

@ -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.

View file

@ -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. 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.

View file

@ -65,10 +65,10 @@ for ext in [importlib.import_module(ext) for ext in logging_extension_imports]:
logging[name] = obj logging[name] = obj
# get config from services.json # get config from services.json
if 'services.json' in os.listdir(): if 'services.json' in os.listdir(path):
config_filename = 'services.json' config_filename = f'{path}/services.json'
elif 'services-example.json' in os.listdir(): elif 'services-example.json' in os.listdir(path):
config_filename = 'services-example.json' config_filename = f'{path}/services-example.json'
with open(config_filename, 'rt') as config_file: with open(config_filename, 'rt') as config_file:
config = json.loads(''.join(config_file.readlines())) config = json.loads(''.join(config_file.readlines()))