Last active
August 29, 2015 14:11
-
-
Save tatsuru/eeb990d2f9db6732a6ba to your computer and use it in GitHub Desktop.
X240 Battery Plugin for Mackerel.io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# [plugin.metrics.battery] | |
# command = "/path/to/x240battery.sh" | |
# | |
LANG=C | |
if [ x$MACKEREL_AGENT_PLUGIN_META = x1 ]; then | |
cat <<EOF | |
# mackerel-agent-plugin | |
{ | |
"graphs": { | |
"battery": { | |
"label": "X240 Battery capacity", | |
"unit": "integer", | |
"metrics": [ | |
{ "name": "BAT0", "label": "Front battery" }, | |
{ "name": "BAT1", "label": "Rear battery" } | |
] | |
} | |
} | |
} | |
EOF | |
exit 0 | |
fi | |
cap0=$(cat /sys/class/power_supply/BAT0/capacity) | |
cap1=$(cat /sys/class/power_supply/BAT1/capacity) | |
echo -n "battery.BAT0 ${cap0} " | |
date +%s | |
echo -n "battery.BAT1 ${cap1} " | |
date +%s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment