FreeNAS UPS to run script

So the rolling black-outs have started to hit SoCal, I’ve been loooong over-due to setup something to gracefully shut down my lab.

I have a box running FreeNAS and a box running xcp-ng.

I was thinking of doing the following:
Use FreeNAS’s built-in UPS service (much like pfSense has a plugin):

For XCP-NG there was this article to use an API a long with a Windows box and the PowerChute software:
https://support.citrix.com/article/CTX119910

Since the APC will be plugged into just one of these two boxes, I need one to act as a server for this service. So going back to the FreeNAS–

There are Auxiliary Parameters (ups.conf)(upsd.conf)
image

Can scripts be ran from these parameters that use that API guidance to log into xcp-ng/xen and gracefully shutdown the VMs and then the host itself?

@LTS_Tom this would be a good youtube vid, just sayin haha

I haven’t tried it but, if your freenas is the master then I think you can create a script and then call the script in the section “Shutdown Command”. Then have your script login over SSH and shutdown whatever server you want.

1 Like

Plugged in the APC, now to see if it plays nice with the service:

And then try to finger out how to script for the xpc-ng, and test it.

Yeah let it rip! Your script should look something like this. Assuming you have install your ssh keys on all your hosts you want to reboot. :smiley:

ssh –t user@server.com 'sudo shutdown now'
1 Like