2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/battery/acpi-battery

70 lines
2.0 KiB
Plaintext
Raw Normal View History

2011-12-18 15:11:52 +01:00
#!/bin/sh
#
# Plugin to graph battery capacity.
#
# Parameters:
#
# acpi - Override path to acpi program
#
#
# $Log$
# Revision 1.1 2007/03/14 19:52:10 anarcat
# ACPI-Battery plugin, framework copied from acpi plugin
#
#
# Expected content of /proc/acpi/battery/BAT0/info:
# present: yes
# design capacity: 47520 mWh
# last full capacity: 37650 mWh
# battery technology: rechargeable
# design voltage: 10800 mV
# design capacity warning: 2376 mWh
# design capacity low: 475 mWh
# capacity granularity 1: 1 mWh
# capacity granularity 2: 1 mWh
# model number: IBM-08K8039
# serial number: 155
# battery type: LION
# OEM info: Panasonic
#%# family=auto
#%# capabilities=autoconf
if [ "$1" = "autoconf" ]; then
if grep -q 'present.*yes' /proc/acpi/battery/*/info > /dev/null 2>&1; then
echo yes
else
echo "no (battery not detected)"
fi
exit 0
2011-12-18 15:11:52 +01:00
fi
cd /proc/acpi/battery
if [ "$1" = "config" ]; then
echo 'graph_title Battery power'
echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel power in' `awk '/remaining capacity:/ { print $NF }' /proc/acpi/battery/*/state`
echo 'graph_category sensors'
echo 'graph_info This graph shows battery power based on output from ACPI.'
i=0
for battery in *
do
echo $battery.label $battery
echo $battery.info Battery $i
i=$(($i+1))
# design capacity warning: 2376 mWh
# design capacity low: 475 mWh
echo $battery.warning `awk '/design capacity warning:/ { print $4 }' $battery/info`
echo $battery.critical `awk '/design capacity low:/ { print $4 }' $battery/info`
echo ${battery}_full.label $battery capacity
echo ${battery}_full.info last full capacity \(design capacity: `awk '/design capacity:/ { print $3 " " $4 }' $battery/info`\)
done
exit 0
fi
for battery in *
do
echo $battery.value `awk '/remaining capacity:/ { print $3 }' $battery/state`
echo ${battery}_full.value `awk '/last full capacity:/ { print $4 }' $battery/info`
done