forked from hornet/lainmonitor
99 lines
No EOL
2.6 KiB
Markdown
99 lines
No EOL
2.6 KiB
Markdown
# lainmonitor
|
||
|
||
LainMonitor is a Telegram bot designed to monitor your system, providing real-time updates on the system’s status, essential services, and disk usage. It can also verify connectivity to a specific Tailscale IP address.
|
||
Current version: v1.2
|
||
|
||
### Key Features:
|
||
|
||
Retrieve system information:
|
||
Hostname
|
||
Uptime
|
||
Status of critical services:
|
||
Zerotier
|
||
Prosody
|
||
PostgreSQL
|
||
Tailscale
|
||
nginx
|
||
Check disk usage
|
||
Ping a Tailscale IP for connectivity verification
|
||
Restart critical services
|
||
Reboot the host
|
||
Accessible via Telegram commands
|
||
|
||
### Prerequisites:
|
||
|
||
Python 3
|
||
Telebot — Python library for interacting with the Telegram bot API.
|
||
|
||
### Installation Guide:
|
||
|
||
Clone the repository:
|
||
|
||
git clone https://git.lainlounge.xyz/hornet/lainmonitor.git
|
||
cd lainmonitor
|
||
|
||
RECOMMENDED: Create a virtual environment for python with:
|
||
```
|
||
python3 -m venv venv
|
||
source venv/bin/activate
|
||
```
|
||
Install dependencies:
|
||
|
||
```
|
||
pip3 install -r requirements.txt
|
||
```
|
||
|
||
Configure your bot token: Open the .env file and replace the placeholder with your Telegram bot token.
|
||
|
||
Configure authorized users: Open the .authorized_users file and replace the placeholders with Telegram user ID(s).
|
||
|
||
Set up service access: Ensure the bot can check system services by running it with sudo or appropriate permissions.
|
||
|
||
### Usage:
|
||
#### Running the Bot Manually:
|
||
|
||
You can run LainMonitor directly from the command line:
|
||
|
||
python3 lainmonitor.py
|
||
|
||
#### Running as a Systemd Service:
|
||
|
||
To run the bot as a systemd service, follow these steps:
|
||
|
||
Create a service file:
|
||
|
||
sudo nano /etc/systemd/system/lainmonitor.service
|
||
|
||
Add the following configuration:
|
||
|
||
[Unit]
|
||
Description=LainMonitor Telegram Bot
|
||
After=network.target
|
||
|
||
[Service]
|
||
ExecStart=/usr/bin/python3 /path/to/lainmonitor.py
|
||
Restart=on-failure
|
||
|
||
[Install]
|
||
WantedBy=multi-user.target
|
||
|
||
Enable and start the service:
|
||
|
||
sudo systemctl enable lainmonitor
|
||
sudo systemctl start lainmonitor
|
||
|
||
### Available Commands:
|
||
|
||
/start — Initialize the bot and receive a welcome message.
|
||
/help — Display a list of available commands.
|
||
/status — Retrieve system hostname, uptime, and status of monitored services.
|
||
/ping — Ping a Tailscale IP and return connectivity status.
|
||
/restart hostname- Restart a specific service on a specified machine.
|
||
/reboot hostname — Placeholder for a system reboot command.
|
||
|
||
### Contributions:
|
||
|
||
Created by hornetmaidan.
|
||
With Contributions from h@x.
|
||
|
||
Any new features and suggestions are welcome! |