write a readme

This commit is contained in:
Alex Tau 2025-06-14 15:18:58 +03:00
parent 8b18d407d7
commit 4558cf9e6f
7 changed files with 116 additions and 4 deletions

View file

@ -0,0 +1,67 @@
# lego-monitoring
Simple system monitoring service. Sends alerts in Telegram. Currently supports monitoring:
* CPU/RAM/network usage
* temperature readings
* [vulnix](https://github.com/nix-community/vulnix) readings (NixOS only)
## Setup
### NixOS
Only flake-based setups are supported.
Include the module in your `flake.nix`:
```nix
{
inputs = {
# ... your other inputs ...
lego-monitoring = {
url = "git+https://gitlab.altau.su/lego/lego-monitoring.git";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
nixpkgs,
lego-monitoring,
...
}: {
# change `yourhostname` to your actual hostname
nixosConfigurations.yourhostname = nixpkgs.lib.nixosSystem {
# change to your system:
system = "x86_64-linux";
modules = [
lego-monitoring.nixosModules.default
./configuration.nix
# ... your other modules ...
];
};
};
}
```
See [docs/nixos-options.md](docs/nixos-options.md) for available configuration options.
### Non-NixOS
Requires [uv](https://github.com/astral-sh/uv), systemd.
```bash
cd /opt
git clone https://gitlab.altau.su/lego/lego-monitoring.git
cd lego-monitoring
uv sync
cp config.example.json config.json
```
Edit `config.json` to suit your usage scenario. The default configuration only sends alerts on service's start and stop.
You may refer to the NixOS option documentation, as its options are the same, except JSON uses snake_case instead of lowerCamelCase.
Then enable and start the service:
```bash
ln -s /opt/lego-monitoring/lego-monitoring.service /etc/systemd/system/lego-monitoring.service
systemctl enable --now lego-monitoring
```

15
config.example.json Normal file
View file

@ -0,0 +1,15 @@
{
"log_level": "INFO",
"enabled_check_sets": [
"start",
"stop",
"remind"
],
"telegram": {
"creds_secret_path": "/opt/lego-monitoring/tg-creds.txt",
"roomId": "0"
},
"checks": {
}
}

View file

@ -28,7 +28,16 @@ boolean
List of enabled check sets\. Each check set is a module which checks something and generates alerts based on check results\.
List of enabled check sets\. Each check set is a module which checks something and generates alerts based on check results\. Available check sets:
- start send an alert when lego-monitoring is started
- stop send an alert when lego-monitoring is stopped
- remind periodically (daily by default) remind about ongoing unresolved alerts
- cpu alerts when CPU usage is above threshold
- ram alerts when RAM usage is above threshold
- temp alerts when temperature readings are above thresholds
- net alerts when network usage is above threshold
- vulnix periodically scans system for known CVEs, alerts if any are found (NixOS only)

12
lego-monitoring.service Normal file
View file

@ -0,0 +1,12 @@
[Unit]
Description=Lego-monitoring service
StartLimitBurst=3
StartLimitIntervalSec=20
[Service]
ExecStart=/opt/lego-monitoring/.venv/bin/lego-monitoring -c /opt/lego-monitoring/config.json
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target

View file

@ -38,7 +38,16 @@ in
"vulnix"
]);
default = [ ];
description = "List of enabled check sets. Each check set is a module which checks something and generates alerts based on check results.";
description = ''
List of enabled check sets. Each check set is a module which checks something and generates alerts based on check results. Available check sets:
* start -- send an alert when lego-monitoring is started
* stop -- send an alert when lego-monitoring is stopped
* remind -- periodically (daily by default) remind about ongoing unresolved alerts
* cpu -- alerts when CPU usage is above threshold
* ram -- alerts when RAM usage is above threshold
* temp -- alerts when temperature readings are above thresholds
* net -- alerts when network usage is above threshold
* vulnix -- periodically scans system for known CVEs, alerts if any are found (NixOS only)'';
};
telegram = {

View file

@ -1,6 +1,6 @@
[project]
name = "lego-monitoring"
version = "0.1.0"
version = "1.0.0"
description = "Monitoring software for the lego server"
readme = "README.md"
requires-python = ">=3.12"

2
uv.lock generated
View file

@ -22,7 +22,7 @@ wheels = [
[[package]]
name = "lego-monitoring"
version = "0.1.0"
version = "1.0.0"
source = { editable = "." }
dependencies = [
{ name = "alt-utils" },