Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I changed my batteries and the battery statistics of the GNOME manager got skewed. Where would the files having the battery statistics be?

share|improve this question

3 Answers 3

up vote 9 down vote accepted
+50

Edit: Ubuntu now uses freedesktop's UPower power-manager. After looking through the source for UPower it looks like the persistent database where the history is stored is defined as history-%s-%s.dat. I searched through my filesystem and my database names are:

./var/lib/upower/history-time-empty-DELL_KP4377-57-22096.dat
./var/lib/upower/history-time-full-DELL_KP4377-57-22096.dat
./var/lib/upower/history-charge-DELL_KP4377-57-22096.dat
./var/lib/upower/history-rate-DELL_KP4377-57-22096.dat

Your file names will obviously be different but they should be in the same directory (/var/lib/upower/)regardless. These four files, despite being ".dat" files are really just human readable text documents with the history. I'd say back up these files, then either delete them or delete their contents and you should be good to go! Let me know how it works.

Original answer:

Good question. One would think that gnome-power-manager would have it's own log file somewhere for storing it--I can't find anything of the sort however.

It looks like most of the information it reads about the battery comes from acpi via /proc/acpi/battery/BAT0/info (my path is "BAT0" yours might be different from yours) For example, here's mine:

present:                 yes
design capacity:         5200 mAh
last full capacity:      3665 mAh
battery technology:      rechargeable
design voltage:          11100 mV
design capacity warning: 520 mAh
design capacity low:     157 mAh
cycle count:          0
capacity granularity 1:  52 mAh
capacity granularity 2:  52 mAh
model number:            DELL KP4377
serial number:           22096
battery type:            LION
OEM info:                DP-SDI52

But other than cycle count and last full capacity there isn't a lot of history information here, so there must be another file somewhere that gnome-power-manager is using for the history information. It's possible that rather than storing it in it's own file it is using some larger database that gnome uses for a variety of settings... I suppose it's also possible that ACPI might store the history information somewhere as well, although once again there doesn't seem to be any documentation for this.

If they exist, you might get some more attention for your question by people who know gnome-power-manager better if you add some more specific tags, ie. "gnome-power-manager", "acpi", etc. Sorry I can't help you much, good luck!

share|improve this answer
    
just saw here, bugs.archlinux.org/task/16970, that the files used to be stored as .cvs files in ~/.gnome2/gnome-power-manager/, obviously they aren't there anymore but at least it hints that they might still be .cvs files. Also, the poster there found out that information by asking at #gnome on irc.gnome.org, so you could try that to find out where the files are now. –  adempewolff May 21 '12 at 5:54
    
This is quite interesting that the battery information on gnome-power manager is now stored in a persistent database. I wonder how the graphs for accuracy of battery life prediction are produced. –  viyyer May 21 '12 at 13:22
    
My mistake, Ubuntu actually uses freedesktop's UPower power manager now rather than gnome-power manager, after looking through the source of UPower I think I've found the persistent history database. I will update my answer with the results. –  adempewolff May 21 '12 at 17:30
1  
also, not particularly relevant now that we've found the history databases, but I was wrong about power-manager getting the information from /proc/acpi/battery/BAT0/info, it actually seems to get it from /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0 –  adempewolff May 21 '12 at 18:01

Just tried the delete-files approach. I assumed that since upowerd was still running, these files would be automatically regenerated, but they weren't – nor were they there immediately after rebooting.

Initially, after deleting /var/lib/upower/*.dat, gnome-power-statistics just ran as a blank GUI window with no content, but returned to its usual self after the reboot. Strangely enough, it was showing a couple of minutes of battery history from since the reboot without anything having recreated the /var/lib/upower data files, and I couldn't find anywhere else in the filesystem where it could have been storing the data (there were no file descriptors for upowerd or gnome-power-statistics pointing to anywhere on the filesystem, just kernel sockets).

I assume that something other than upower must have a short-term log of this data, which is what was being displayed in gnome-power-statistics. Running "upower -d" also outputs history points for charge and discharge rate when the data files don't exist, so presumably it can also access the same data source that is independent of the /var/lib/upower history files. upowerd appears to recreate the data files after about ten minutes post-deletion, so perhaps these are required to store data points over a longer period of time.

share|improve this answer
1  
Just an addendum: /sys/class/power_supply is a useful symlink for /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply (as in adempewolff's comment above) –  Harry Willis May 21 '12 at 21:30
    
It might just hold the data points in memory, or write them to swap space before writing them to disk every 10 minutes. I don't really see why, but I can't find any other files in UPower's directories resembling a log... –  adempewolff May 22 '12 at 3:03
1  
also, given the results of your testing, I think deleting the files should meet @viyyer's needs--it will delete all history of the old battery that it messing his statistics up. Alternately, he could go into the files and only delete the data points from prior to the new battery. –  adempewolff May 22 '12 at 3:13

Harry, your right. Don't you remember Ubuntu asking you to plug in the charger before installing? That's because it's taking a snapshot at how much the battery can hold. If you want to reset the power-manager, I presume you're going to need to re-install Ubuntu or try a power-cycle. In other words, let your battery die out and then turn it on at the same moment you plug in the charger, and keep it on until it hits the 100%.

share|improve this answer
2  
I don't know if I believe this. I believe it asks you to plug in the charger before installing because running out of battery in the middle of installation, or god forbid in the middle of partitioning, would at best leave you with an unusable Ubuntu and at worst fry the other OSes partition tables. –  adempewolff May 27 '12 at 8:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.