mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-04-28 22:20:38 +00:00
Update notification service
This commit is contained in:
@@ -1093,7 +1093,7 @@ class HealthPersistence:
|
|||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
# ─── System Capabilities Cache ───────────────────��───────────
|
# ─── System Capabilities Cache ───────────────────────────────
|
||||||
|
|
||||||
def get_capability(self, cap_key: str) -> Optional[str]:
|
def get_capability(self, cap_key: str) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ def _format_vzdump_body(parsed: Dict[str, Any], is_success: bool) -> str:
|
|||||||
return '\n'.join(parts)
|
return '\n'.join(parts)
|
||||||
|
|
||||||
|
|
||||||
# ──�� Severity Icons ──────────────────────────────────────────────
|
# ─── Severity Icons ──────────────────────────────────────────────
|
||||||
|
|
||||||
SEVERITY_ICONS = {
|
SEVERITY_ICONS = {
|
||||||
'CRITICAL': '\U0001F534',
|
'CRITICAL': '\U0001F534',
|
||||||
|
|||||||
@@ -368,42 +368,9 @@ install_proxmenux_monitor() {
|
|||||||
local shutdown_script_src="$TEMP_DIR/Scripts/shutdown-notify.sh"
|
local shutdown_script_src="$TEMP_DIR/Scripts/shutdown-notify.sh"
|
||||||
mkdir -p "$MONITOR_INSTALL_DIR/scripts"
|
mkdir -p "$MONITOR_INSTALL_DIR/scripts"
|
||||||
local shutdown_script_dst="$MONITOR_INSTALL_DIR/scripts/shutdown-notify.sh"
|
local shutdown_script_dst="$MONITOR_INSTALL_DIR/scripts/shutdown-notify.sh"
|
||||||
if [ -f "$shutdown_script_src" ]; then
|
cp "$shutdown_script_src" "$shutdown_script_dst"
|
||||||
cp "$shutdown_script_src" "$shutdown_script_dst"
|
chmod +x "$shutdown_script_dst"
|
||||||
chmod +x "$shutdown_script_dst"
|
msg_ok "Shutdown notification script installed."
|
||||||
msg_ok "Shutdown notification script installed."
|
|
||||||
else
|
|
||||||
msg_warn "Shutdown script not found, creating default..."
|
|
||||||
cat > "$shutdown_script_dst" << 'SHUTDOWN_EOF'
|
|
||||||
#!/bin/bash
|
|
||||||
# ProxMenux Monitor - Shutdown Notification Script
|
|
||||||
LOG_FILE="/var/log/proxmenux-shutdown.log"
|
|
||||||
PORT="${PORT:-8008}"
|
|
||||||
log() { echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> "$LOG_FILE" 2>/dev/null || true; }
|
|
||||||
log "=== Shutdown notification script started ==="
|
|
||||||
is_reboot=false
|
|
||||||
systemctl is-active --quiet reboot.target 2>/dev/null && is_reboot=true
|
|
||||||
if [ "$is_reboot" = true ]; then
|
|
||||||
event_type="system_reboot"
|
|
||||||
reason="The system is rebooting."
|
|
||||||
else
|
|
||||||
event_type="system_shutdown"
|
|
||||||
reason="The system is shutting down."
|
|
||||||
fi
|
|
||||||
hostname=$(hostname)
|
|
||||||
log "Event: $event_type, Host: $hostname"
|
|
||||||
response=$(curl -s -w "\n%{http_code}" -X POST "http://127.0.0.1:$PORT/api/internal/shutdown-event" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{\"event_type\": \"$event_type\", \"hostname\": \"$hostname\", \"reason\": \"$reason\"}" \
|
|
||||||
--max-time 10 2>&1)
|
|
||||||
log "Response: $response"
|
|
||||||
sleep 3
|
|
||||||
pkill -TERM -f "flask_server" 2>/dev/null || true
|
|
||||||
log "=== Shutdown script completed ==="
|
|
||||||
exit 0
|
|
||||||
SHUTDOWN_EOF
|
|
||||||
chmod +x "$shutdown_script_dst"
|
|
||||||
fi
|
|
||||||
msg_ok "ProxMenux Monitor beta v${appimage_version} installed."
|
msg_ok "ProxMenux Monitor beta v${appimage_version} installed."
|
||||||
|
|
||||||
if [ "$service_exists" = false ]; then
|
if [ "$service_exists" = false ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user