[SOLVED] UPS service fails to start

Hi there,

Trying to setup NUT service to no avail. UPS is APC brand, working perfectly in freeNAS before. Permissions are fine, ups user in dialout group, so we have:
1- Setting port to auto fails with port error

– Unit nut-driver.service has begun starting up.
Jun 13 12:51:28 micropepino systemd-tmpfiles[2476]: Failed to open ‘/etc/tmpfiles.d/nut-run.conf’, ignoring: No such file or directory
Jun 13 12:51:28 micropepino upsdrvctl[2480]: Error: you must specify a port name in ups.conf. Try -h for help.
Jun 13 12:51:28 micropepino upsdrvctl[2480]: Network UPS Tools - APC Smart protocol driver 3.1 (2.7.2)
Jun 13 12:51:28 micropepino upsdrvctl[2480]: APC command table version 3.1
Jun 13 12:51:28 micropepino systemd[1]: nut-driver.service: control process exited, code=exited status=1
Jun 13 12:51:28 micropepino upsdrvctl[2480]: Driver failed to start (exit status=1)
Jun 13 12:51:28 micropepino upsdrvctl[2480]: Network UPS Tools - UPS driver controller 2.7.2
Jun 13 12:51:28 micropepino systemd[1]: Failed to start Network UPS Tools - power device driver controller.
– Subject: Unit nut-driver.service has failed
– Defined-By: systemd
– Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

2- Setting port to /dev/ttyUSB0 fails with

– Unit nut-driver.service has begun starting up.
Jun 13 12:41:24 micropepino systemd-tmpfiles[63832]: Failed to open ‘/etc/tmpfiles.d/nut-run.conf’, ignoring: No such file or directory
Jun 13 12:41:39 micropepino upsdrvctl[63836]: unable to detect an APC Smart protocol UPS on port /dev/ttyUSB0
Jun 13 12:41:39 micropepino upsdrvctl[63836]: check the cabling, port name or model name and try again
Jun 13 12:41:43 micropepino upsdrvctl[63836]: Network UPS Tools - APC Smart protocol driver 3.1 (2.7.2)
Jun 13 12:41:43 micropepino upsdrvctl[63836]: APC command table version 3.1
Jun 13 12:41:43 micropepino systemd[1]: nut-driver.service: control process exited, code=exited status=1
Jun 13 12:41:43 micropepino upsdrvctl[63836]: Driver failed to start (exit status=1)
Jun 13 12:41:43 micropepino upsdrvctl[63836]: Network UPS Tools - UPS driver controller 2.7.2
Jun 13 12:41:43 micropepino systemd[1]: Failed to start Network UPS Tools - power device driver controller.
– Subject: Unit nut-driver.service has failed

Soooo… Any ideas about

@AngeleToR What is the APC model exactly as from a quick looks it seems like the wrong drive selection.
There is a web link presented in the tool tip popup of the “NUT Driver” section that can help with choosing the right driver.
Replicated here for convenience Hardware compatibility list.
It may be that your particular model requires the usbhid-ups driver.

Also note that the UPS / NUT user is actually independent of all system users (see the yellow popup on the NUT Driver selection), ie NUT has it’s own user system mainly for authentication across the network with other NUT servers / clients running on other machines. So it is best to not use a Rockstor user as then there is less potential leakage of system access credentials. The yellow popup indicates this with the phrase “(not a Rockstor user)”.

A comprehensive rundown of all settings is offered in Rockstor’s official doc’s under UPS / NUT Setup.
Ie on the user front “NUT User - N.B. this is not a system user but reserved solely for NUT use.”

Internally NUT has to run some parts of itself as root for hardware access but drops these privileges for all other parts and I think then runs as it’s own nut system user setup by the package installer, would have to check this. The user entered in the NUT configs is just for NUT to NUT authentication which comes in more when you have a NUT server and client arrangement across the network, but as it goes this is how it works locally as well, ie it’s client part authenticates to the backend (server) part only on the same system over the loopback interface.

I’m assuming you are attempting to configure NUT in standalone mode by the way? Otherwise the nut user would have to coincide with that of the other systems involved. NUT is actually quite an impressive piece of software and very flexible but in trying to maintain full flexibility Rockstor’s implementation does leave the user with quite a few questions to answer, but I think with reference to the docs and tool tip popups it is still accessible.

Hope this helps and let us know how you get on with this, I have a couple of APC devices here that use different drives from one another but they are both serial devices as well so also require special cables. At least you have that covered already.

1 Like

Hi @phillxnet,

Thanks for the prompt reply. My UPS is an APC Back-UPS Pro 1500. Thanks to your suggestions, with new ideas and double checking my assumptions made my setup finally work, this is how I did it just for general knowledge. I found the docs to lack some details I will try to cover here, so the doc plus this mini-guide should be enough to get you going:
1- Check the HW list, even if your UPS is an APC, maybe your driver is NOT the obvious one. Mine used usbhid-ups. My bad for making silly asumptions
2- Leave the port in auto, for my USB connected UPS it works fine, if not find the port (/dev/ttyUSB0 is a good option)
3- There is already a user called nut in the system for this service, NO need to create a new one. Forget the ‘monuser’ example in the GUI, just write nut
4- The password field is mandatory, even though the nut user is login-disabled. So go to a root shell and launch

