telegram bot hosted on lainlounge servers for remote system monitoring
Find a file
2024-12-27 21:51:18 +05:00
.authorized_users finished /reboot host and /restart host functions, added authorization for actions by telegram ID, added nginx to default services 2024-10-18 18:06:53 +05:00
.env horfix #4 (fucking insanity) 2024-10-05 01:38:52 +05:00
.gitignore add .gitignore 2024-10-05 00:35:18 +05:00
lainmonitor.py updoot readme and version labels in the main file 2024-12-27 21:46:34 +05:00
LICENSE Initial commit 2024-10-04 18:55:32 +00:00
README.md updoot readme v1.2 2024-12-27 21:51:18 +05:00
requirements.txt uploaded sou 2024-10-04 18:58:46 +00:00

lainmonitor

LainMonitor is a Telegram bot designed to monitor your system, providing real-time updates on the systems 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!