Blog

Connect a ESXi 6.5 Host to a UPS Connected to a Synology NAS

If you have a consumer UPS that connects via USB, you need to use this workaround to expose the UPS to the ESXi host. I use the built in NUT server on a Synology NAS to expose the UPS to the ESXi using a vib packaged NUT client.

This is an updated guide including the Synology side as well. Find the earlier guide here.

Variables set on the ESXi NUT Client configuration

The following client parameters (as named and defined in ESXi) are needed from the NUT server, in our case it’s the Synology NUT server. These are set in two different files as described below.

1
2
3
4
5
6
7
8
9
10
UserVars.NutUpsName    : UPS name on remote NUT server ([email protected]_name),
can be a space separated list of NUT servers. In our case the servername is defined on the Synology ([email protected]).
UserVars.NutUser : Username to connect to NUT server. If more that one NUT
server is declared, all need to use the same user/password.
The Synology default is "monuser"
UserVars.NutPassword : Username password on NUT server
The Synology default is "secret".
UserVars.NutFinalDelay : Seconds to wait on low battery event before shutting down
UserVars.NutSendMail : Set to 1 if you want a mail to be sent on UPS event
UserVars.NutMailTo : Email address to send mail to on UPS event

Allow ESXi clients to query upsmon on the Synology

First enable the Synology “Network UPS” and then allow other clients to query the NUT server on the Synology by entering their ip addresses.

NUT configuration on the Synology

The NUT configuration on the Synology is located in the /usr/syno/etc/ups/ directory.

Synology configuration details

The named server instance is defined in the file ups.conf. The default is “ups” which is later used on the ESXi side together with the ip: [email protected]

1
sudo cat /usr/syno/etc/ups/ups.conf

The instance name is the node, in this case “ups”. Port is set to 3493 by default (auto). If the port is non-default, you will need to make the proper changes in the firewall on the ESXi side, however the defaults are automatically applied during installation.

Credentials

This file is updated whenever the fw is updated on the Synology which is something to keep in mind if you want to set your own. The username and password are used on the ESXi side.

1
sudo vi /usr/syno/etc/ups/upsd.users

The user is the node.

Download the NUT client vib package to the ESXi host

The NUTClient vib package has (2016-04) been updated to version 1.4 to include “NUT v2.7.4 and SSL support with embeded libressl 2.3.0”.

The NUT client package contains configuration files, installation script, firewall settings in addition to the NUT client library.

1
wget [http://rene.margar.fr/downloads/NutClient-ESXi500-1.4.0.tar.gz](http://rene.margar.fr/downloads/NutClient-ESXi500-1.4.0.tar.gz)

Extract package

1
tar -xvzf NutClient-ESXi500-1.4.0.tar.gz

Make sure to set the script files to be executable.

1
chmod +x upsmon-install.sh

Update the install script

Instead of entering the configuration using the UI, you can set them to default values using the install script as well. The settings are used to create configuration files on the ESXi host, when the service is started.

1
2
3
4
5
6
7
8
9
#!/bin/sh
DIRNAME="`pwd`"
esxcfg-advcfg -A NutUpsName -T string -E 'NUT remote ups name (eg: [email protected]) use space as a separator for multiple upses' -F [email protected]
esxcfg-advcfg -A NutUser -T string -E 'NUT username to connect to remote ups' -F monuser
esxcfg-advcfg -A NutPassword -T string -E 'NUT password to connect to remote ups' -F secret
esxcfg-advcfg -A NutFinalDelay -T int -E 'NUT seconds to wait on low battery event before shutting down' -N 0 -M 3600 -F 60000
esxcfg-advcfg -A NutMailTo -T string -E 'NUT send mail notification to this address' -F [email protected]
esxcfg-advcfg -A NutSendMail -T int -E 'NUT send mail notification (1=yes 0=no)' -N 0 -M 1 -F 0
esxcli software vib install -f -v "${DIRNAME}/upsmon-2.7.4-1.4.0vmw.500.x86_64.vib"

Run the installation script

The vib installation also creates firewall settings to allow the client outbound traffic on default (3493 and 25) ports. You can change these ports in the firewall ruleset configuration file.

Verify installation in ESXi UI

Look in the Packages section of the UI

Reboot the ESXi host

The reboot forces the creation of the configuration files in addition to the variables being available in the advanced configuration

Validate the advanced settings

Make sure the settings are set as you want as these are used to generate the configuration files.

Validate configuration files in /etc/ups/

1
cat /etc/ups/upsmon.conf

The actual configuration used is contained in this file.

Validate firewall settings

1
ls /etc/vmware/firewall

Where the file upsmon.xml is added by the package.

1
esxcli network firewall ruleset list

Will list the upsmon in the list of rulesets as enabled set to true. Change the settings in the upsmon.xml file to update the ruleset.

Set autostart policy on the ESXi

The default startup policy is manual so you should change the startup policy to start and stop with the host.

Verify the NUT client connectivity with the NUT server

1
upsc [email protected]