passwd nut

set a new password and enter it in its field. Being local calls maybe this step is not necessary, but doing it works great.

You’re done, enjoy your UPS support, now it would be great being able to setup things like when to shut off the system in case of power failure, or a battery level where you want to shut down. I have a HUGE battery attached to my UPS and prefer the server to go to sleep depending on the juice left in the batts, not a fixed time, but for the time being I’m pretty happy.

Regards, Angel

EDIT: Don’t follow this instructions as they are, read next posts for better ones…

1 Like

@AngeleToR Thanks for the update and glad you got it going, well done.

However I would not recommend your advise on using the nut user as it is still potentially a security risk. The NUT system makes no assumption that this nut user requested during config is a system user and there is better separation if it is not a system user. Did you find that you were unable to use the monuser suggestion or any other non system user as it really is a good idea to not use a system user as it’s credentials are in no way considered as ‘precious’ as normal system users? Also using a system user very much blurs the distinction when in fact it is used completely independently, hence the suggested ‘monuser’ example for those that are not aware of this. And the password you enter there is one you are creating for that user at that time.

This is where I agree with you that the tool tip popup and docs could be better, however. I have on your suggestion opened an issue to address this in the doc repo.

Just my opinion and also removes the requirement to command line it; there is as well additional value in having this user be explicit, in my opinion, given the network nature of NUT.

As per your Shutdown after time period request I completely agree and hopefully it’s just a matter of time before that gets implemented via the Rockstor Web-UI. In fact we have an issue open on this very thing:

Bit more tricky to do percentage of battery as not all UPS’s can reliable indicate / report this unfortunately. But the after a set time thing is a build in for NUT due to the popularity of the request for the same.

This issue in turn links to an existing forum post on the same feature request. I have also added a link to your last post in this thread to that issue so that this thread also might be informed of progress on that issue.

Glad your happy for the time being and chuffed that it’s working for you (though I’d follow the suggestions re user myself :slight_smile:) Also I believe the auto port doesn’t work for serial ports but thankfully USB is becoming more popular even in the slow moving UPS hardware field.

Thank for the reply, followed your instructions, made a new user just for this service and stopped using the system one. Everything works fine, so I really recommend doing it your way.

A couple extra lines in the docs so we users don’t get strayed and that’s it. Sometimes knowing other ways of doing things take you out of the track, my bad :wink:

Extra functions for battery management with the ups will be welcomed with time. At least having the service allows you to tweak under the hood, but will likely crash the UI when you add the functionality in it, one thing at a time.

Regards, Angel

@AngeleToR Thanks for the update and testing.

Well actually there is provision already in place for the timed shutdown by way of a remarked out schedule. NUT can have it’s own scheduler enabled and Rockstor’s implementation does just this. However there is no provision as of yet to modify the default schedules established by Rockstor via the Web-UI. But given the NUT scheduler file used by Rockstor is derived (actually it’s currently just copied as in) from /opt/rockstor/conf/upssched.conf; if you make changes to that file they will in turn be activated in the next NUT/UPS config submit via the Web-UI.

We have a few ‘technical manuals’ for various Rockstor subsystems within this forum under the Wiki section which are intended primarily for developers and advanced users and luckily NUT has one. From this we have:

The remarked out shutdown schedule I mentioned above is in /opt/rockstor/conf/upssched.conf and is instantiated by the last 2 lines of the file with the 3rd from last being a comment to explain the same:

# remark out these 2 lines to shutdown after # seconds on battery
#AT ONBATT * START-TIMER early-shutdown 120
#AT ONLINE * CANCEL-TIMER early-shutdown

currently this is at the very end of that file but that may change in the future of course.

So if you wanted to go with the rather short time frame of 2 minutes (120 seconds), good for testing and smaller battery units, you could just uncomment those 2 lines and re-submit your NUT/UPS config via the Web-UI. The effect is to simply use the scheduler to activate a pre-defined behaviour and email notification established in it’s sister file /opt/rockstor/conf/upssched-cmd which should not require alteration.

There are a few other concerns / considerations / complexities with this method such as what state the UPS itself is left in (likely the same actually) but those are beyond this post really and are no different from the current behaviour.

In open source we are given the tools to effectively ‘shoot our selves in the foot’ so obviously do take care when changing any of these files.

Hope that helps and let us know how you get on.

@AngeleToR Just a notification that the issue opened as a result of your contributions here has now been closed by way of additional wording in the UPS / NUT Setup section of the Official Docs. So thanks for the suggestion and lets hope this aids in a smoother experience for future Rockstor NUT users.

Thanks.

@AngeleToR I’m please to report that as of Rockstor testing channel updates version 3.8.15-3 the referenced issue in this thread:

has now been resolved.