How to change battery low for ups in nut server

ups

(Guus) #1

NethServer Version: 7.6.1810
Module: nut
How can I change the value battery.low in the config of NUT for the Back-UPS ES/CyberFort 350. Battery doesn’t have enough energy left to shutdown 2 nethserver machines in the vmware environment at battery.low=10

Thanks in advance
Guus.


(Marc) #2

Haven’t tried and don’t know if it needs to be scheduled to remain at each startup:

upsrw -s battery.charge.low=20 -u `config getprop nut-server User` -p `config getprop nut-server Password` `config getprop nut-server Ups`

(Guus) #3

Hello marc,
followed your instruction which results in an error:

[root@yz1fs ~]# upsrw -s battery.charge.low=20 -u config getprop nut-server User -p config getprop nut-server Password config getprop nut-server Ups
Unexpected response from upsd: ERR ACCESS-DENIED
[root@yz1fs ~]#

I’ve tried the getprop commands one after another and found out that only the Password returns an empty string. User=upsmon Ups=UPS

Any suggestions?


(Marc) #4

The password is set by nethserver-nut-conf action. If neither the command nor the server-manger ups section show a password, you can check if it’s set on /etc/ups/upsd.users file (e.g. tail -4 /etc/ups/upsd.users).


(Guus) #5

in upsd.users there is the pasword presented as displayed in the screen under /Configuration/UPS there the slave password is shown which is the same as in the upsd.users file.

The term for password in the instruction is written in lower cases, so I tried the command as follows:

upsrw -s battery.charge.low=50 -u config getprop nut-server User -p config getprop nut-server password config getprop nut-server Ups
Network UPS Tools upsrw 2.7.2

usage: upsrw [-h]
upsrw [-s ] [-u ] [-p ]

Demo program to set variables within UPS hardware.

-h display this help text
-s specify variable to be changed
use -s VAR=VALUE to avoid prompting for value
-u set username for command authentication
-p set password for command authentication

UPS identifier - [@[:]]

Call without -s to show all possible read/write variables.

So now the interesting question is how to check whether the variable has been changed.


(Marc) #6

The command response showing the help section implies it failed.
The password term of config getprop command comes from nethserver’s e-smith database and starts with an uppercase letter.

I’m no expert on nut, but as the password for upsmon user is present on upsd.users file I will suggest to add it to the e-smith (nethserver) database.

First check it is not already set:

config getprop nut-server Password

If empty, you can set it with the value from upsd.users file (replace xxxxxxxxx with the proper password):

config setprop nut-server Password xxxxxxxxx

You can check available UPS settings with:

upsrw -u `config getprop nut-server User` -p `config getprop nut-server Password` `config getprop nut-server Ups`

or directly with the known values (xxxxxxxxx represent the password):

upsrw -u upsmon -p xxxxxxxxx UPS

Same goes for chaning settings, were the paremeter -s is added.


(Guus) #7

Password was empty so changed the Password,

check gives expected output:
upsrw -u upsmon -p 676200624863591 UPS
[battery.charge.low]
Remaining battery level when UPS switches to LB (percent)
Type: STRING
Maximum length: 10
Value: 10

Nevertheless no succes in changing the battery.charge.low value:

upsrw -s battery.charge.value=50 -u upsmon -p 676200624863591 UPS
Unexpected response from upsd: ERR ACCESS-DENIED


(Marc) #8

From the error I guess the user has no admin privileges, and a new user might need to be added (with a custom template) to upsd.users file.

EDIT: here is an untested example. Some steps could be missing (see nut manual, for example to set tcp-wrappers edit hosts.allow/deny, restarting service…), and the password could be randomly generated with a script:

mkdir -p /etc/e-smith/templates-custom/etc/ups/upsd.users/
cat << EOF > /etc/e-smith/templates-custom/etc/ups/upsd.users/21admin

[admin]
    password = supersecretpassword
    actions = SET
    instcmds = ALL
EOF

signal-event nethserver-nut-update

More info:
https://networkupstools.org/docs/man/upsd.users.html
https://networkupstools.org/docs/user-manual.chunked/ar01s09.html

NUT administrative user definitions should be used in conjunction with TCP Wrappers.


(Guus) #9

This worked, battery.low.level changed to 50%

First set the admin user in custom template
then changed the value with command:
upsrw -s battery.charge.low=50 -u admin -p supersecretpassword UPS

Outcome:
upsrw -u config getprop nut-server User -p config getprop nut-server Password config getprop nut-server Ups
[battery.charge.low]
Remaining battery level when UPS switches to LB (percent)
Type: STRING
Maximum length: 10
Value: 50

thanks