Hi all,
I’m seeking assistance to configure Proxmox to send an email (or Telegram message, if possible) when the system shuts down due to a UPS-triggered shutdown.
Setup Overview:
• My Proxmox server is a NUT client of a Synology NAS, which is connected to the UPS.
• During a live power outage test, when the Synology shuts down, Proxmox follows shortly after. This works fine with the default NUT config.
Goal:
I want Proxmox to notify me when a UPS-triggered shutdown is initiated, and tell my UDM SE to shutdown.
Current Attempt:
I used ChatGPT to do this, but later realised its not quite what I want.
I’ve created a shutdown script at /usr/lib/systemd/system-shutdown/udm_shutdown.sh with the following content:
The script works for shutting down my UDM SE. However, the email notification doesn’t send.
I believe this script runs too late in the shutdown process — possibly after email services are already terminated? When watching the hardware physically, I only see the UDM SE start shutting down moments before the proxmox host machine cuts power.
Additionally, I realised this script runs for all shutdowns and not just NUT-triggered ones.
I’m still a novice with most things Linux and would appreciate any guidance to:
1. Ensure the email notification is sent before Proxmox shuts down, even if it means it sends it on ALL shutdowns, I can live with this. I can't have my UDM shutting down on all shutdowns though.
2. Make this notification specific to NUT-triggered shutdowns, if possible.
Perhaps I need to spin up a VM, or external machine to handle the shutting down of the UDM SE and sending the email notification?
Thank you in advance for your help!
I’m seeking assistance to configure Proxmox to send an email (or Telegram message, if possible) when the system shuts down due to a UPS-triggered shutdown.
Setup Overview:
• My Proxmox server is a NUT client of a Synology NAS, which is connected to the UPS.
• During a live power outage test, when the Synology shuts down, Proxmox follows shortly after. This works fine with the default NUT config.
Goal:
I want Proxmox to notify me when a UPS-triggered shutdown is initiated, and tell my UDM SE to shutdown.
Current Attempt:
I used ChatGPT to do this, but later realised its not quite what I want.
I’ve created a shutdown script at /usr/lib/systemd/system-shutdown/udm_shutdown.sh with the following content:
Code:
#!/bin/bash
# This script runs during system shutdown to power off the UDM SE and send an email notification.
# Define email parameters
EMAIL_SUBJECT="Proxmox Shutdown Initiated"
EMAIL_RECIPIENT="my_email@example.com"
EMAIL_BODY="Proxmox is initiating shutdown. A command to power off the UDM SE has been sent."
# Send an email notification
echo "${EMAIL_BODY}" | mail -s "${EMAIL_SUBJECT}" "${EMAIL_RECIPIENT}"
# Send shutdown command to UDM SE via SSH
sshpass -p "your_password_here" ssh -o StrictHostKeyChecking=no root@192.168.1.1 ubnt-systool poweroff
The script works for shutting down my UDM SE. However, the email notification doesn’t send.
I believe this script runs too late in the shutdown process — possibly after email services are already terminated? When watching the hardware physically, I only see the UDM SE start shutting down moments before the proxmox host machine cuts power.
Additionally, I realised this script runs for all shutdowns and not just NUT-triggered ones.
I’m still a novice with most things Linux and would appreciate any guidance to:
1. Ensure the email notification is sent before Proxmox shuts down, even if it means it sends it on ALL shutdowns, I can live with this. I can't have my UDM shutting down on all shutdowns though.
2. Make this notification specific to NUT-triggered shutdowns, if possible.
Perhaps I need to spin up a VM, or external machine to handle the shutting down of the UDM SE and sending the email notification?
Thank you in advance for your help!
Last edited: