Skip to content

apcupsd-ups driver race condition #2007

@tbsky

Description

@tbsky

Hi:
we have more and more new APC ups which need to use nut apcupsd-ups driver (with serial modbus supported in apcupsd).
they work fine under nut 2.7.4, but it is not good under nut 2.8.0.

the difference is that the default nut apcupsd-ups driver polling interval is 60 seconds under 2.7.4 and change to 2 seconds under 2.8.0. the default normal polling interval settings for apcupsd is also 60 seconds. so nut 2.7.4 seems co-exist with apcupsd well.

we need to record the ups data like "ups.load" history so we use command "upsc myups" to read the data. and we found sometimes there are no "ups.load" data under 2.8.0. I write a little script and try to execute "upsc myups" every second and found it will fail to read the full data about 60 seconds interval. the normal full data for "upsc myups" is like below:

battery.charge: 100.0
battery.charge.low: 5
battery.date: 2021-11-10
battery.runtime: 1440.0
battery.runtime.low: 180
battery.voltage: 26.2
device.mfr: APC
device.type: ups
driver.name: apcupsd-ups
driver.parameter.pollinterval: 2
driver.parameter.port: localhost
driver.parameter.synchronous: auto
driver.version: 2.8.0
driver.version.internal: 0.6
input.frequency: 59.8
input.transfer.reason: Line voltage notch or spike
input.voltage: 105.7
output.current: 4.03
output.frequency: 59.8
output.voltage: 121.5
output.voltage.nominal: 120
power.percent: 33.9
ups.date: 2023-08-02
ups.delay.shutdown: 0
ups.delay.start: 0
ups.firmware: UPS 04.4
ups.firmware.aux: 00.5
ups.id: APC UPS
ups.load: 47.1
ups.mfr: APC
ups.mfr.date: 2021-11-10
ups.model: Smart-UPS 1500
ups.power.nominal: 1440
ups.realpower.nominal: 1000.0
ups.serial: AS2145160441
ups.status: BOOST OL
ups.temperature: 34.0
ups.test.result: OK
ups.time: 17:46:18

===================================================

when there is racing, "upsc myups" returns partial data like below:

battery.charge: 100.0
battery.runtime: 1440.0
device.mfr: APC
device.type: ups
driver.name: apcupsd-ups
driver.parameter.pollinterval: 2
driver.parameter.port: localhost
driver.parameter.synchronous: auto
driver.version: 2.8.0
driver.version.internal: 0.6
ups.mfr: APC
ups.model: Smart-UPS 1500
ups.power.nominal: 1440
ups.realpower.nominal: 1000.0
ups.status: BOOST OL

===================================================

but the "apcaccess" of apcupsd is always correct like below:

APC      : 001,042,1078
DATE     : 2023-08-02 17:56:48 +0800
HOSTNAME : love-1.nhs.hcc.edu.tw
VERSION  : 3.14.14 (31 May 2016) redhat
UPSNAME  : APC UPS
CABLE    : Custom Cable Smart
DRIVER   : MODBUS UPS Driver
UPSMODE  : Stand Alone
STARTTIME: 2023-02-18 23:22:30 +0800
MODEL    : Smart-UPS 1500
STATUS   : BOOST ONLINE
LINEV    : 105.5 Volts
LOADPCT  : 46.6 Percent
LOADAPNT : 33.6 Percent
BCHARGE  : 100.0 Percent
TIMELEFT : 24.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
OUTPUTV  : 121.4 Volts
DWAKE    : 0 Seconds
DSHUTD   : 0 Seconds
ITEMP    : 34.0 C
BATTV    : 26.2 Volts
LINEFREQ : 59.8 Hz
OUTCURNT : 4.03 Amps
LASTXFER : Line voltage notch or spike
NUMXFERS : 24
XONBATT  : 2023-07-29 15:35:27 +0800
TONBATT  : 0 Seconds
CUMONBATT: 1079 Seconds
XOFFBATT : 2023-07-29 15:35:36 +0800
LASTSTEST: 2023-07-25 15:53:35 +0800
SELFTEST : OK
STATFLAG : 0x0500000C
MANDATE  : 2021-11-10
SERIALNO : AS2145160441
BATTDATE : 2021-11-10
NOMOUTV  : 120 Volts
NOMPOWER : 1000 Watts
NOMAPNT  : 1440 VA
FIRMWARE : UPS 04.4 / 00.5
END APC  : 2023-08-02 17:57:04 +0800

===================================================

I found I can not set the apcupsd-ups polling interval back to "60" seconds under nut 2.8.0. the maximum value it will use is "10" seconds. current I can only set the polling interval to "7" seconds, since "7" is a prime number. it will has better common multiple with "60" seconds default with apcupsd.

Metadata

Metadata

Assignees

No one assigned

    Labels

    APCbugimpacts-release-2.8.0Issues reported against NUT release 2.8.0 (maybe vanilla or with minor packaging tweaks)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions