[Nut-upsuser] How to get started (Windows)
Jeff Bowman
jeff.bowman at intexx.com
Sun Sep 11 19:37:51 UTC 2016
> On Thu, 8 Sep 2016, Jeff Bowman wrote:
>
> > (Note: running
> > 'upsc ups at localhost' echoes only a blank line to the screen, as do
> > both 'upsmon' and 'upsd.')
>
> Something is wrong here. Is the daemon upsd running? On a Unix/Linux
> system, the command ps aux | grep ups gives the report
>
> upsd 3196 0.0 0.0 13228 880 ? Ss août30 2:14 /usr/lib/ups/driver/usbhid-ups -a Eaton-66781
> upsd 3200 0.0 0.0 17560 736 ? Ss août30 0:49 /usr/sbin/upsd -u upsd
> root 3203 0.0 0.0 19432 664 ? Ss août30 0:00 /usr/sbin/upsmon
> upsd 3204 0.0 0.0 19856 1612 ? S août30 0:41 /usr/sbin/upsmon
>
> I don't have any Windows boxes, but I guess there is a similar command on
> Windows. What does it show?
The equivalent PowerShell command is Get-Process *ups*
Presently it returns this:
PS C:\Users\Admin> Get-Process *ups*
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
57 6 788 3584 25 0.03 3504 usbhid-ups
So no... it doesn't appear upsd is running.
> Is it possible to ssh into the system which runs NUT, and then run command
> "upsc <myups>"?
FYI RDP is the Windows equivalent to SSH, then a PowerShell prompt. I just did so and ran this again:
upsc ups at localhost
Only a blank line echoes to the screen, presumable because the other *usb* processes aren't running.
Note that when I run upsdrvctl start as indicated on pp21 of the NUT User Manual (PDF), I get the conflict error I described earlier:
Can't claim USB device [051d:0003]: libusb0-dll:err [claim_interface] could not
claim interface 0, win error: The requested resource is in use.
Driver failed to start (exit status=1)
Running the .MSI setup on Windows results in a service (daemon) being created, one that starts and maintains an executable named NUT.exe. I'm not sure what that process does. The above error occurs only when the service is running:
PS C:\Users\Admin> Get-Process *nut*
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
71 5 692 3376 16 0.00 3840 nut
When I stop the service (NUT.exe) and run upsdrvctl start, the command immediately echoes this:
Using subdriver: APC HID 0.95
...and then hangs for 45 seconds before returning to a command prompt. No UPS hardware information is printed.
With the service stopped and after running upsdrvctl start, PowerShell returns this:
PS C:\Users\Admin> Get-Process *ups*
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
57 6 788 3584 25 0.03 3504 usbhid-ups
upsd still returns a blank line. I tried adding this to upsd.conf:
LISTEN 127.0.0.1 3493
But the result is still the same.
Running this again:
upsc ups at localhost
Also still results in a blank line.
I tried adding this to ups.conf:
vendorid = 051d
But that didn't help either.
My UPS is an APC Smart-UPS Model C1000, if that helps.
This is starting to get sticky, isn't it?
> Given that a perfect data set is mission critical for you, I would recommend
> having a test rig where you can check that you can handle wall power return
> at every phase of NUT action.
My plan is to plug the server into a separate power source not controlled by the UPS, and then run my tests. If everything is configured correctly, the server will start its shutdown when I pull the plug on the UPS. But at first I'm only going to have it do something simple, like write some text out to a file or sign out of the current user session. Something non-destructive.
> > Sounds good. Next up: how to then send the 'delayed shutdown' command
> > to the UPS hardware itself? Does the driver automatically handle that?
>
> The command upsdrvctl shutdown does this. See man upsdrvctl.
Got it, thanks. Will do. RTFM.
> "Shortly after" means using timers. If you want to preserve the battery
> charge, but not use timers, you need to use a combination of OB and LB and
> set your LB level high using a command such as
>
> upsrw -s battery.charge.low=60 -u upsmaster -p sekret my-ups
My timers/loops/etc will be in the logic of the shutdown program I'll eventually write for this (probably a small .NET Console app). All I need NUT to do is detect the power outage and fire the NOTIFYFLAG ONBATT EXEC event, which in turn will run my program. Once control is handed off, I can do anything I want from there. (Start a loop to re-check power status, send emails, shut down the NAS, make log entries, etc.)
But first I have to get it working :-)
> Roger
Thanks again,
Jeff Bowman
Fairbanks, Alaska
More information about the Nut-upsuser
mailing list