Jump to content

Nicehash OS (NHOS) - Stopping VM when UPS switches


mcba3n

Recommended Posts

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

Quote

root@unraidserver:~# virsh list
 Id   Name          State
-----------------------------
 3    Nicehash OS   running

root@unraidserver:~# virsh shutdown "Nicehash OS"
Domain Nicehash OS is being shutdown

root@unraidserver:~# virsh start "Nicehash OS"
Domain Nicehash OS started

- 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

 

 

Link to comment

Thank you itimpi!

 

NicehashOS is running on a super stripped down version of linux, TinyCore.  I have scoured the support forums for TinyCore and there are no UPS controls built in - I would have to compile it myself.... which looks like a much larger mountain to climb.  I don't even know where to start with compiling packages....  though I have super user access to my server, I am far from a "super" linux user.

 

Thank you for your time

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...