log is filled with warnings, causing graph generation to fail

Bug #1814886 reported by joosteto
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
battery-stats (Ubuntu)
New
Undecided
Unassigned

Bug Description

battery-graph shows empty graphs.

Cause: the battery-log on my system looks like this:

No power supply found
1549454931 94.23 1 2019/02/06 13:08:51 -
No power supply found
1549454991 94.57 1 2019/02/06 13:09:51 -

This is because the power adapter in /sys/class/power_supply is called slightly different from what battery-stat-collector excpects:

$ ls /sys/class/power_supply
AC0 BAT0

And the relevant section from /usr/sbin/battery-stats-collector :
    if [ -f /sys/class/power_supply/AC/online ]; then
        aconline=$(cat /sys/class/power_supply/AC/online)
    elif [ -f /sys/class/power_supply/ACAD/online ]; then
        aconline=$(cat /sys/class/power_supply/ACAD/online)
    elif [ -f /sys/class/power_supply/ADP1/online ]; then
        aconline=$(cat /sys/class/power_supply/ADP1/online)
    else
        echo "No power supply found"
    fi

Just removing the else and echo statements at least makes the 'No power supply found' warning messages to go away from the log, and battery-graph works again.

Another fix would be to add AC0 to the tested directories, for example by replacing all of the tests above by:

for d in /sys/class/power_supply/{AC,AD}*/online; do
  if test -f $d; then
     aconline=$(cat $d)
     break;
  fi;
done

See also:
https://github.com/petterreinholdtsen/battery-stats/issues/23

Thanks,

ProblemType: Bug
DistroRelease: Ubuntu 18.10
Package: battery-stats 0.5.6-1 [modified: usr/sbin/battery-stats-collector]
ProcVersionSignature: Ubuntu 4.18.0-13.14-generic 4.18.17
Uname: Linux 4.18.0-13-generic x86_64
ApportVersion: 2.20.10-0ubuntu13.1
Architecture: amd64
CurrentDesktop: i3
Date: Wed Feb 6 13:07:41 2019
InstallationDate: Installed on 2019-01-16 (20 days ago)
InstallationMedia: Ubuntu 18.10 "Cosmic Cuttlefish" - Release amd64 (20181017.3)
SourcePackage: battery-stats
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
joosteto (joosteto) wrote :
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.