Pythontr

husonet | Tarih: 06.12.2013

Debian Batarya Durumunu Göüntüleme

Debian Batarya Charge Kapasite Monitör İşlemleri

Konsol dan Takip İşlemleri

Kolay bir şekilde her hangi bir araç kullanmadan aşağıdaki dosyaların içeriğine bakarak bir çok veriyi görebilirsiniz.

su - 
ls /sys/class/power_supply/BAT1/
alarm device energy_full_design manufacturer power present status technology uevent voltage_now
cycle_count energy_full energy_now model_name power_now serial_number subsystem type voltage_min_design



cat /sys/class/power_supply/BAT1/energy_full_design
52170000

cat /sys/class/power_supply/BAT1/energy_full
39280000

cat /sys/class/power_supply/BAT1/energy_now
39280000

cat /sys/class/power_supply/BAT1/status
Charging


zenity --info --text `cat /sys/class/power_supply/BAT1/energy_full_design`

ACPI Utilities üzerinden daha kullanıcı dostu sonuçlar alabilirsiniz.

acpi -bi
Battery 0: Charging, 100%, until charged
Battery 0: design capacity 4188 mAh, last full capacity 3153 mAh = 75%


{reklam}

Gerekli Paket
aptitude install acpitool

acpitool -B
Battery #1 : present
Remaining capacity : 39280 mWh, 100.0%, 00:00:00
Design capacity : 52170 mWh
Last full capacity : 39280 mWh, 75.29% of design capacity
Capacity loss : 24.71%
Present rate : 2628 mW
Charging state : Charging
Battery type : Li-ion



Grafiksel Ortam

RRDtool

Gerekli Paketler
aptitude install rrdtool

su - kullanici
mkdir ~/.battery

rrdtool create ~/.battery/battery_capacity.rrd -s 60 DS:capacity:GAUGE:120:0:6000 RRA:MAX:0.5:1:1440 RRA:MAX:0.5:3:5040 RRA:MAX:0.5:5:8928

Ayarlar
vim ~/.battery/update_battery_charge.sh

#!/bin/sh
# Update battery charge level

rrd_file="/home/huso/.battery/battery_capacity.rrd"

charge_now=`cat /sys/class/power_supply/BAT1/energy_now`
charge_now=`expr ${charge_now} / 1000`

rrdtool update ${rrd_file} N:${charge_now}


Çalıştırma yetkisi verelim kullanıcı için
chmod +x ~/.battery/update_battery_charge.sh

vim /etc/rc.local
# update battery charge
watch -n 60 su huso /home/huso/.battery/update_battery_charge.sh > /dev/null &

Şarz durumunu png olarak jpg edelim.
su - huso
vim ~/.battery/graph_battery_charge.sh
#!/bin/sh
# Create "battery charge level" graphs for 1 day, 1 week and 1 month

rrd_file="/home/huso/.battery/battery_capacity.rrd"
destination="/home/huso/.battery/"

for period in "1d" "1w" "1m"
do
/usr/bin/rrdtool graph - \
--imgformat=PNG -N \
--start=-${period} \
--end=-60 \
--title="Battery capacity - ${period}" \
--rigid \
--base=1000 \
--full-size-mode \
--height=210 \
--width=590 \
--upper-limit=6000 \
--lower-limit=0 \
--vertical-label="mAh" \
--slope-mode \
--border 0 \
--color BACK#FFFFFF \
--color GRID#FFFFFF \
--color MGRID#FFFFFF \
DEF:a=${rrd_file}:capacity:MAX \
HRULE:5856#FF0000:"Maximum battery capacity" \
CDEF:b=a,UN,PREV,a,IF \
LINE:b#dddddd \
LINE:a#000FF0FF:"Battery capacity" > ${destination}battery_charge_level_${period}.png
done



Kullanıcıya çalıştırma izni verelim.
chmod +x ~/.battery/graph_battery_charge.sh

Bununla ilgili bir python uygulaması yazılabilir :)