This is a Telegram bot that monitors the public IP address of your Raspberry Pi and notifies you of any changes. It also provides system metrics such as CPU, RAM, and internet usage.
- Monitor public IP address changes and notify via Telegram
- Log IP checks and changes to a file
- Provide system metrics (CPU, RAM, internet usage)
- View the log of IP changes
- Docker
- Docker Compose
- A Telegram bot token (you can create one by talking to BotFather on Telegram)
Create a .env
file in the root directory of the project by copying the .example.env
file:
cp .example.env .env
Then, edit the .env
file to include your specific configuration:
TELEGRAM_TOKEN=<your_telegram_token>
POLLING_INTERVAL=60
CHAT_ID=<your_chat_id>
LOG_RETENTION_DAYS=7
TELEGRAM_TOKEN
: Your Telegram bot tokenPOLLING_INTERVAL
: Interval in seconds to check for IP changesCHAT_ID
: Your Telegram chat IDLOG_RETENTION_DAYS
: Number of days to retain log files
-
Clone the repository:
git clone <repository-url> cd telegram-monitor
-
Create the
.env
file from the.example.env
file:cp .example.env .env
-
Edit the
.env
file to include your specific configuration. -
Build the Docker image:
docker compose build
-
Run the Docker container:
docker compose up -d
/start
: Initialize the bot and get a welcome message with available commands./ip
: Get the current public IP address and details./log [n]
: View the lastn
log entries of IP changes for the current day (default: 10)./metrics
: Get system metrics such as CPU, RAM, and internet usage.
.
├── Dockerfile
├── docker-compose.yml
├── .env
├── .example.env
├── .gitignore
├── current_ip.json
├── README.md
├── requirements.txt
├── src
│ ├── bot.py
│ ├── main.py
│ └── utils.py
└── log
- Start the bot by sending the
/start
command. - Get the current public IP address by sending the
/ip
command. - View the log of IP changes by sending the
/log
command. - Get system metrics by sending the
/metrics
command.
This project is licensed under the MIT License.