Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.
Resource icon

Configuring UPS support for single or multiple FreeNAS servers

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,211
Spearfoot submitted a new resource:

Configuring UPS support for single or multiple FreeNAS servers - Details on configuring the NUT UPS tools for use with FreeNAS servers connected to a UPS

If you are running a FreeNAS server you definitely need to connect it to a UPS.

Standalone Configuration

The official FreeNAS 9.10 UPS service documentation is available at doc.freenas.org and you should read it before proceeding.

Configuring a standalone FreeNAS server is fairly simple, provided your UPS is supported by the Network UPS Tools driver used by FreeNAS. You may consult networkupstools.org's...
Read more about this resource...
 

marksibert

Neophyte
Joined
Jun 5, 2018
Messages
7
I agree - great resource! Is there any documentation on how to set up multiple UPSs, in the case where there is a server with redundant power supplies, each plugged into its own UPS?
 

jp83

Junior Member
Joined
Mar 31, 2017
Messages
23
Trying to set this up myself. Spearfoot's guide "ssh root@esxihost poweroff" and neb50's "ssh root@ipaddress /sbin/poweroff" both seem to Power Off VMs as opposed to Shutdown Guest (using VM Tools for a safe shutdown). I was watching the tasks at the bottom. I also looked in the config in the esxi NUT client and it appears to use the poweroff command as well. Sounds like permissions issues prevent a wrapper script from working, so how are you safely shutting down ESXi VMs?

Cross-post link: https://forums.freenas.org/index.php?threads/ups-shutdown-esxi-6-5.63211/#post-486371
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,211
Trying to set this up myself. Spearfoot's guide "ssh root@esxihost poweroff" and neb50's "ssh root@ipaddress /sbin/poweroff" both seem to Power Off VMs as opposed to Shutdown Guest (using VM Tools for a safe shutdown). I was watching the tasks at the bottom. I also looked in the config in the esxi NUT client and it appears to use the poweroff command as well. Sounds like permissions issues prevent a wrapper script from working, so how are you safely shutting down ESXi VMs?

Cross-post link: https://forums.freenas.org/index.php?threads/ups-shutdown-esxi-6-5.63211/#post-486371
No, the 'poweroff' command shuts down the ESXi host, not the VMs. The latter are shutdown as part of the normal ESXi server shutdown sequence -- but only if you have configured it correctly! Otherwise (if memory servers) ESXi will simply power them down. So you must configure your ESXi server to send a graceful shutdown command to at least the FreeNAS VM, and any other VMs not homed on storage provided by the FreeNAS VM.

With this setup, as part of the ESXi host shutdown sequence, the FreeNAS VM itself receives a shutdown command from its ESXi host. This invokes your FreeNAS shutdown script, which should send shutdown commands to each VM it stores (either on NFS or iSCSI storage). These VMs should have the VMware tools installed.

See my resource Utility scripts for FreeNAS and VMware ESXi for scripts you can modify to use on your AIO (All-In-One) server to do all of this stuff.

It can be a little tough to wrap your mind around all of this, but it really does work very well. I've been using this setup for several years on multiple AIO servers.

Good luck!
 

NasKar

Neophyte Sage
Joined
Jan 8, 2016
Messages
670
Thanks for the great guide. I'm not running ESXi so is the Shutdown Command
Code:
/sbin/shutdown -p now
ok for the Master and Slave?
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,211
Thanks for the great guide. I'm not running ESXi so is the Shutdown Command
Code:
/sbin/shutdown -p now
ok for the Master and Slave?
Yes
 

Sundog

Newbie
Joined
Jun 10, 2020
Messages
2
Thanks for posting the guide it was very useful! I'm a little stuck on one part though. If I run the poweroff command as a test in Freenas shell, I'm still getting prompted for a password when I connect to my ESXI server. I don't think this should be happening because I setup SSH keypairs and an SSH connection under System in FreeNAS and I copied the public key to ESXI and pasted it into the authorized keys list. If I run the upsmon -fsd command it doesn't do anything other than stop the UPS service.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,211
Thanks for posting the guide it was very useful! I'm a little stuck on one part though. If I run the poweroff command as a test in Freenas shell, I'm still getting prompted for a password when I connect to my ESXI server. I don't think this should be happening because I setup SSH keypairs and an SSH connection under System in FreeNAS and I copied the public key to ESXI and pasted it into the authorized keys list. If I run the upsmon -fsd command it doesn't do anything other than stop the UPS service.
Thank you, @Sundog

I admit skipping over the details of configuring SSH keypairs, saying only "first enable the SSH service on the ESXi server and set up private key authentication", but in my defense there are probably hundreds of tutorials about this subject on the internet and I didn't want to get bogged down.

If you're being prompted for a password, something still isn't right with your VMware setup. VMware is a little different from everyone else, their SSH implementation looks in /etc/ssh/keys-root for the authorized_keys file. Also, you need to enable the ESXI shell service in addition to SSH; this service gives you access to CLI commands such as poweroff, etc.
 

Sundog

Newbie
Joined
Jun 10, 2020
Messages
2
Thanks for replying @Spearfoot

The strange part is that it's only an issue if I try and SSH from Freenas shell into the ESXi host. If I do it from Putty SSH client with it's own keypair then it works fine and I don't get prompted for a password. Both public keys are in the authorized_keys file each on a separate line. Maybe there's a syntax for separating them? I also recall before getting the Keypairs setup in Freenas I got prompted for whether I wanted to accept an unknown server key I think (something like that). I entered yes but I'm not sure if that could be the issue.

