Skip to content

Instantly share code, notes, and snippets.

@yangl1996 yangl1996/ Secret
Last active Oct 1, 2017

What would you like to do?
Get power reading from IPMI

Utils reading power meter using IPMI DCMI and recording value into a round-robin database (rrd).

  • readpower - reads IPMI power meter
  • pushover $title $message - pushes arbitrary message to my phone using Pushover
  • checkpower - reads power meter, writes the value into rrd and reports overage using Pushover
  • - creates a round-robin database at /opt/power.rrd

Export $PUSHOVER_TOKEN and $PUSHOVER_USER to set UID and API token.

Run checkpower every 1 sec by calling watch -n 1 -- checkpower.

To collect data and draw a graph, use rrdtool graph. An example is given here:

sudo rrdtool graph ./power-trace.png \
  -a PNG \
  -s -300s \
  -t 'Past 5 mins' \
  -w 600 -h 200 \
  DEF:watts=/opt/power.rrd:watts:AVERAGE \
#! /bin/bash
sudo rrdtool update /opt/power.rrd N:$current_power
echo "Instantaneous Power Consumption: $current_power"
if [ $current_power -gt 2900 ]; then
pushover 'Power Overage' "Current power consumption is $current_power"
sudo rrdtool create /opt/power.rrd --step 1s \
DS:watts:GAUGE:1m:0:5000 \
RRA:AVERAGE:0:3s:1h \
RRA:AVERAGE:0.2:10s:6h \
RRA:AVERAGE:0.5:30s:24h \
#! /bin/bash
curl -s \
--form-string "token=$PUSHOVER_TOKEN" \
--form-string "user=$PUSHOVER_USER" \
--form-string "message=$2" \
--form-string "title=$1" \ | grep -q '"status":1'
if [ $? -ne 0 ]; then
>&2 echo 'pushover request failed'
exit 1
exit 0
#! /bin/bash
sudo ipmitool dcmi power reading | sed -n '/Instantaneous power reading/s/^\s*Instantaneous power reading:\s*\([0-9][0-9]*\) Watts$/\1/p'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.