Thank you VERY much, Roger, for your detailed explanations. I'm going to choose to heed your warning.> On Thu, 8 Sep 2016, Jeff Bowman wrote: > > > 1. CLI error: I get an error when running ?upsdrvctl start?: ?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.?The solution to this was easy: the conflict occurred because the service was running. Apparently NUT.exe on Windows runs all of the preparatory commands, one of which is 'upsdrvctl start.'> > 2. Event log errors: As noted the service starts fine, but I?m getting > > these two errors on service stop--?Error stopping upsd (2)? and ?Error > stopping upsmon (2).?This one is still unresolved. Is there a detailed log file somewhere?> It's assumed in the NUT world that you are running a server which is a) to be > shut down when wall power fails for too long, and which is b) to be brought > back into service automatically when wall power finally returns. > > a) is shutting down the server using the SHUTDOWNCMD > > b) is more subtle. After, and I repeat _after_, the server has shut down, > the UPS unit must be put into a state where is can react to the return of > wall power, and signal the server to restart. A UPS which is left beeping > cannot do that. To get the server going again it is necessary to perform a > "delayed shutdown" of the UPS unit itself. This might be some 30 seconds > after the server has shut down. Once the UPS unit is itself shutdown, it > will react to a return of wall power by applying power supply to the server, > and the server will, if the BIOS is set up correctly, power up, and resume > duty. > > The use of the term "shutdown" for both the server and the UPS unit is not > the happiest choice, but we live with it.I've decided not to seek the server restart part of b). Either I or someone else will manually turn the server on once it's determined that power has reliably resumed. That said, is there a way to manually poll the driver for UPS/power line status? I ask because I can foresee a scenario such as this: - I am offsite - Power event occurs - Server sends 'delayed shutdown' signal to UPS (as described, thank you) - Server shuts down - UPS shuts down - Power resumes - I contact someone onsite - With me on the phone, he manually powers the server on (a ten-minute startup sequence occurs before the OS is fully loaded) - He leaves the area (he won't be able to sit there on his thumbs for the full startup time) - Power event occurs again, during the startup sequence and before NUT can begin monitoring Of course the odds of all this actually occurring are slim, but I have mission-critical files that bear risk of corruption in the event of a plug-pull. I can't afford to take chances. If it's 0.001% it's 100%. So I'd like to be able to remote in and check the status to make sure everything is OK. If not, then I can manually run my shutdown script/process and start the cycle all over again. (Note: running 'upsc ups at localhost' echoes only a blank line to the screen, as do both 'upsmon' and 'upsd.')> There are two schools of thought for managing wall power loss. > > Optimist: Keep going as long as possible on battery and turn off the server > when the low-battery signal is received. No timer needed, This is the > simplest approach. > > Pessimist: Whenever OB is received, start timers to shut down the server > after a short interval. Expect wall power to return and then fail again. > Hope that the battery will recover enough between failures for the next > shutdown. This is for people with unreliable wall power supplies. Using > timers is more complicated. > > If you want simplicity, use the LB state as your guide, and set up your > upsmon.conf to react to it. ( I don't do this, so the following is > speculative. ) In upsmon.conf set > > NOTIFYMSG LOWBATT "Power failure - system is shutting down" > NOTIFYFLAG LOWBATT SYSLOG+EXEC+WALL > NOTIFYCMD /path/to/your/system-shutdown-batch-filePerfect. I'm going to prefer the Pessimist approach, but with simplicity (no NUT timers). I'll handle timers/loops/checks and other logic from within my shutdown script/process. So to confirm my understanding: You're stating that I'll want to do this via NOTIFYFLAG ONBATT SYSLOG+EXEC and NOTIFYCMD (no WALL in Windows), using that combination to run my script/process and skipping SHUTDOWNCMD altogether--correct? Sounds good. Next up: how to then send the 'delayed shutdown' command to the UPS hardware itself? Does the driver automatically handle that? I'd like everything to occur shortly after the OB signal, so as to preserve battery as much as possible.> You don't use upssched. > > If you want timers, look at http://rogerprice.org/NUT.html which contains a > fully worked example. It's more complicated. You have been warned.That's quite a writeup. But you're correct--I'll pass.> RogerThanks again, Jeff Bowman Fairbanks, Alaska
On Thu, 8 Sep 2016, Jeff Bowman wrote:> That said, is there a way to manually poll the driver for UPS/power line > status? I ask because I can foresee a scenario such as this:...> So I'd like to be able to remote in and check the status to make sure > everything is OK. If not, then I can manually run my shutdown > script/process and start the cycle all over again. (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? Is it possible to ssh into the system which runs NUT, and then run command "upsc <myups>"?> So to confirm my understanding: You're stating that I'll want to do this > via NOTIFYFLAG ONBATT SYSLOG+EXEC and NOTIFYCMD (no WALL in Windows), > using that combination to run my script/process and skipping SHUTDOWNCMD > altogether--correct?Remember that I don't use windows or the LB status so my suggestion is only a suggestion. Above all, you need to test thoroughly with your system and your UPS. 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.> 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.> I'd like everything to occur shortly after the OB signal, so as to > preserve battery as much as possible."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 Roger
> 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-upsMy 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 :-)> RogerThanks again, Jeff Bowman Fairbanks, Alaska