A Python-based script that allows you to monitor the status of servers and services. It supports various monitoring types such as ping, port check, HTTP(s) check, and keyword check. You can easily configure the script to monitor your desired servers and receive notifications via Telegram.
- Ping: Checks the reachability and latency of a target IP address.
- Port Check: Verifies if a specific port on a target IP address is open.
- HTTP(s) Check: Sends an HTTP(s) request to a target URL and checks the response status code. It validates that the status code is 200 and the SSL certificate is present in case it's a https target.
- Keyword Check: Verifies if a specific keyword is present or absent in the response content of an HTTP(s) request.
Install Docker
curl -sSL https://get.docker.com | shDownload pymon
mkdir -p /opt && cd /opt/ && git clone https://github.com/iandk/pymon.gitEdit configuration
# settings
cp /opt/pymon/.env.sample /opt/pymon/.env
nano /opt/pymon/.env
# monitoring targets
cp /opt/pymon/servers-sample.yaml /opt/pymon/servers.yaml
nano /opt/pymon/servers.yamlBuild container
cd pymon && docker build -t pymon:latest .Run container
docker run -d --name pymon -v /opt/pymon:/opt/pymon --network host pymonYou have two options for running the script: running it in the background, which will automatically monitor for status changes, or running it in the terminal with a graphical output.
To run the script as a background service, follow the steps below:
- Clone the repository to your local machine:
mkdir -p /opt && cd /opt/
git clone https://github.com/iandk/pymon.git
cd pymon && bash install.sh- Edit configuration
# settings
cp /opt/pymon/.env.sample /opt/pymon/.env
nano /opt/pymon/.env
# monitoring targets
cp /opt/pymon/servers-sample.yaml /opt/pymon/servers.yaml
nano /opt/pymon/servers.yaml- Start pymon
systemctl start pymon
systemctl status pymonTo run the script in the terminal with a graphical output, use the following command:
Note: The terminal view should only be used if the system service is stopped. Running both the service and terminal view simultaneously may cause conflicts.
cd /opt/pymon/ && myvenv/bin/python3 main.py| Variable | Required | Default | Description |
|---|---|---|---|
BOT_TOKEN |
Yes | - | Telegram bot token from BotFather |
CHAT_ID |
Yes | - | Telegram chat ID for notifications |
FAILURE_THRESHOLD |
No | 3 | Consecutive failures before marking server as Down |
CHECK_INTERVAL_SECONDS |
No | 60 | Interval between server checks |
STATUS_REPORT_INTERVAL_MINUTES |
No | 60 | Interval between status report messages |
REPORT_ONLY_ON_DOWN |
No | false | Only send reports when servers are down |
To find your chat ID, send a message to your bot and access: https://api.telegram.org/bot<bot_token>/getUpdates
Each server entry requires:
description: A brief description of the server or servicetype: Monitoring type (ping,port,http, orkeyword)target: IP address or URL to monitor
Additional fields by type:
porttype:port- Port number to checkkeywordtype:keyword- Keyword to search for,expect_keyword- true/false
Example configuration:
- description: "1.1.1.1"
type: ping
target: "1.1.1.1"
- description: "v6Node.com"
type: http
target: "https://v6node.com"
- description: "Google"
type: port
target: "google.com"
port: 80
- description: "v6Node Keyword check"
type: keyword
target: "https://v6node.com"
keyword: "v6node"
expect_keyword: true