Projet

Général

Profil

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

root / plugins / battery / battery_ @ e08a6448

Historique | Voir | Annoter | Télécharger (1,87 ko)

1
#! /bin/sh
2
# Plugin to monitor the battery status via the uevent API
3
#
4
# (c) 2015 - GPLv2 - steve.schnepp@pwkf.org
5
#
6
# It is a wildcard plugin, symlink it with the battery directory
7
# default is to display charge as mAh, but you can also use percentage if you
8
# prefer, by setting the env var "percent" to "yes".
9
#
10
# [battery_*]
11
# env.percent no
12
#
13

    
14
battery_name=${0##*_}
15
percent=${percent:-"no"}
16

    
17
if [ "$1" = "config" ]
18
then
19
	echo "graph_title Battery $battery_name"
20
  echo "graph_category sensors"
21
	if [ "$percent" = "yes" ]
22
	then
23
		echo "graph_vlabel %"
24
	else
25
		echo "graph_vlabel mAh"
26
	fi
27

    
28
	echo "charge_design.label Design charge"
29
	echo "charge_design.draw AREA"
30
	[ "$percent" = "yes" ] && echo "charge_design.cdef charge_design,charge_design,/,100,*"
31

    
32
	echo "charge_full.label Full charge"
33
	echo "charge_full.draw AREA"
34
	[ "$percent" = "yes" ] && echo "charge_full.cdef charge_full,charge_design,/,100,*"
35
	echo "charge_now.label Current charge"
36
	echo "charge_now.draw AREA"
37
	[ "$percent" = "yes" ] && echo "charge_now.cdef charge_now,charge_design,/,100,*"
38

    
39
	exit 0
40
fi
41

    
42
# Crudely read all the vars into the current namespace
43
. /sys/class/power_supply/$battery_name/uevent
44

    
45
echo "charge_design.value $(( $POWER_SUPPLY_CHARGE_FULL_DESIGN / 1000 )) "
46
echo "charge_full.value $(( $POWER_SUPPLY_CHARGE_FULL / 1000 ))"
47
echo "charge_now.value $(( $POWER_SUPPLY_CHARGE_NOW / 1000 ))"
48

    
49
exit 0
50

    
51

    
52
:<< DATA
53
cat /sys/class/power_supply/$1/uevent
54
POWER_SUPPLY_NAME=CMB1
55
POWER_SUPPLY_STATUS=Charging
56
POWER_SUPPLY_PRESENT=1
57
POWER_SUPPLY_TECHNOLOGY=Li-ion
58
POWER_SUPPLY_CYCLE_COUNT=0
59
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
60
POWER_SUPPLY_VOLTAGE_NOW=11418000
61
POWER_SUPPLY_CURRENT_NOW=2668000
62
POWER_SUPPLY_CHARGE_FULL_DESIGN=5200000
63
POWER_SUPPLY_CHARGE_FULL=5000000
64
POWER_SUPPLY_CHARGE_NOW=100000
65
POWER_SUPPLY_CAPACITY=2
66
POWER_SUPPLY_CAPACITY_LEVEL=Normal
67
POWER_SUPPLY_MODEL_NAME=CP293570
68
POWER_SUPPLY_MANUFACTURER=Fujitsu
69
DATA