Why can't you just work?
A quick fix written by me to monitor my unstable server. It requires an additional, but stable, server to function. The system consists of two parts:
- Exposer - the component for the unstable server, responsible for providing data to the monitor.
- Monitor - the component for the stable server, responsible for checking the status of the unstable server and sending notifications to Telegram.
Note
Before using the solution, you need to create a bot using @BotFather and also obtain your chat_id from @userinfobot.
After creating the bot, you must start it by sending the /start command in a chat with it.
Additionally, Docker with Compose is required on both systems.
- Clone the repository to a convenient location on both machines.
git clone https://github.com/Bronuh/ServerMonitor.git- Navigate to the repository directory
cd ServerMonitor/- It is recommended to prepare the .env file in advance
cp .env.template .envBefore running, it is advisable to configure the port for Exposer in the .env file. To start Exposer, simply run the following command inside the repository directory:
./app exposer startAfter building and starting, it will be accessible at http://localhost:5015/online
Currently, it does not return anything except an empty response with a status of 200 OK.
Before starting, it is REQUIRED to configure the service in the .env file
- SERVER_URL - should point to any HTTP endpoint on the unstable server that returns 200 OK.
- This is exactly what Exposer does.
- PING_TARGET - should point to the unstable server or the main network gateway of the network in which it is located.
- CHECK_INTERVAL - the check interval, in seconds.
- TELEGRAM_TOKEN - your Telegram bot token.
- TELEGRAM_CHAT_ID - the chat_id of the user who will receive notifications about the server and network status.
To start Monitor, simply run the following command inside the repository directory:
./app monitor startThe ./app file makes it easier to manage services within the repository. A basic call to ./app without arguments will display a list of available services and actions for them.
Command syntax: ./app <service> <action> [args]
Currently available services:
- exposer
- monitor
- all - for debugging, starts both services
Actions:
- start - starts the service
- stop - stops the service
- restart - restarts the service. The --hard flag will also remove the existing service image.
- update - stops the service, removes the existing image, runs
git pull, and starts the service