9fb2a3adbaa794ad094e35b5dcbdcff7c715ea05
Synology Monitor Service
This is a lightweight Python monitoring service designed to keep track of the availability of critical servers. It periodically pings defined endpoints to ensure they are online and responsive.
Features
- Heartbeat & Outage Alerts: Sends a regular heartbeat status check to a Rocket.Chat webhook.
- Email Notifications: Triggers beautifully formatted HTML emails exclusively when a server goes down, and sends a follow-up recovery email when the server comes back online.
- State Persistence: Keeps track of the downtime duration so recovery alerts can report exactly how long the outage lasted.
- Easy Testing: Built-in
--test-emailflag to trigger an instant test of the email formatting without waiting for the scheduled check.
Local Development & Testing
- Create a Python virtual environment:
python -m venv venv - Activate the virtual environment:
- Windows (PowerShell):
.\venv\Scripts\Activate.ps1 - Linux/Mac:
source venv/bin/activate
- Windows (PowerShell):
- Install dependencies:
pip install -r requirements.txt - Copy
.env.exampleto.envand fill in your credentials. - Run the script:
(To test the email layout instantly:
python monitor.pypython monitor.py --test-email)
Production Deployment (Linux / VPS)
This repository includes a deployment script (deploy.sh) and a systemd service file (synology-monitor.service) to easily deploy this as a continuous background service on a Linux server.
Step 1: Clone the repository to the server
git clone https://git.seekright.com/kaushik/Enigma-Synology-Monitor.git
cd Enigma-Synology-Monitor
Step 2: Run the deployment script
The provided deploy.sh script automates the installation. It will:
- Create a dedicated, secure system user named
monitor. - Copy the files to
/opt/synology-monitor. - Set up a fresh Python virtual environment and install dependencies.
- Install and enable the
systemdservice.
Run it with sudo:
sudo bash deploy.sh
Step 3: Configure your credentials
The deployment script creates a skeleton .env file from the example. You must edit this file and add your actual SMTP passwords and RocketChat webhooks before starting the service:
sudo nano /opt/synology-monitor/.env
Step 4: Start the service
Once your .env file is saved, start the background monitor:
sudo systemctl start synology-monitor
Useful Commands
- Check the status:
sudo systemctl status synology-monitor - View live logs:
sudo journalctl -u synology-monitor -f - Stop the monitor:
sudo systemctl stop synology-monitor
Description
Languages
Python
89.4%
Shell
10.6%