diff --git a/.authorized_users b/.authorized_users new file mode 100644 index 0000000..dbefc0c --- /dev/null +++ b/.authorized_users @@ -0,0 +1,2 @@ +AUTHORIZED_USER_ID_1 +AUTHORIZED_USER_ID_2 \ No newline at end of file diff --git a/.env b/.env new file mode 100644 index 0000000..e791c3a --- /dev/null +++ b/.env @@ -0,0 +1 @@ +YOUR_TOKEN_HERE \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7d7a845 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +test.py +venv/ \ No newline at end of file diff --git a/README.md b/README.md index c00ed87..77fbd1d 100644 --- a/README.md +++ b/README.md @@ -1,54 +1,59 @@ -# 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 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. +### Key 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` + Retrieve system information: + Hostname + Uptime + Status of critical services: + Zerotier + Prosody + PostgreSQL + Tailscale + Check disk usage + Ping a Tailscale IP for connectivity verification + Accessible via Telegram commands such as /status, /ping, and /help -## Dependencies -- [Telebot](https://github.com/eternnoir/pyTelegramBotAPI) - A Python library for Telegram bot API. +### Prerequisites: + + Python 3 + Telebot — Python library for interacting with the Telegram bot API. + +### Installation Guide: + +Clone the repository: -## Installation -1. Clone this repository: - ```bash git clone https://git.lainlounge.xyz/hornet/lainmonitor.git cd lainmonitor - ``` -2. Install the required Python library: - ```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). +Install dependencies: -## Usage + pip3 install pyTelegramBotAPI -### Running Directly -You can run the bot directly using Python: +Configure your bot token: Open the lainmonitor.py file and replace the placeholder with your Telegram bot token: -```bash -python3 lainmonitor.py -``` + TOKEN = 'YOUR_BOT_TOKEN' + +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: -### Running as a Service -To run LainMonitor as a service, follow these steps: -1. Create a systemd service file: - ```bash sudo nano /etc/systemd/system/lainmonitor.service - ``` -2. Add the following configuration: - ```ini + +Add the following configuration: + [Unit] Description=LainMonitor Telegram Bot After=network.target @@ -59,21 +64,23 @@ To run LainMonitor as a service, follow these steps: [Install] WantedBy=multi-user.target - ``` -3. Enable and start the service: - ```bash + +Enable and start the service: + sudo systemctl enable lainmonitor sudo systemctl start lainmonitor - ``` -## Telegram Bot Commands -- `/start`: Initialize the bot and receive a welcome message. -- `/help`: Display available commands. -- `/status`: Get the system hostname, status, uptime, and the status of monitored services. -- `/ping`: Ping a Tailscale IP and return the connectivity status. -- `/reboot`: (Work in progress) Placeholder for a reboot command. +### Available Commands: -## Author -Created by **hornetmaidan** + /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. + /reboot — (Work in progress) Placeholder for a system reboot command. -Feel free to contribute or suggest features! \ No newline at end of file +### Contributions: + +Created by hornetmaidan. +With Contributions from h@x. + +Any new features and suggestions are welcome! \ No newline at end of file diff --git a/lainmonitor.py b/lainmonitor.py index 790af29..906de4a 100644 --- a/lainmonitor.py +++ b/lainmonitor.py @@ -158,6 +158,7 @@ def handle(message): bot.reply_to(message, 'lainmonitor v1.0 --- standing by...') elif message.text == '/help': bot.reply_to(message, 'commands: /start, /help, /status, /restart, /reboot, /ping') + bot.reply_to(message, 'commands: /start, /help, /status, /restart, /reboot, /ping') elif message.text == '/status': get_system_info() status_message = (