I currently have it sort of working by installing the NUT tools on the ESXi host, but that's not as clean as just doing it through SSH the way you did. The issue I've noticed with the poweroff command is that it doesn't seem to be gracefully powering off the VMs and isn't respecting the ESXi shutdown delay settings. I'll take another look at it today though and see if I can figure something out.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,211
Thanks for replying @Spearfoot

The strange part is that it's only an issue if I try and SSH from Freenas shell into the ESXi host. If I do it from Putty SSH client with it's own keypair then it works fine and I don't get prompted for a password. Both public keys are in the authorized_keys file each on a separate line. Maybe there's a syntax for separating them? I also recall before getting the Keypairs setup in Freenas I got prompted for whether I wanted to accept an unknown server key I think (something like that). I entered yes but I'm not sure if that could be the issue.

I currently have it sort of working by installing the NUT tools on the ESXi host, but that's not as clean as just doing it through SSH the way you did. The issue I've noticed with the poweroff command is that it doesn't seem to be gracefully powering off the VMs and isn't respecting the ESXi shutdown delay settings. I'll take another look at it today though and see if I can figure something out.
Yikes! I wouldn't recommend installing the NUT tools on your ESXi server.

I believe you will have success if configure your system according to these instructions. I'm using this setup on four FreeNAS-on-ESXi All-In-One systems here at my home, and I've been using this setup for ~5 years.

1> Until you can log on to your ESXi host via SSH using keys instead of a password, there's no hope of getting the FreeNAS UPS support to shut down your ESXi server. Did you double-check the key location I mentioned above? ESXi is a little different from other operating systems. In brief, your authorized_keys file for user root must be located here:

/etc/ssh/keys-root/

2> In addition to the SSH service (and it's key setup), you need to make sure the ESXi Shell service is running, too. See the screen shot below:
esxi-services.jpg


3> Lastly, the burden is on you to configure ESXi for graceful shutdown, it doesn't work that way out of the box. You'll have to install the VMware tools on all VMs and configure ESXi to shut them down instead of simply powering them off, see 'Stop Action' below:
esxi-startup-config.jpg
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,211

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,211

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,243
Unfortunately, (unless I've missed something in the interim), while FreeNAS is the perfect platform for Plex, it doesn't support TV tuner cards. I run a second Plex server on a Windows 10 Home PC with a Hauppage TV tuner card just so I can have Plex manage recorded TV programs such as my favourite cooking shows.

I've been using WinNUT for several years now on that PC as a NUT slave. For such an old piece of software, it's as solid as a rock and is dead easy to set up.

@Spearfoot This extract from the FreeNAS User Guide UPS

screenshot.542.png


I believe the port needs to be included in this line that's in the Overview...

MONITOR ups@172.16.10.13 1 upsmon 'your_upsmon_password' slave

so it operates with a FreeNAS NUT master i.e.

MONITOR ups@172.16.10.13:3493 1 upsmon 'your_upsmon_password' slave

Furthermore, as WinNUT is a partial port of the client side of NUT for Windows, I vaguely recall that I wasn't successful in setting it up as a NUT master.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,211
Unfortunately, (unless I've missed something in the interim), while FreeNAS is the perfect platform for Plex, it doesn't support TV tuner cards. I run a second Plex server on a Windows 10 Home PC with a Hauppage TV tuner card just so I can have Plex manage recorded TV programs such as my favourite cooking shows.

I've been using WinNUT for several years now on that PC as a NUT slave. For such an old piece of software, it's as solid as a rock and is dead easy to set up.

@Spearfoot This extract from the FreeNAS User Guide UPS

View attachment 41369

I believe the port needs to be included in this line that's in the Overview...

MONITOR ups@172.16.10.13 1 upsmon 'your_upsmon_password' slave

so it operates with a FreeNAS NUT master i.e.

MONITOR ups@172.16.10.13:3493 1 upsmon 'your_upsmon_password' slave

Furthermore, as WinNUT is a partial port of the client side of NUT for Windows, I vaguely recall that I wasn't successful in setting it up as a NUT master.
Interesting... Did you have to specify a port to get WinNUT to work? Because I just pasted in the MONITOR spec from my working WinNUT configuration file, which as you see, has no port specifier. Perhaps WinNUT defaults to port 3493 and you only need to give it explicitly when you use a different port?

My master NUT system contains only an IP address (no port) in the Auxillary parameters (upsd.conf) settings:
Code:
LISTEN 172.16.10.13
Does your master system include a port in the LISTEN setting?

I will gladly update the resource once we figure out how this part of the puzzle actually works. Thanks!
 

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,243
Did you have to specify a port to get WinNUT to work? Because I just pasted in the MONITOR spec from my working WinNUT configuration file, which as you see, has no port specifier. Perhaps WinNUT defaults to port 3493 and you only need to give it explicitly when you use a different port?
I think you're right. I've just always explicitly specified the port, but I just tried it without the port in the WinNUT upsmon.conf and it still works so this suggests that it must implicitly assume the master defaults to 3493.

Does your master system include a port in the LISTEN setting?
I have a FreeNAS server acting as NUT master.

screenshot.543.png


FreeNAS servers acting as NUT slaves do need to have the port specified.

screenshot.544.png
 
Last edited:
Top