[ltp] hibernate scriptlet to know battery drop during s2ram

Frédéric BOITEUX linux-thinkpad@linux-thinkpad.org
Thu, 31 May 2007 12:41:54 +0200


--MP_=ul.Wd9vF9kzbLxjDYsEjnH
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

	Hello,

  following an e-mail on this list, I've written a small script, a
scriptlet for hibernate, to know how much power is drawn from the
battery between suspend-to-ram's sleep and wake-up.
  I've installed it in /etc/hibernate/scriptlets.d/ directory, made it
executable, and added a line in /etc/hibernate/ram.conf to tell to
use it :

# Enable info about power lost during suspend
BattStat yes

I've tested it on a X31 with Debian Etch, it works, and I=A0get following
results (looking traces in /var/log/hibernate.log) :

=3D=3D Drawn 640 mWh in 1904 seconds, i.e. 1210 mWh/h
=3D=3D Drawn 390 mWh in 1062 seconds, i.e. 1322 mWh/h
=3D=3D Drawn 730 mWh in 2141 seconds, i.e. 1227 mWh/h

Have you similar results ? I=A0guess the power loss is important, isn't
it ?

--=20
Fr=E9d=E9ric Boiteux.

--MP_=ul.Wd9vF9kzbLxjDYsEjnH
Content-Type: application/octet-stream; name=battstat
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=battstat

IyAtKi0gc2ggLSotCiMgdmltOmZ0PXNoOnRzPTg6c3c9NDpub2V0CgpBZGRDb25maWdIYW5kbGVy
IGJhdHRTdGF0T3B0aW9ucwpBZGRDb25maWdIZWxwICJiYXR0c3RhdCA8Ym9vbGVhbj4iICJQcmlu
dCBzdGF0cyBhYm91dCBiYXR0ZXJ5IGxvYWQgaW4gbG9nLiIKCiMgTWF5IG5lZWQgdG8gYmUgbWFk
ZSBjb25maWd1cmFibGUgbGF0ZXIuCmJhdHRfYWNwaWZpbGU9L3Byb2MvYWNwaS9iYXR0ZXJ5L0JB
VDAvc3RhdGUKClJlbWFpbkNhcCgpIHsKICAgIGdyZXAgInJlbWFpbmluZyBjYXBhY2l0eToiICAk
YmF0dF9hY3BpZmlsZSB8IGF3ayAtRic6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