Monitoring power consumption of an IPMI system for a given application

A simple script to measure power consumption of an IPMI enabled system (using ipmi-sensors) while executing a given application. The script can perform two operations: log the power consumption and read an existing log file and report the average watts consumed. The consumption sample is taken by default every 1 second. That can be easily altered either within the script or by introducing an additional user argument.

For logging consumption:

$ ./watt_log.sh get <logfile> <application in ps>

Once the logging will start, the script will automatically stop when the application will finish executing. For interrupting this, CTRL+C would work as well without affecting the logged entries.

For reporting average:

$ ./watt_log.sh average <logfile>
############################################################################
# Copyright (C) 2011  Panagiotis Kritikakos <panoskrt@gmail.com>           #
#                                                                          #
#    This program is free software: you can redistribute it and/or modify  #
#    it under the terms of the GNU General Public License as published by  #
#    the Free Software Foundation, either version 3 of the License, or     #
#    (at your option) any later version.                                   #
#                                                                          #
#    This program is distributed in the hope that it will be useful,       #
#    but WITHOUT ANY WARRANTY; without even the implied warranty of        #
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
#    GNU General Public License for more details.                          #
#                                                                          #
#    You should have received a copy of the GNU General Public License     #
#    along with this program.  If not, see <http://www.gnu.org/licenses/>. #
############################################################################

#!/bin/bash

option=$1
logfile=$2
code=$3

getAvg(){
  totalwatts=`cat ${logfile} | awk '{total = total + $1}END{print total}'`
  elements=`cat  ${logfile} | wc -l`
  avgwatts=`echo "${totalwatts} / ${elements}" | bc`

  printf "\n\n Average watts: ${avgwatts}\n\n"
}

if [ "${option}" == "average" ]; then
   getAvg
   exit 0
fi

if [ $# -lt 3 ] || [ $# -gt 3 ]; then
  echo " Specify logfile and code"
  exit 1
fi

if [ -e ${logfile} ]; then rm -f ${logfile}; fi

codeis=`ps aux | grep ${code} | grep -v grep | wc -l`

while [ ${codeis} -gt 0 ]; do

  sudo /usr/sbin/ipmi-sensors | grep -w "System Level" | awk {'print $5'} | \
  awk ' sub("\\.*0+$","") ' >> ${logfile}
  sleep 1
  codeis=`ps aux | grep ${code} | grep -v grep | wc -l`

done

getAvg
Advertisement

Πίνδος: Το Εθνικό Πάρκο

Σχετικά πρόσφατα κυκλοφόρησε το καταπληκτικό λεύκωμα του Αλέξανδρου Τζιόλλα, “ΠΙΝΔΟΣ : Το Εθνικό Πάρκο ΖΑΓΟΡΙ-ΜΕΤΣΟΒΟ-ΓΡΕΒΕΝΑ-ΒΟΙΟ-ΚΟΝΙΤΣΑ“. Πρόκειται για μία φωτογραφημένη περιήγηση στην ευρύτερη περιοχή του Εθνικού Πάρκου της Β. Πίνδου με 2.500 φωτογραφίες και απόψεις για την διάσωση, την διατήρηση και την “ανάπτυξη” των ορεινών περιοχών όπως αυτής της Πίνδου. Η έκδοση είναι μία πρωτότυπη ΠΑΓΚΟΣΜΙΑ ΣΥΝΕΡΓΑΣΙΑ για τον ιστορικό, πολιτισμικό και φυσικό πλούτο της Πίνδου. 80 διάσημοι επιστήμονες, επισκέπτες, φωτογράφοι και 140 Έλληνες συμβάλλουν στη διαμόρφωση αυτής της έκδοσης. Έγχρωμο 400 σελ. 23χ30, κυκλοφόρησε από τις εκδόσεις Περιοδικό Δίαυλος.

Προλογίζουν :
Economou Th. Αστροφυσικός NASA, Chicago University USA.
Tom Dempsey, International Photographer of National Geographic.
Dick Mol καθηγ. Φυσικής Ιστορίας του Ρόττερνταμ, Holland.
D. Harding, καθηγ. Cambrige Un. UK.

Ο πρόλογος του Αλέξανδρου Τζιόλα στη παραπάνω έκοδση: http://alextziolas.blogspot.com/2011/01/o.html