Hi wonderful people,
I recently upgraded my UPS to a Cyberpower CP1500PFCLCD, one of the most popular UPS this year as it is affordable and sine wave waveform (won't debate here about cons/pros of sine wave).
I use it only for my Openmediavault baby, so I connected it directly via USB. It works, I am happy-ish.
I premise I am sharing this for both
a) helping temporarily those who like me are going banana and NUTs (pun intended) with this issue (see below) and
b) to start a thread that may hopefully bring a more stable/persistent solution
So.. I installed the Openmediavault official UPS NUT plugin, configured it good as per various threads here (see settings picture below) and everything seems to be working fine... except...
- I cannot either monitor the status remotely
- The plugin simply fails to shut down the server on loss of power (I explain below) making it moot to have it running.
The server looses connection randomly for no apparent reason, consistently in a range between 5 to 75 minutes after I manually stop/restart the service, because of the dreaded (and apparently well-known) "Data stale" issue.
- DRAMA: I get notifications of this every 5 minutes via email, so if I am not at home to restart the service manually, I get self spammed HUNDREDS of email notifications: I need/want all the other notifications, and mostly I can choose, but i cannot disable the ones for UPS (not in the list yet (hint, hint)).
- Of course, with the UPS disconnected, there is no point running the plugin or the monitoring at all as the server won't get nor issue the "graceful shutdown" command.
I perused everywhere, finding solutions that are outdated for OMV2 and OMV3 that no longer apply, and I attempted every trick in the book (e.g. changing the upsd.conf values for maxstartdelay, which it will ignore and maxretry, which is also ignored) but nada...
- Monitoring: no software for windows or linux are able to establish connection to the OMV server from local network on its local address and the port 3493 (or any other port). I checked with open FW port and no FW at all, TCP and UDP.
I finally had enough NUTs so I decided to create a shell script and then add it on cron (on reboot) that will run continuously and check on the UPS link status, and if disconnected will restart the service: this way I will still get an email notification every time it disconnects and reconnects, but not every five minutes for hours. This way I will get 20/30 notices, not 300.
I also noticed that since I started this script, I am getting almost no failure notices, possibly because of the harassing nature of the scripts itself.
Basically this script, launched on reboot, will run in the background and checks every 10 seconds if the UPS link is up using "upsc xyz" (upsc comes pre-installed with OMV) command status.
This method actually provides a status value of 0 (if link up) / 1 (if link down) with echo $?, hence the idea of using it to trigger a driver/daemon restart using the "upsdrvctl start".
To launch it silent without output I use a second shell script, which is also what I use in the OMV task scheduler to run it on reboot.
I created two shell script files in root home:
- touch /root/checkups.sh
- touch /root/upsfix.sh
made them executable by root user and group only.
Then in the OMV control panel for the System \ Scheduled Jobs (cron), I created a task,
- At reboot, as Root, execute "sleep 300 && /root/upsfix.sh"
One can change the check loop interval from 10 seconds to whatever. Though IMHO I wouldn't go any lower than 5 or any higher than 300 (5 minutes).
5 minutes (sleep 300) is also what I chose the launcher to wait after reboot to start the script, just to make sure everything is loaded and up and running before launching this.
SO: with this I fixed temporarily the SPAM and now everything seems to be working fine: I pulled the power to the UPS to test, while it was reporting UPS link disconnected, and 10 seconds later it reconnected and the plugin issued the shutdown.
Question to you wonderful people: can we do any better than this workaround?
Please feel free to kill, mock and denigrate my code skills, I'd actually really love if you can do better and show me how.
It is always a good time to learn new things !
You guys have a wonderful week !