How do I move the downloaded .Deb installer for powerpanel to proxmox and install. Want to have the program to alow automatic shutdowns.
curl -o cyberpowerpowerpanel.deb https://www.cyberpower.com/tw/en/File/GetFileSampleByType?fileId=SU-18070001-06&fileType=Download%20Center&fileSubType=FileOriginal
dpkg -i cyberpowerpowerpanel.deb
pwrstat -status
pwrstat -pwrfail -delay 60 -active on -cmd /etc/pwrstatd-powerfail.sh -duration 1 -shutdown on
pwrstat -lowbatt -runtime 300 -capacity 35 -active on -cmd /etc/pwrstatd-lowbatt.sh -duration 1 -shutdown on
man pwrstat
Thanks for this! SO much easier than nut server. Thank youOk I configured the graceful shutdown and it worked perfectly. For me personally, this was a much better solution than NUT (although if I end up with a setup in the future with multiple servers connected to the same UPS - or something else requiring different commands being sent to different machines, I can see why I would use NUT in that case.)
After you get the install set up from my post above, here is how you set up graceful shutdowns for power failures (mine is currently set up for a shutdown after 1 minute, but I might change it to 5 minutes by changing the delay from 60 to 300):
pwrstat -pwrfail -delay 60 -active on -cmd /etc/pwrstatd-powerfail.sh -duration 1 -shutdown on
you can also do a shutdown for low battery like this (This is set for when you have less than 5 minutes of battery time remaining but you can adjust that by changing the 300 seconds to something else if you like):
pwrstat -lowbatt -runtime 300 -capacity 35 -active on -cmd /etc/pwrstatd-lowbatt.sh -duration 1 -shutdown on
you can see all the options at:
man pwrstat
i tested the above by unplugging the UPS and after 1 minute, proxmox shutdown.
Yes that would be helpful. I have never setup nut client ( I have server)if needed i will post my config files as an example. Just let me know
/etc/ssmtp/ssmtp.conf
AuthUser=user@gmail.com
AuthPass=GmailPassword #obtain from ”Applications Password” on your google account
FromLineOverride=YES
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES
echo "this is for testing" | mail -s "$(echo -e "test\nFrom: UPS Alert <yourdesiredsenderaddress@email.com>\nContent-Type: text/html\n")" recipient@email.com
echo "${DATA[*]}" | mail \
-s "$(echo -e "$SUBJECT\nFrom: $FROM\n")" \
"$TO"
exit 0
/etc/pwrstatd-email.sh
with the following:IFS=$'\n'
echo "${DATA[*]}" | mail -s "$SUBJECT" root
exit 0
i figured out how to get it installed.
i went into the proxmox shell and typed:
curl -o cyberpowerpowerpanel.deb https://www.cyberpower.com/tw/en/File/GetFileSampleByType?fileId=SU-18070001-06&fileType=Download%20Center&fileSubType=FileOriginal
to download the installer.
then I did:
dpkg -i cyberpowerpowerpanel.deb
and that installed it.
it is definately working insofar as that I can type
pwrstat -status
and it will display things like battery capacity and runtime.
I am still unsure how to configure it for a graceful shutdown from here but I am working on it and I will get back to you.
if you setup smtp via datacenter you can simply ignore the from to address variables in your scripts and setup/etc/pwrstatd-email.sh
with the following:
Bash:IFS=$'\n' echo "${DATA[*]}" | mail -s "$SUBJECT" root exit 0
#!/bin/bash
#
# This is sample script of the send mail for pwrstatd daemon using.
#
# If you want to change SMTP server, edit following parameters into /etc/mail.rc file.
# set smtp=smtp server address
# set smtp-auth-user=user name
# set smtp-auth-password=user password
SUBJECT="PowerPanel Notification - [$EVENT]"
FROM="PowerPanel Daemon <$SENDER_ADDRESS>"
TO="$RECEIPT_NAME <$RECEIPT_ADDRESS>"
MESSAGE="Warning: The $EVENT event has occurred for a while, system will be shutdown immediately!"
DATE=`date +'%Y/%m/%d %p %H:%M'`
test ${#DATE}
RUNTIME=""
if [ ! -z "$REMAINING_RUNTIME" ]; then
RUNTIME="Remaining Runtime: $REMAINING_RUNTIME Seconds"
fi
DATA=(
"========================================================"
" $SUBJECT"
"========================================================"
""
""
"$MESSAGE"
"Time: $DATE"
""
""
"UPS Model Name: $MODEL_NAME"
"Battery Capacity: $BATTERY_CAPACITY %"
"$RUNTIME"
)
IFS=$'\n'
echo "${DATA[*]}" | mail -s "$SUBJECT" root
exit 0
#IFS=$'\n'
#echo "${DATA[*]}" | mail \
#-r "$FROM" \
#-s "$SUBJECT" \
# "$TO"
#exit 0
-test only makes a self test of the UPS batteryDoes this look about right? Should I delete the "TO="$RECEIPT_NAME <$RECEIPT_ADDRESS>""? if so should it be
TO="$google <$test@gmail.com>" or remove the dollar sign?
They look like variables but where are they defined?
Any way to test this? I tried "pwrstat -test" but no email is sent.
-test only makes a self test of the UPS battery
try unplugging it from main and see then
SUBJECT="PowerPanel Notification - [$EVENT]"
FROM="PowerPanel Daemon <$SENDER_ADDRESS>"
TO="$RECEIPT_NAME <$RECEIPT_ADDRESS>"
MESSAGE="Warning: The $EVENT event has occurred for a while, system will be shutdown immediately!"
DATE=`date +'%Y/%m/%d %p %H:%M'`
test ${#DATE}
RUNTIME=""
if [ ! -z "$REMAINING_RUNTIME" ]; then
RUNTIME="Remaining Runtime: $REMAINING_RUNTIME Seconds"
fi
DATA=(
"========================================================"
" $SUBJECT"
"========================================================"
""
""
"$MESSAGE"
"Time: $DATE"
""
""
"UPS Model Name: $MODEL_NAME"
"Battery Capacity: $BATTERY_CAPACITY %"
"$RUNTIME"
)
IFS=$'\n'
echo "${DATA[*]}" | mail -s "$SUBJECT" root
exit 0
#IFS=$'\n'
#echo "${DATA[*]}" | mail \
#-r "$FROM" \
#-s "$SUBJECT" \
# "$TO"
#exit 0
journalctl _SYSTEMD_UNIT=postfix@-.service
ug 03 16:18:17 procove postfix[764]: Postfix is using backwards-compatible default settings
Aug 03 16:18:17 procove postfix[764]: See http://www.postfix.org/COMPATIBILITY_README.html for details
Aug 03 16:18:17 procove postfix[764]: To disable backwards compatibility use "postconf compatibility_level=3.6" and "postfix reload"
Aug 03 16:18:18 procove postfix/postfix-script[860]: starting the Postfix mail system
Aug 03 16:18:18 procove postfix/master[862]: daemon started -- version 3.7.11, configuration /etc/postfix
Aug 03 17:52:17 procove postfix/pickup[863]: 677178050F: uid=0 from=<root>
Aug 03 17:52:17 procove postfix/cleanup[40682]: 677178050F: message-id=<20240803225217.677178050F@procove.alife.com>
Aug 03 17:52:17 procove postfix/qmgr[864]: 677178050F: from=<root@procove.life.com>, size=889, nrcpt=1 (queue active)
Aug 03 17:52:17 procove postfix/smtp[40684]: connect to gmail-smtp-in.l.google.com[607:f0:43:104::b]:25: Network is unreachable
Aug 03 17:52:47 procove postfix/smtp[40684]: connect to gmail-smtp-in.l.google.com[142.50.15.26]:25: Connection timed out
Aug 03 17:53:17 procove postfix/smtp[40684]: connect to alt1.gmail-smtp-in.l.google.com[142.250.12.26]:25: Connection timed out
Aug 03 17:53:17 procove postfix/smtp[40684]: connect to alt1.gmail-smtp-in.l.google.com[267:f80:401:c56::1b]:25: Network is unreachable
Aug 03 17:53:17 procove postfix/smtp[40684]: connect to alt2.gmail-smtp-in.l.google.com[207:fb0:403:1::1b]:25: Network is unreachable
WHere do you check this?Ensure in the shell script being used, e.g. pwrstatd-powerfail.sh or pwrstatd-lowbatt.sh, the email variable is set to yes.
nano /etc/pwrstatd-powerfail.sh