Interfacing UPS, Synology and WinNUT for Windows - Gadget Victims

Post Top Ad

Interfacing UPS, Synology and WinNUT for Windows

Power cuts are very common in my area with about 2 incidents monthly. So far, the damage has been minimal with just one hard disk full of games lost. It would have been another story if it happened to the NAS dedicated to my  photos, music and movies.
After comparing different brands and models, the BE700G(-UK) from APC appeared as the obvious choice.
It is said to have enough power to allow plenty time for my stuff to shut down safely and it's just like a bulky power strip that can stay discrete on the floor. 

Next thing was to find a store to buy it. It was particularly convenient since APC has an Irish web site with the model available for €118.99 (VAT & Shipping included). Just four days later, the Back-UPS arrived from Netherlands and I started to install it.



All it took was to connect the cathode wire in the battery compartment, link the UPS data port to the NAS (Synology DS-109) with the USB cable provided, and decide which devices to plugs in the 8 outlets (4 surge protection + backup power, and 4 surge protection only). In my configuration, there would be an old 300W tower computer, a 22" LCD monitor (80W), and the Synology NAS (20W) on the power backup side. The printer would be on the surge-protection-only side on a "controlled" outlet. One feature offered by the BE700G is to allow up to 3 devices on the "controlled" outlets to be powered off when the device on the "master" outlet (typically a PC) shuts down.

Ideally the UPS must be left to charge for the first 16 hours in order to provide an optimal protection, so I resisted the urge to play with it...for at least 20 minutes...


In my case it was not necessary to install the included PowerChute software since I linked the UPS to my Synology Diskstation which software already takes care of the UPS management. By default it is set to keep the NAS running until the UPS battery is low (which takes 4 min. in my case), then it would go on safe mode, I preferred to have this action done after 1 minute.
At this stage, I enabled the network UPS server with no clear idea how I would make this work with my PC.

I first thought that the PowerChute software would be necessary, but it only work if the UPS is locally connected to the PC USB ports. As a newbie in to the UPS world, I learnt that a network UPS server (NUT) would provide its service to NUT clients, and while there were plenty available for Linux, there were only a few running on Windows platforms.


I came accross that neat freeware called WinNUT which has the excellent option to install as a service. Its properties file must be properly configured but comes with enough comments and examples to make this possible in a matter of minutes. After clicking the "Apply and Start WinNUT" button , the computer was ready to receive alerts from the NAS. It is good to note that WinNUT 2.0.0b works perfectly on Windows 7.



I just switched off the wall outlet for a test and, while the Synology DiskStation detected the new UPS status (which in turn started to beep at regular intervals), the WinNUT client sent a pop up message to relay the information.




After the 60 seconds specified, both NAS and PC initiated their shut-down procedure.


...and best of all... a real outage occurred shortly after my UPS unit was installed !



Quick update:

Since this post was published, some things have changed:
1. The latest Winnuts development is now found at http://code.google.com/p/winnut/

2. Winnuts may log an "Access Denied" on startup. The solution is to use the credential defined in /usr/syno/etc/ups/upsd.users for the MONITOR command in upsmon.conf. So the line would look like this: MONITOR ups@192.168.x.x 1 monuser secret slave

3. Since Vista, the "Allow Service to Inreract with Desktop" does not allow the service to send its popup alerts. To workaround this, you need to spot the "Application Popup" event in Windows Event Viewers > Windows Logs > System, select it and define a task for this event (Action pane). In the possible actions for this "trigger", you can choose to display a system message. This new task will appear in the Task Scheduler.


15 comments:

J.G. said...

Excellent post - very informative! Question - when the power is restored after the Synology NAS has shut itself down, will the NAS power up again, or do you have to manually press the power button?

Bubbah said...

@J.G.
If the Power Recovery function has been enabled in DSM, the system will restart automatically when power is restored.
Cheers

Unknown said...

Hi Bubbah,

Sorry for the noob question but what is this upsd.users? a file in windows? how do I access it?

Bubbah said...

Hi Jonathan,
It's a standard UPS server config file found on the Synology DiskStation. You need a terminal emulator like putty to access it. The credential used for the UPS monitoring service is found at the end, and should look like this:
[monuser]
password = secret
upsmon master


Unknown said...

I managed to read it.

DO I need to edit anything in this upsd.users file? if so how to do it?

Bubbah said...

Just don't change anything to that file on the NAS but confirm that it matches the example in the "Quick Update" section of the article, so you can reflect that credential in your WinNUTS (upsmon.conf) config.

Jondave said...

Hi I can access my synology box with shh but I cannot access the upsd.users file, how do I do this

Bubbah said...

you need to use the root user (not "admin") to have the permission to open the upsd.users (located under /usr/syno/etc/ups/), but I recommend that you don't edit it. Just use the info in it. By default you should see this:
[monuser]
password = secret
upsmon master

...so upsmon.conf would use:
MONITOR ups@192.168.x.x 1 monuser secret slave

Mark Marino said...

I continue to get an access denied error using DSM5 on a DS412+ any ideas why?

Mark Marino said...

The upsd.users file on the DS412+ contains this:
# The matching MONITOR line in your upsmon.conf would look like this:
#
# MONITOR myups@localhost 1 upsmon pass master (or slave)
[monuser]
password = secret
upsmon master

The upsmon.conf file contains this:
MONITOR myups@192.168.1.100 1 monuser secret slave

The log entries in the WinNUTUpsMon.log file are:
Level ALERT 04/29/2014 16:11:24 WinNUTUpsMon Service is starting to monitor UPS
Level ERROR 04/29/2014 16:11:24 Set username on [myups@192.168.1.100] failed: Access denied
Level ERROR 04/29/2014 16:11:29 Poll UPS [myups@192.168.1.100] failed - Access denied
Level NOTICE 04/29/2014 16:11:29 Communications with UPS myups@192.168.1.100 lost

So what gives? Anybody else got this working?

merceroz said...

I've been setting this up today and I believe I've got it working. Need to do some final testing. However if I turn the power off to the UPS connected to my Diskstation 214 I certainly see a UPS event log message on my PC.

Have you entered the IP address of your PC as a 'Permitted Diskstation' under the UPS control panel on your Diskstation? Presumably it will only accept a connection from a authorised source.

frantyk said...

just wanted to say thanks for this blog. setup was so simple.
addded the line "MONITOR ups@192.168.x.x 1 monuser secret slave" to the WinNut config file after installing it, also added the PC address to the Synology "UPS > Allowed Devices" page, done.
piece of cake.

Unknown said...

Ive set up Synology and WinNUT and am about to try switching the mains off! I have the shutdown method set to "Forced".

Is there an option somewhere in WinNUT to tell the PC to hibernate?

James Abram said...

Thanks for this mate! This is really useful in setting up my PC Uninterruptible Power Supply

yudi one said...

Hi,.. this a very good information to shared< i've been looking how to manage this kind of scenario, I already try it and the slave (windows server 2019) is properly shut down after 1 minutes, but it seems the NAS was not shut down, and when the UPS charged back, the slave (server) was not auto power on, how to solve this?, thank you

Post Top Ad