Public bug reported:

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)

** Affects: battery-stats (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug cosmic

** Description changed:

  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
+     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)
-      echo $d; 
-      break; 
-   fi; 
- done 
+ 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)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1814886

Title:
  log is filled with warnings, causing graph generation to fail

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/battery-stats/+bug/1814886/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to