pushin env and readme.md files
This commit is contained in:
36
.env
Normal file
36
.env
Normal file
@@ -0,0 +1,36 @@
|
||||
# ─────────────────────────────────────────────────────
|
||||
# Synology Monitor – Configuration
|
||||
# ─────────────────────────────────────────────────────
|
||||
|
||||
# ── Servers to monitor ────────────────────────────────
|
||||
# Synology NAS / DSM web interface
|
||||
SYNOLOGY_URL=https://enigma.seekright.ai
|
||||
|
||||
# Image server — root is pinged to check if the server is up.
|
||||
# No specific paths or filenames needed — works even as images change daily.
|
||||
IMAGE_SERVER_URL=https://images.seekright.ai
|
||||
|
||||
# ── RocketChat Webhook ────────────────────────────────
|
||||
# Always receives a report every 3 hrs (green or red)
|
||||
ROCKETCHAT_WEBHOOK_URL=https://text.seekright.com/hooks/6a227039a88367bc6e1091c6/rYHXfNPDz4auqHampGTYrdNCkg2rPXeu97r8E4bzNh5uwa9C
|
||||
ROCKETCHAT_BOT_NAME=Enigma-Status-Bot
|
||||
ROCKETCHAT_BOT_EMOJI=:robot:
|
||||
|
||||
# ── Email Alerts ──────────────────────────────────────
|
||||
# Email is sent ONLY when something is DOWN (to avoid inbox noise)
|
||||
SMTP_HOST=smtp.gmail.com
|
||||
SMTP_PORT=587
|
||||
SMTP_USERNAME=no-reply@seekright.com
|
||||
SMTP_PASSWORD=clzf ywew riqx lvqv
|
||||
EMAIL_FROM=no-reply@seekright.com
|
||||
EMAIL_TO=shahid.m@seekright.com
|
||||
EMAIL_CC=knmkaushik@gmail.com
|
||||
|
||||
# ── Schedule & Timeouts ───────────────────────────────
|
||||
CHECK_INTERVAL_HOURS=3
|
||||
REQUEST_TIMEOUT_SECONDS=15
|
||||
|
||||
# ── Logging ───────────────────────────────────────────
|
||||
# Log rotates at 5 MB, keeps 3 backups — max ~20 MB disk
|
||||
LOG_LEVEL=INFO
|
||||
LOG_FILE=monitor.log
|
||||
70
README.md
Normal file
70
README.md
Normal file
@@ -0,0 +1,70 @@
|
||||
# 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-email` flag to trigger an instant test of the email formatting without waiting for the scheduled check.
|
||||
|
||||
## Local Development & Testing
|
||||
|
||||
1. Create a Python virtual environment:
|
||||
```bash
|
||||
python -m venv venv
|
||||
```
|
||||
2. Activate the virtual environment:
|
||||
* **Windows (PowerShell):** `.\venv\Scripts\Activate.ps1`
|
||||
* **Linux/Mac:** `source venv/bin/activate`
|
||||
3. Install dependencies:
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
4. Copy `.env.example` to `.env` and fill in your credentials.
|
||||
5. Run the script:
|
||||
```bash
|
||||
python monitor.py
|
||||
```
|
||||
*(To test the email layout instantly: `python 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
|
||||
```bash
|
||||
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 `systemd` service.
|
||||
|
||||
Run it with sudo:
|
||||
```bash
|
||||
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:
|
||||
```bash
|
||||
sudo nano /opt/synology-monitor/.env
|
||||
```
|
||||
|
||||
### Step 4: Start the service
|
||||
Once your `.env` file is saved, start the background monitor:
|
||||
```bash
|
||||
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`
|
||||
5
monitor_state.json
Normal file
5
monitor_state.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"last_was_failure": true,
|
||||
"failed_since": "2026-06-08T05:15:17.885416+00:00",
|
||||
"last_check": "2026-06-08T05:23:29.810168+00:00"
|
||||
}
|
||||
Reference in New Issue
Block a user