Posts Tagged ‘UPS’

Using a UPS with Hyper-V R2

Did you ever try to get a UPS up and running on a server using Microsoft Hyper-V? Well, I did. And it proofed to be a more difficult task than I had initially imagined…

There is quite some information about Hyper-V and UPS’s  that can be found on the internet, but most of this information is about connecting the UPS using a USB connection. In this scenario the server will act as a very big (and very heavy) laptop with the UPS being the battery. On a Windows 2008 server it would be possible to use the regular power options to shut down or hibernate the server when the battery (i.e. UPS) runs low.

Too bad this doesn’t apply to a Hyper-V R2 server (core) installation. On this platform it is possible to use all kinds of scripts that monitor the battery status using WMI (querying the WIN32_Battery class) and then shutting down the server when the battery is running low.

But in both cases only the server connected to the UPS will be shut down. What if there are multiple servers connected to the same UPS? This situation is quite common.

Of course one could write another script that shuts down several other servers before shutting down the Hyper-V server, but this would not be a very flexible solution.

Unfortunately, we did have another problem. Our UPS’s were not connected through USB, but through a serial cable. So all of the above doesn’t apply.

Before we migrated our physical servers to a Hyper-V based platform, we were using LanSafe to monitor our UPS’s. Despite a lot of people are always complaining that the UPS software itself is lousy, we quite liked the LanSafe software. This software did allow us to set up a LanSafe controller (server that was connected to and monitoring the UPS), several LanSafe members (servers that are shut down by the controller when the power fails) and and a LanSafe console (on a workstation) that allows the remote configuration of the LanSafe controllers. Wouldn’t it be neat to be able to use the LanSafe software again?

Downloading LanSafe

In order to download the LanSafe software, go to the Eaton website. Before you will be able to download the software, you will have to register first.

Eaton Website

After registering, you should be able to download the LanSafe software. Be sure to download all required versions. Since we want to install on a Hyper-V server, you have to download the 64-bit version. But if we also need to install the software for a member that is running on a 32-bit version of Windows, you will also need the 32-bit version.

Installing LanSafe

After downloading LanSafe we can install it on the Hyper-V server. But before we will start the installation, we will have to connect the UPS first. If the UPS is being detected as “New Hardware”, we can just ignore this by selecting “Don’t ask me again”. We can now run the installation program that we downloaded previously and go through the installation wizard:

  • Accept the license agreement.
  • Select “LanSafe Controller” to install the UPS monitoring component on the Hyper-V server.
  • Select “Serial Connection (COM port)” and have the software automatically detect the attached UPS.
  • Accept the detected serial port.
  • If required, select the correct UPS. LanSafe supports several different UPS models and different vendors. Usually the UPS will be detected correctly.
  • Enter the password for the LanSafe controller. This password is required when connecting remotely rom a different LanSafe member or console.
  • Accept the default Power Failure Settings (these settings can be configured later).
  • Enter a unique name for the controller.
  • Skip the configuration of the SMTP settings (this can be done at a later stage).>
  • Continue the installation wizard (installation folder and program group can be changed, if desired).

When the installation has finished unselect the option to start LanSafe !!! Before we can use LanSafe we still have some work to do.

Enabling the LanSafe GUI

The LanSafe GUI requires the presence of msvfw32.dll, but this DLL file is not present on a system running Hyper-V. You should be able to obtain a copy of this file from  the %WINDIR%\System32 folder on a computer running Windows Vista or Windows 7.

Now copy the DLL file into the %WINDIR%\SysWOW64 folder on the Hyper-V server. That’s it…

You should now be able to start LanSafe.exe which is located in the Bin subfolder of the installation location (usually C:\Program Files (x86)\Powerware\LanSafe\Bin).

LanSafe GUI

Configuring the firewall

As I mentioned before, it is quite common for a single UPS to supply power to multiple servers. In case of a power failure the controller should shut down the other servers first, before is will shut down itself. Therefor it must be possible for the controller and the member servers to communicate with each other. The problem is that the firewall blocks the ports that LanSafe requires for its communication. We need to enable these ports first.

The ports that LanSafe uses are UDP ports 3068, 3069 and 7015. To enable communication through port 3068, type the following commands in the command windows at the Hyper-V server:

netsh advfirewall firewall add rule name="LanSafe (UDP 3068)" protocol=udp localport=3068 dir=in action=allow

netsh advfirewall firewall set rule name="LanSafe (UDP 3068)" new enable=yes

Repeat the commands above for port 3069 and port 7015. When done, communication between the LanSafe controller and the LanSafe members / consoles will be possible.

Shutting down physical servers during power failure

When we would like the LanSafe controller to shut down other servers attached to the same UPS as the controller, we will need to install the LanSafe software on these servers as well. Depending on the type of Operating System on the server, we will either need to download the 32-bit or 64-bit version of the LanSafe software.

Run the appropriate installation package and go through the installation wizard:

  • Accept the license agreement.
  • Select to install a “LanSafe Member”.
  • Enter the name of the controller that should be managing this member.
  • Skip the configuration of the management settings. These settings can be configured later.
  • Select a destination folder and a program group.
  • When the installation is completed, LanSafe can be started.

After starting LanSafe it is required to enter the password of the controller. This is necessary to prevent unauthorized members to connect to the controller.

The shutdown timings for each member as well as the controller itself, can be configured through the Management Settings using the LanSafe GUI.

Shutting down the virtual servers on the Hyper-V server

Using virtual servers makes it very easy to shutdown a server, or even suspend a server. In fact, the latter is the default setting in Hyper-V. As soon as the physical Hyper-V server is shut down, all virtual server running on the Hyper-V server will be suspended.

Hyper-V VM Shutdown

If desired, it is also possible to automatically shut down all virtual servers. In that case one would have to select the bottom option in the Hyper-V management console.

UPS’s connected via USB or LAN

Although the information above is about using a serially attached UPS with Hyper-V, the LanSafe software also supports UPS’s connected via USB and UPS’s connected via the LAN using a network card inside the UPS. I have not been able to test these configurations myself. I know that the LanSafe software also contains drivers for USB connected UPS’s (you’ll have to extract these drivers from the installation program first). You will probably need to install these drivers on your Hyper-V server first, before attaching your UPS.

If you can confirm this from your own personal experience, then please leave me a comment.

Categories: Hyper-V, Virtualization Tags: ,