Projet

Général

Profil

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

root / plugins / battery / battery_ @ 2e3f5acd

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

1
#! /bin/sh
2

    
3
: <<=cut
4

    
5
=head1 NAME
6

    
7
battery_ - monitor battery status via the uevent API
8

    
9

    
10
=head1 CONFIGURATION
11

    
12
It is a wildcard plugin, symlink it into the plugins directory.
13

    
14
 [battery_*]
15
 env.percent no
16

    
17
By default the charge current is displayed as mAh, but you can also use percentage if you
18
prefer, by setting the environment variable "percent" to "yes".
19

    
20

    
21
=head1 AUTHORS
22

    
23
Copyright 2015 Steve Schnepp <steve.schnepp@pwkf.org>
24

    
25

    
26
=head1 LICENSE
27

    
28
GNU Library General Public License v2 only
29

    
30
SPDX-License-Identifier: GPL-2.0-only
31

    
32
=cut
33

    
34
battery_name=${0##*_}
35
percent=${percent:-"no"}
36

    
37
if [ "$1" = "config" ]
38
then
39
	echo "graph_title Battery $battery_name"
40
  echo "graph_category sensors"
41
	if [ "$percent" = "yes" ]
42
	then
43
		echo "graph_vlabel %"
44
	else
45
		echo "graph_vlabel mAh"
46
	fi
47

    
48
	echo "charge_design.label Design charge"
49
	echo "charge_design.draw AREA"
50
	[ "$percent" = "yes" ] && echo "charge_design.cdef charge_design,charge_design,/,100,*"
51

    
52
	echo "charge_full.label Full charge"
53
	echo "charge_full.draw AREA"
54
	[ "$percent" = "yes" ] && echo "charge_full.cdef charge_full,charge_design,/,100,*"
55
	echo "charge_now.label Current charge"
56
	echo "charge_now.draw AREA"
57
	[ "$percent" = "yes" ] && echo "charge_now.cdef charge_now,charge_design,/,100,*"
58

    
59
	exit 0
60
fi
61

    
62
# Crudely read all the vars into the current namespace
63
. /sys/class/power_supply/$battery_name/uevent
64

    
65
echo "charge_design.value $(( $POWER_SUPPLY_CHARGE_FULL_DESIGN / 1000 )) "
66
echo "charge_full.value $(( $POWER_SUPPLY_CHARGE_FULL / 1000 ))"
67
echo "charge_now.value $(( $POWER_SUPPLY_CHARGE_NOW / 1000 ))"
68

    
69
exit 0
70

    
71

    
72
:<< DATA
73
cat /sys/class/power_supply/$1/uevent
74
POWER_SUPPLY_NAME=CMB1
75
POWER_SUPPLY_STATUS=Charging
76
POWER_SUPPLY_PRESENT=1
77
POWER_SUPPLY_TECHNOLOGY=Li-ion
78
POWER_SUPPLY_CYCLE_COUNT=0
79
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
80
POWER_SUPPLY_VOLTAGE_NOW=11418000
81
POWER_SUPPLY_CURRENT_NOW=2668000
82
POWER_SUPPLY_CHARGE_FULL_DESIGN=5200000
83
POWER_SUPPLY_CHARGE_FULL=5000000
84
POWER_SUPPLY_CHARGE_NOW=100000
85
POWER_SUPPLY_CAPACITY=2
86
POWER_SUPPLY_CAPACITY_LEVEL=Normal
87
POWER_SUPPLY_MODEL_NAME=CP293570
88
POWER_SUPPLY_MANUFACTURER=Fujitsu
89
DATA