Repository
Munin (contrib)
Last change
2018-09-16
Graph Categories
Family
auto
Capabilities
Keywords
Language
Shell

acpi-battery

Sadly there is no documentation for this plugin.

#!/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
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