forked from hornet/lainmonitor
README.md aktualisiert
Signed-off-by: hax <hax@lainlounge.org>
This commit is contained in:
parent
ce133c03ee
commit
e7275ac1de
1 changed files with 86 additions and 60 deletions
108
README.md
108
README.md
|
|
@ -1,53 +1,76 @@
|
||||||
# LainMonitor
|
# LainMonitor
|
||||||
|
|
||||||
LainMonitor is a Telegram bot designed to monitor your system by providing real-time information about the system's status, services, and disk usage. It can also check connectivity to a specific Tailscale IP address.
|
LainMonitor is a Telegram bot designed to provide real‑time monitoring of both the local system and remote network clients (OPNsense firewalls and generic SSH hosts). It aggregates key metrics via SSH and REST APIs, and delivers concise reports through Telegram commands.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- Retrieve system hostname, uptime, and status of essential services such as:
|
|
||||||
- Zerotier
|
|
||||||
- Prosody
|
|
||||||
- PostgreSQL
|
|
||||||
- Tailscale
|
|
||||||
- Check disk usage
|
|
||||||
- Ping a Tailscale IP to verify connectivity
|
|
||||||
- Use via Telegram commands like `/status`, `/ping`, and `/help`
|
|
||||||
|
|
||||||
## Dependencies
|
* **Local System Monitoring**
|
||||||
- [Telebot](https://github.com/eternnoir/pyTelegramBotAPI) - A Python library for Telegram bot API.
|
|
||||||
|
* Hostname and overall online/offline status
|
||||||
|
* Uptime (human‑readable)
|
||||||
|
* Load averages (1, 5, 15 minute)
|
||||||
|
* Memory usage (via `free -h`)
|
||||||
|
* Disk usage (via `df -h`)
|
||||||
|
|
||||||
|
* **Remote Client Monitoring**
|
||||||
|
|
||||||
|
* **OPNsense Firewalls** (multiple hosts with per‑host trust‑on‑first‑use SSL)
|
||||||
|
|
||||||
|
* System health status
|
||||||
|
* Uptime
|
||||||
|
* Memory and disk statistics
|
||||||
|
* Load averages
|
||||||
|
* **Generic SSH Hosts**
|
||||||
|
|
||||||
|
* Hostname, uptime, load, memory, and disk via SSH
|
||||||
|
|
||||||
|
* **Security & Resilience**
|
||||||
|
|
||||||
|
* Trust‑on‑first‑use SSL: automatically fetches and caches firewall certificates
|
||||||
|
* Concurrency: parallel polling of remote hosts with `ThreadPoolExecutor`
|
||||||
|
* Error handling: per‑task exceptions are logged and do not interrupt overall data gathering
|
||||||
|
* Access control: only whitelisted Telegram chat IDs can invoke commands
|
||||||
|
* Automatic bot restart on failure with backoff retry loop
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
* `/status` or `/ping` — Returns a combined report of local and remote metrics
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
1. Clone this repository:
|
|
||||||
|
1. **Clone repository**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://git.lainlounge.xyz/hornet/lainmonitor.git
|
git clone https://git.lainlounge.xyz/hornet/lainmonitor.git
|
||||||
cd lainmonitor
|
cd lainmonitor
|
||||||
```
|
```
|
||||||
2. Install the required Python library:
|
2. **Install dependencies**
|
||||||
```bash
|
|
||||||
pip install pyTelegramBotAPI
|
|
||||||
```
|
|
||||||
3. Replace the placeholder in the code with your Telegram bot token:
|
|
||||||
```python
|
|
||||||
TOKEN = 'PLACE_YOUR_TOKEN_HERE'
|
|
||||||
```
|
|
||||||
|
|
||||||
4. Set up permissions for the bot to check system services (run as a user with `sudo` access).
|
```bash
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
3. **Configure**
|
||||||
|
|
||||||
|
* Copy `config.py.example` to `config.py`
|
||||||
|
* Populate `config.TOKEN` with your Telegram bot token
|
||||||
|
* Add your Telegram chat IDs to `config.ALLOWED_CHATS`
|
||||||
|
* Define each host under `config.HOSTS` with correct credentials and API settings
|
||||||
|
4. **Prepare SSL directory** (created automatically at runtime):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir certs
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Running Directly
|
* **Run directly**
|
||||||
You can run the bot directly using Python:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
python3 lainmonitor.py
|
|
||||||
```
|
|
||||||
|
|
||||||
### Running as a Service
|
|
||||||
To run LainMonitor as a service, follow these steps:
|
|
||||||
1. Create a systemd service file:
|
|
||||||
```bash
|
```bash
|
||||||
sudo nano /etc/systemd/system/lainmonitor.service
|
python3 lainmonitor.py
|
||||||
```
|
```
|
||||||
2. Add the following configuration:
|
|
||||||
|
* **Run as a service** (systemd)
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=LainMonitor Telegram Bot
|
Description=LainMonitor Telegram Bot
|
||||||
|
|
@ -60,20 +83,23 @@ To run LainMonitor as a service, follow these steps:
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
```
|
```
|
||||||
3. Enable and start the service:
|
|
||||||
```bash
|
```bash
|
||||||
sudo systemctl enable lainmonitor
|
sudo systemctl enable lainmonitor
|
||||||
sudo systemctl start lainmonitor
|
sudo systemctl start lainmonitor
|
||||||
```
|
```
|
||||||
|
|
||||||
## Telegram Bot Commands
|
## Dependencies
|
||||||
- `/start`: Initialize the bot and receive a welcome message.
|
|
||||||
- `/help`: Display available commands.
|
* `pyTelegramBotAPI` (Telebot) — Telegram Bot API client
|
||||||
- `/status`: Get the system hostname, status, uptime, and the status of monitored services.
|
* `paramiko` — SSH connectivity
|
||||||
- `/ping`: Ping a Tailscale IP and return the connectivity status.
|
* `requests` — HTTP/REST API client
|
||||||
- `/reboot`: (Work in progress) Placeholder for a reboot command.
|
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
Created by **hornetmaidan**
|
|
||||||
|
|
||||||
Feel free to contribute or suggest features!
|
**h@x**
|
||||||
|
|
||||||
|
## Original Script written by:
|
||||||
|
**hornetmaidan**
|
||||||
|
|
||||||
|
Contributions and feedback are welcome! :-)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue