Boinc on Ubuntu 18 LTS not detecting "on battery"

Message boards : Number crunching : Boinc on Ubuntu 18 LTS not detecting "on battery"
Message board moderation

To post messages, you must log in.

AuthorMessage
Profile M_M
Avatar

Send message
Joined: 20 May 04
Posts: 76
Credit: 45,752,966
RAC: 8
Serbia
Message 2014098 - Posted: 3 Oct 2019, 20:11:59 UTC

I have a Ubuntu 18.04.3 LTS, Boinc manager 7.14.2 (x64), I have APC SmartUPS SMT1500i.

Ubuntu correctly detects UPS, apcupsd works ok, reporting status correctly, see below.

When going on battery, it correctly displays battery discharging status etc...

Under Options->Computing Preferances I select "Suspend when computer is on battery", but when goes on battery, Boinc still continue to work. Of course, selected is "Run based on preferances".

Any idea?

P.S. Same works correctly in Windows 10 (dual boot), but not in Ubuntu.

root@ubuntu:~$ apcaccess
APC : 001,028,0732
DATE : 2019-10-03 22:06:38 +0200
HOSTNAME : korisnik-ubuntu
VERSION : 3.14.14 (31 May 2016) debian
UPSNAME : SmartUPS 1500
CABLE : USB Cable
DRIVER : USB UPS Driver
UPSMODE : Stand Alone
STARTTIME: 2019-10-03 21:59:33 +0200
MODEL : Smart-UPS 1500
STATUS : ONLINE
BCHARGE : 90.0 Percent
TIMELEFT : 34.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 2 Minutes
MAXTIME : 0 Seconds
ALARMDEL : No alarm
BATTV : 27.3 Volts
NUMXFERS : 1
XONBATT : 2019-10-03 22:01:15 +0200
TONBATT : 0 Seconds
CUMONBATT: 96 Seconds
XOFFBATT : 2019-10-03 22:02:51 +0200
STATFLAG : 0x05000008
MANDATE : 2014-10-20
NOMBATTV : 24.0 Volts
FIRMWARE : UPS 09.2 / ID=18
END APC : 2019-10-03 22:06:41 +0200
ID: 2014098 · Report as offensive
Profile Keith Myers Special Project $250 donor
Volunteer tester
Avatar

Send message
Joined: 29 Apr 01
Posts: 13164
Credit: 1,160,866,277
RAC: 1,873
United States
Message 2014107 - Posted: 3 Oct 2019, 22:00:44 UTC

Probably should create a new issue at Github on the problem. Obviously, whatever mechanism that the Manager hooks into in the Windows environment is not available in the Linux environment. The signaling that Windows does should be the key. I didn't find anything promising in the code other than where the option is defined. Don't know what process I should be looking for.
Seti@Home classic workunits:20,676 CPU time:74,226 hours

A proud member of the OFA (Old Farts Association)
ID: 2014107 · Report as offensive
Profile Keith Myers Special Project $250 donor
Volunteer tester
Avatar

Send message
Joined: 29 Apr 01
Posts: 13164
Credit: 1,160,866,277
RAC: 1,873
United States
Message 2014117 - Posted: 3 Oct 2019, 23:35:32 UTC

I found an existing open issue and added a comment. Could you look at it and add your observations or corrections as to what is observed and wanted.
https://github.com/BOINC/boinc/issues/1471#issuecomment-538165443
Seti@Home classic workunits:20,676 CPU time:74,226 hours

A proud member of the OFA (Old Farts Association)
ID: 2014117 · Report as offensive
Richard Haselgrove Project Donor
Volunteer tester

Send message
Joined: 4 Jul 99
Posts: 14686
Credit: 200,643,578
RAC: 874
United Kingdom
Message 2014135 - Posted: 4 Oct 2019, 9:17:49 UTC
Last modified: 4 Oct 2019, 9:18:16 UTC

Please note that the OP is referring to an APC UPS. I've used those in connection with Windows servers, and at the time I did so (several years ago), they required bespoke OEM software and an external hard-wired control connection (originally RS232 serial, later USB) to implement status monitoring and initiate system shutdown when the remaining battery level reached a critical level.

BOINC's battery monitoring was implemented primarily for laptops, where the battery and its monitoring software are integrated into the operating system at build time by the manufacturer.

@ Keith - your report at GitHub mentions that you've confirmed that the Windows implementation works. May I ask whether that is the same 'external OEM UPS' use case, or the internal laptop battery case? I'm not 100% certain that they use the same control software APIs.
ID: 2014135 · Report as offensive
Ian&Steve C.
Avatar

Send message
Joined: 28 Sep 99
Posts: 4267
Credit: 1,282,604,591
RAC: 6,640
United States
Message 2014140 - Posted: 4 Oct 2019, 10:08:44 UTC - in response to Message 2014135.  

I had the same impression, that the “on battery” option was aimed at laptop batteries, not an external UPS.
Seti@Home classic workunits: 29,492 CPU time: 134,419 hours

ID: 2014140 · Report as offensive
Profile Keith Myers Special Project $250 donor
Volunteer tester
Avatar

Send message
Joined: 29 Apr 01
Posts: 13164
Credit: 1,160,866,277
RAC: 1,873
United States
Message 2014154 - Posted: 4 Oct 2019, 15:08:17 UTC - in response to Message 2014135.  
Last modified: 4 Oct 2019, 15:09:11 UTC

Please note that the OP is referring to an APC UPS. I've used those in connection with Windows servers, and at the time I did so (several years ago), they required bespoke OEM software and an external hard-wired control connection (originally RS232 serial, later USB) to implement status monitoring and initiate system shutdown when the remaining battery level reached a critical level.

BOINC's battery monitoring was implemented primarily for laptops, where the battery and its monitoring software are integrated into the operating system at build time by the manufacturer.

@ Keith - your report at GitHub mentions that you've confirmed that the Windows implementation works. May I ask whether that is the same 'external OEM UPS' use case, or the internal laptop battery case? I'm not 100% certain that they use the same control software APIs.

The OP is using an APC UPS model SMT-1500i. I am using mostly APC Backups 1500G's, SMT1500C's or a SMT2200C. All use the USB connection via the apcupsd daemon. The upowerd daemon controls monitoring of all battery powered devices. This is what is used to detect whether the device is on battery or not.

keith@Serenity:~$ upower -d
Device: /org/freedesktop/UPower/devices/ups_hiddev0
  native-path:          /sys/devices/pci0000:00/0000:00:08.1/0000:0d:00.3/usb9/9-4/9-4:1.0/usbmisc/hiddev0
  vendor:               American Power Conversion 
  model:                Smart-UPS_1500 FW:UPS 03.5 / ID=1015
  serial:               3S1831X12519    
  power supply:         yes
  updated:              Fri 04 Oct 2019 08:04:57 AM PDT (6 seconds ago)
  has history:          yes
  has statistics:       yes
  ups
    present:             yes
    state:               fully-charged
    warning-level:       none
    time to empty:       7.2 minutes
    percentage:          100%
    icon-name:          'battery-full-charged-symbolic'

Device: /org/freedesktop/UPower/devices/keyboard_hidpp_battery_0
  native-path:          hidpp_battery_0
  model:                K520
  serial:               2011-1c-ea-e8-7f
  power supply:         no
  updated:              Fri 04 Oct 2019 08:04:03 AM PDT (60 seconds ago)
  has history:          yes
  has statistics:       yes
  keyboard
    present:             yes
    rechargeable:        yes
    state:               discharging
    warning-level:       none
    battery-level:       high
    percentage:          70%
    icon-name:          'battery-full-symbolic'

Device: /org/freedesktop/UPower/devices/mouse_hidpp_battery_1
  native-path:          hidpp_battery_1
  model:                Wireless Mouse M510
  serial:               4051-4d-87-b1-46
  power supply:         no
  updated:              Fri 04 Oct 2019 08:03:12 AM PDT (111 seconds ago)
  has history:          yes
  has statistics:       yes
  mouse
    present:             yes
    rechargeable:        yes
    state:               discharging
    warning-level:       none
    battery-level:       normal
    percentage:          55%
    icon-name:          'battery-good-symbolic'

Device: /org/freedesktop/UPower/devices/DisplayDevice
  power supply:         yes
  updated:              Fri 04 Oct 2019 08:04:57 AM PDT (6 seconds ago)
  has history:          no
  has statistics:       no
  ups
    present:             yes
    state:               fully-charged
    warning-level:       none
    time to empty:       7.2 minutes
    percentage:          100%
    icon-name:          'battery-full-charged-symbolic'

Daemon:
  daemon-version:  0.99.7
  on-battery:      no
  lid-is-closed:   no
  lid-is-present:  no
  critical-action: PowerOff
keith@Serenity:~$ 



This is used to detect whether a laptop is on battery or has the lid closed and is in hibernation for example. So the same type of mechanism that works for detecting on battery status in Windows is available in Linux. What I need to do is find out which module in the client controls this behavior for Windows and duplicate it for Linux.
Seti@Home classic workunits:20,676 CPU time:74,226 hours

A proud member of the OFA (Old Farts Association)
ID: 2014154 · Report as offensive
Profile Keith Myers Special Project $250 donor
Volunteer tester
Avatar

Send message
Joined: 29 Apr 01
Posts: 13164
Credit: 1,160,866,277
RAC: 1,873
United States
Message 2014155 - Posted: 4 Oct 2019, 15:15:21 UTC
Last modified: 4 Oct 2019, 15:17:39 UTC

To clarify, the monitoring of the UPS status is done by the apcupsd daemon via the USB connection. When the the conf file settings for that daemon are tripped, that signals the upowerd daemon to initialize the host shutdown based on the conf file parameters like time remaining on battery. That mechanism works fine in Linux. But preferably, we would like to see the client shed computing load to preserve more of the battery time remaining during a longer power outage that is past the normal load runtime of the battery. The daemons would still have final control over shutting the system down once the UPS battery can't sustain the system load so the that the host is powered down gracefully and filesystem integrity is maintained.

The OP says that a Windows host correctly observes the setting in the Manager.
P.S. Same works correctly in Windows 10 (dual boot), but not in Ubuntu.

Seti@Home classic workunits:20,676 CPU time:74,226 hours

A proud member of the OFA (Old Farts Association)
ID: 2014155 · Report as offensive
Profile M_M
Avatar

Send message
Joined: 20 May 04
Posts: 76
Credit: 45,752,966
RAC: 8
Serbia
Message 2014175 - Posted: 4 Oct 2019, 19:55:07 UTC - in response to Message 2014155.  

seems that upower correctly detect when the power is on-battery, but Boinc still doesn't react...

power on-line (idle):
user@ubuntu:~$ upower -d
Device: /org/freedesktop/UPower/devices/ups_hiddev0
native-path: /sys/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-5/1-5:1.0/usbmisc/hiddev0
vendor: American Power Conversion
model: Smart-UPS 1500 FW:UPS 09.2 / ID=18
serial: 3S1442X06625
power supply: yes
updated: петак, 04. октобар 2019. 21:47:45 CEST (22 seconds ago)
has history: yes
has statistics: yes
ups
present: yes
state: fully-charged
warning-level: none
time to empty: 1,5 hours
percentage: 100%

icon-name: 'battery-full-charged-symbolic'

on UPS power (idle):
user@ubuntu:~$ upower -d
Device: /org/freedesktop/UPower/devices/ups_hiddev0
native-path: /sys/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-5/1-5:1.0/usbmisc/hiddev0
vendor: American Power Conversion
model: Smart-UPS 1500 FW:UPS 09.2 / ID=18
serial: 3S1442X06625
power supply: yes
updated: петак, 04. октобар 2019. 21:50:45 CEST (12 seconds ago)
has history: yes
has statistics: yes
ups
present: yes
state: discharging
warning-level: discharging
time to empty: 1,5 hours
percentage: 96%

icon-name: 'battery-full-symbolic'
ID: 2014175 · Report as offensive
Profile Keith Myers Special Project $250 donor
Volunteer tester
Avatar

Send message
Joined: 29 Apr 01
Posts: 13164
Credit: 1,160,866,277
RAC: 1,873
United States
Message 2014182 - Posted: 4 Oct 2019, 21:41:37 UTC

Yes, that is what I concluded also. This would be the proper interface to interrogate.
upower -i /org/freedesktop/UPower/devices/ups_hiddev0

I have finally found where the client checks for a host being on battery. Unfortunately the code is about 5 years out of date and is interrogating interfaces that no longer exist in modern Linux distros. The code is in the /client/hostinfo_unix.cpp file. That is the file that needs to be updated to interrogate the upower interface for the status of whether the system is on UPS battery.

Now all we have to do if find a Linux programmer that can write the code. That will be the hard part.
Seti@Home classic workunits:20,676 CPU time:74,226 hours

A proud member of the OFA (Old Farts Association)
ID: 2014182 · Report as offensive
Profile M_M
Avatar

Send message
Joined: 20 May 04
Posts: 76
Credit: 45,752,966
RAC: 8
Serbia
Message 2014240 - Posted: 5 Oct 2019, 6:40:13 UTC

Thanks Keith.

I see you already also reported to Github, and you started discussion on Boinc message board.
Please also report in Boinc message board your finding where in code this should be fixed, and we shall keep our fingers crossed that it shall be fixed soon... :)
ID: 2014240 · Report as offensive
Profile Keith Myers Special Project $250 donor
Volunteer tester
Avatar

Send message
Joined: 29 Apr 01
Posts: 13164
Credit: 1,160,866,277
RAC: 1,873
United States
Message 2014242 - Posted: 5 Oct 2019, 7:32:14 UTC - in response to Message 2014240.  

I have asked for help from the upower developers on Launchpad. I also sent a DM to one of our BOINC developers asking for assistance over at Discord BOINC channel.
Seti@Home classic workunits:20,676 CPU time:74,226 hours

A proud member of the OFA (Old Farts Association)
ID: 2014242 · Report as offensive
Profile Keith Myers Special Project $250 donor
Volunteer tester
Avatar

Send message
Joined: 29 Apr 01
Posts: 13164
Credit: 1,160,866,277
RAC: 1,873
United States
Message 2016181 - Posted: 21 Oct 2019, 20:04:55 UTC

Well I got ignored on the Upower Launchpad interface. My post was expired after no activity for 15 days. So no help there. I need a programmer to figure out which interface to look at. I am totally confused now. My research shows that the dbus messaging system notifies of a change in a device state like hiddev0 changing from charging to discharging. So is that the interface we need to look at?

https://upower.freedesktop.org/docs/Device.html
Seti@Home classic workunits:20,676 CPU time:74,226 hours

A proud member of the OFA (Old Farts Association)
ID: 2016181 · Report as offensive
Profile Keith Myers Special Project $250 donor
Volunteer tester
Avatar

Send message
Joined: 29 Apr 01
Posts: 13164
Credit: 1,160,866,277
RAC: 1,873
United States
Message 2016501 - Posted: 24 Oct 2019, 18:58:15 UTC

So what do I need to do to get some traction on this issue in the Linux client? Works on Windows but does not in Linux.
Seti@Home classic workunits:20,676 CPU time:74,226 hours

A proud member of the OFA (Old Farts Association)
ID: 2016501 · Report as offensive

Message boards : Number crunching : Boinc on Ubuntu 18 LTS not detecting "on battery"


 
©2025 University of California
 
SETI@home and Astropulse are funded by grants from the National Science Foundation, NASA, and donations from SETI@home volunteers. AstroPulse is funded in part by the NSF through grant AST-0307956.