Hi folks,
I'm trying to figure out a way to accomplish the following, and looking for some expert help to guide me on my way. I'll outline the scenario and where I am looking for some help.
Background
- My wife recently upgraded her computer, opting for an M1 iMac (against my advice, her choice and happy wife = happy life)
- Her old machine has become my new Unraid machine, as it is much better than the 12 year old Athlon II I had running previously, and it included my old GTX1080 video card (migration was a breeze - my 20TB array moved over without any issues)
- Using the guide from dboris, I setup an NHOS VM, which is fully operational and mining away right now
- My local area suffers from frequent brown outs and black outs, usually brief, but to protect my array my server is connected to a UPS
- This UPS also has my core network connected to it (modem, switch, router, 1 access point, a couple raspberry pi's) as well, so that I have time to save my work to the network and recover gracefully if the power outage is extended past 10 minutes or so
- Right now, I have the NUT plugin installed to manage my UPS
- If there is a power outage, and the battery life drops below 30% on my UPS, the whole array will shut down, leaving me with about 30 minutes of battery on the network equipment
Where I need help
- What I'd like to do, is have my VMs shut down if the power outage lasts more than 10 seconds, so that my array can still stay online much longer, given that NHOS is eating up an additional 120W with my GPU, and also a windows VM that is always busy eating up lots of CPU as well
- I've come across these shell commands that do the trick
- Where I need help: How can I get the command "virsh shutdown <VM name>" to execute only when the UPS changes state to ONBATT for more than 10 seconds? Also, I would want it to spin the VM back on with "virsh start <VM name>" once power is restored?
- I've come across the NUT guide which should show me how to do this, but it's a bit over my head
Worst case, I will just have to live with the shorter lifespan of the array on battery power, but this would really help me avoid power cycling the whole server for the majority of the power challenges I have, which rarely last more than 10 minutes
Thank you for your consideration and reading!!!!
Unraid Machine Details:
ASRock Z87 Killer | Intel i7 4790K | 16 GB DDR3 1600 | ASUS GTX 1080 | 20GB Array with 1TB Cache NVME