Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / acpi-battery @ 8f2bcef9

Historique | Voir | Annoter | Télécharger (2,01 ko)

1
#!/bin/sh
2
#
3
# Plugin to graph battery capacity.
4
#
5
# Parameters:
6
#
7
# 	acpi      - Override path to acpi program
8
#
9
#
10
# $Log$
11
# Revision 1.1  2007/03/14 19:52:10  anarcat
12
# ACPI-Battery plugin, framework copied from acpi plugin
13
#
14
#
15
# Expected content of /proc/acpi/battery/BAT0/info:
16
# present:                 yes
17
# design capacity:         47520 mWh
18
# last full capacity:      37650 mWh
19
# battery technology:      rechargeable
20
# design voltage:          10800 mV
21
# design capacity warning: 2376 mWh
22
# design capacity low:     475 mWh
23
# capacity granularity 1:  1 mWh
24
# capacity granularity 2:  1 mWh
25
# model number:            IBM-08K8039
26
# serial number:             155
27
# battery type:            LION
28
# OEM info:                Panasonic
29
#%# family=auto
30
#%# capabilities=autoconf
31

    
32
if [ "$1" = "autoconf" ]; then
33
	if grep -q 'present.*yes' /proc/acpi/battery/*/info > /dev/null 2>&1; then
34
		echo yes
35
		exit 0
36
	else
37
		echo "no (battery not detected)"
38
		exit 1
39
	fi
40
fi
41

    
42
cd /proc/acpi/battery
43
if [ "$1" = "config" ]; then
44
        echo 'graph_title Battery power'
45
        echo 'graph_args --base 1000 -l 0'
46
        echo 'graph_vlabel power in' `awk '/remaining capacity:/ { print $NF }' /proc/acpi/battery/*/state`
47
        echo 'graph_category sensors'
48
	echo 'graph_info This graph shows battery power based on output from ACPI.'
49
	i=0
50
	for battery in *
51
	do
52
		echo $battery.label $battery
53
		echo $battery.info Battery $i
54
		i=$(($i+1))
55
# design capacity warning: 2376 mWh
56
# design capacity low:     475 mWh
57
		echo $battery.warning `awk '/design capacity warning:/ { print $4 }' $battery/info`
58
		echo $battery.critical `awk '/design capacity low:/ { print $4 }' $battery/info`
59

    
60
		echo ${battery}_full.label $battery capacity
61
		echo ${battery}_full.info last full capacity \(design capacity: `awk '/design capacity:/ { print $3 " " $4 }' $battery/info`\)
62
	done
63
        exit 0
64
fi
65

    
66
for battery in *
67
do
68
	echo $battery.value `awk '/remaining capacity:/ { print $3 }' $battery/state`
69
	echo ${battery}_full.value `awk '/last full capacity:/ { print $4 }' $battery/info`
70
done