Add UPS email notifications and automatic UPS shutdown
- Add email notifications via PVE::Notify for all UPS events: - ONBATT: when UPS switches to battery - ONLINE: when power is restored - LOWBATT: critical battery level - SHUTDOWN_START/NODE/PRIMARY: during cluster shutdown - COMMBAD: communication lost with UPS - Add automatic UPS shutdown command after cluster shutdown (protects against power surge when power returns) - Update upssched.conf with ONLINE handler and immediate ONBATT notification - Add notification templates for HTML and text emails - Update documentation with new features and timer configuration Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -68,24 +68,33 @@ Restart servicii
|
||||
|
||||
### Scenario 1: Întrerupere scurtă (< 3 minute)
|
||||
1. Curent se întrerupe → UPS trece pe baterie (status: OB)
|
||||
2. upssched pornește timer de 180 secunde
|
||||
3. Curent revine înainte de 3 minute
|
||||
4. Timer anulat → **Niciun sistem nu se oprește**
|
||||
2. **📧 Email: "Trecere pe baterie"** - notificare imediată
|
||||
3. upssched pornește timer de 180 secunde
|
||||
4. Curent revine înainte de 3 minute
|
||||
5. **📧 Email: "Curent revenit - OK"**
|
||||
6. Timer anulat → **Niciun sistem nu se oprește**
|
||||
|
||||
### Scenario 2: Întrerupere lungă (> 3 minute)
|
||||
1. Curent se întrerupe → UPS pe baterie
|
||||
2. Timer 180 secunde expiră
|
||||
3. `/usr/local/bin/ups-shutdown-cluster.sh` pornește:
|
||||
- **Step 1:** Oprește toate VM-urile de pe toate nodurile (paralel)
|
||||
2. **📧 Email: "Trecere pe baterie"**
|
||||
3. Timer 180 secunde expiră
|
||||
4. **📧 Email: "Pe baterie 3 min - SHUTDOWN"**
|
||||
5. `/usr/local/bin/ups-shutdown-cluster.sh` pornește:
|
||||
- **📧 Email: "Shutdown cluster PORNIT"**
|
||||
- **Step 1:** Oprește toate VM-urile și LXC de pe toate nodurile
|
||||
- **Step 2:** Așteaptă 90 secunde pentru oprire graceful
|
||||
- **Step 3:** Shutdown pve1 și pve2 (noduri secundare)
|
||||
- **Step 4:** Așteaptă 30 secunde
|
||||
- **Step 5:** Shutdown pvemini (nod primary - ultimul)
|
||||
- **Step 3:** Shutdown pve1 → **📧 Email: "Shutdown pve1 trimis"**
|
||||
- **Step 4:** Shutdown pveelite → **📧 Email: "Shutdown pveelite trimis"**
|
||||
- **Step 5:** Așteaptă 60 secunde
|
||||
- **📧 Email: "Shutdown pvemini (ULTIMUL NOD)"**
|
||||
- **Step 6:** Comandă UPS shutdown (oprire completă)
|
||||
- **Step 7:** Shutdown pvemini (nod primary - ultimul)
|
||||
|
||||
### Scenario 3: Baterie scăzută imediată
|
||||
1. UPS raportează LOWBATT (baterie critică)
|
||||
2. Shutdown **IMEDIAT** (fără timer)
|
||||
3. Același flux de shutdown orchestrat ca mai sus
|
||||
2. **📧 Email: "BATERIE CRITICĂ - SHUTDOWN IMEDIAT"**
|
||||
3. Shutdown **IMEDIAT** (fără timer)
|
||||
4. Același flux de shutdown orchestrat ca mai sus
|
||||
|
||||
## Quick Start
|
||||
|
||||
@@ -300,17 +309,29 @@ tail -50 /var/log/ups-monthly-test.log
|
||||
|
||||
## Configurare Personalizată
|
||||
|
||||
### Modificare timp de așteptare (default: 3 minute)
|
||||
### Modificare timp de asteptare (default: 3 minute)
|
||||
|
||||
Editează `/etc/nut/upssched.conf` pe pvemini:
|
||||
Fisier: `/etc/nut/upssched.conf` pe pvemini
|
||||
|
||||
```bash
|
||||
# Schimbă din 180 (3 min) la 300 (5 min)
|
||||
AT ONBATT * START-TIMER onbatt 300
|
||||
Linia relevanta:
|
||||
```
|
||||
AT ONBATT * START-TIMER onbatt 180
|
||||
```
|
||||
|
||||
Apoi:
|
||||
Valoarea **180** = secunde (3 minute). Exemple:
|
||||
- 180 = 3 minute
|
||||
- 300 = 5 minute
|
||||
- 600 = 10 minute
|
||||
|
||||
Pentru a modifica:
|
||||
```bash
|
||||
# Editare manuala
|
||||
nano /etc/nut/upssched.conf
|
||||
|
||||
# Sau comanda directa (exemplu: 5 minute)
|
||||
sed -i 's/START-TIMER onbatt [0-9]*/START-TIMER onbatt 300/' /etc/nut/upssched.conf
|
||||
|
||||
# Restart serviciu pentru a aplica
|
||||
systemctl restart nut-monitor
|
||||
```
|
||||
|
||||
@@ -381,12 +402,31 @@ iptables -A INPUT -p tcp --dport 3493 -s 10.0.20.0/24 -j ACCEPT
|
||||
- **Hardware Compatibility:** https://networkupstools.org/stable-hcl.html
|
||||
- **WinNUT GitHub:** https://github.com/gawindx/WinNUT-V2
|
||||
|
||||
## Notificări Email
|
||||
|
||||
Sistemul trimite notificări email via **PVE::Notify** pentru toate evenimentele importante:
|
||||
|
||||
| Eveniment | Când | Severity |
|
||||
|-----------|------|----------|
|
||||
| **ONBATT** | UPS trece pe baterie | warning |
|
||||
| **ONLINE** | Curentul revine | info |
|
||||
| **LOWBATT** | Baterie critică | error |
|
||||
| **SHUTDOWN_START** | Începe shutdown cluster | error |
|
||||
| **SHUTDOWN_NODE** | Shutdown nod secundar (pentru fiecare) | error |
|
||||
| **SHUTDOWN_PRIMARY** | Shutdown nod primary (ultimul) | error |
|
||||
| **COMMBAD** | Comunicație pierdută cu UPS | warning |
|
||||
|
||||
**Configurare:** Email-urile folosesc notificările Proxmox existente. Verifică că ai configurat un target email în **Datacenter → Notifications**.
|
||||
|
||||
**Template-uri:** `/etc/pve/notification-templates/default/ups-power-event-*`
|
||||
|
||||
## Funcționalități Complete
|
||||
|
||||
### ✅ Shutdown Orchestrat Automat
|
||||
- Detectare întrerupere curent (3 minute grace period)
|
||||
- Oprire ordonată: VM-uri → noduri secundare → nod primary
|
||||
- Notificări în timp real prin upssched
|
||||
- Oprire ordonată: VM-uri/LXC → noduri secundare → nod primary
|
||||
- **Oprire automată UPS** după shutdown (protecție power surge)
|
||||
- Notificări email la fiecare pas
|
||||
|
||||
### ✅ Test Lunar Automat Baterie (NOU!)
|
||||
- Rulare automată pe 1 ale lunii la 00:00
|
||||
@@ -410,10 +450,11 @@ iptables -A INPUT -p tcp --dport 3493 -s 10.0.20.0/24 -j ACCEPT
|
||||
## Autori și Istoric
|
||||
|
||||
- **Creat:** 2025-10-06
|
||||
- **Versiune:** 1.1
|
||||
- **Ultima modificare:** 2025-10-06
|
||||
- **Versiune:** 1.2
|
||||
- **Ultima modificare:** 2026-01-13
|
||||
- **Autor:** Configurat automat via Claude Code
|
||||
- **Changelog:**
|
||||
- v1.2 (2026-01-13): Adăugat notificări email pentru toate evenimentele UPS + oprire automată UPS
|
||||
- v1.1 (2025-10-06): Adăugat test lunar automat baterie cu notificări PVE::Notify
|
||||
- v1.0 (2025-10-06): Release inițial cu shutdown orchestrat și monitorizare NUT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user