#!/bin/bash IPMI='/usr/bin/ipmitool -I open' host=$(hostname) OUTF="/tmp/${host}_ipmi.txt" dt=$(date '+%Y-%m-%d %H:%S') dt1=$(date "+%s") divider='==========================================' list=$(${IPMI} -I open sdr list) echo "${divider}" > ${OUTF} echo "= Host: ${hostname}" >> ${OUTF} echo "= Date: ${dt}" >> ${OUTF} echo "${divider}" >> ${OUTF} echo "ipmitol sdr list" >> ${OUTF} echo "${divider}" >> ${OUTF} echo "${list}" >> ${OUTF} echo "${divider}" >> ${OUTF} echo "${list}" | while read line do state=$(echo "${line}" | awk -F'|' '{print $3}') if [[ ' ns' != "${state}" ]] then sensor=$(echo "${line}" | awk -F'|' '{print $1}' | sed 's/ *$//') echo "= ${sensor} : ${state}" >> ${OUTF} echo "= ipmitool sensor get \"${sensor}\"" >> ${OUTF} res=$(${IPMI} sensor get "${sensor}" | grep -v 'Locating sensor record...') echo "${res}" >> ${OUTF} echo "${divider}" >> ${OUTF} fi done dt2=$(date "+%s") ((diff = dt2 - dt1)) echo "= Command took ${diff} seconds" >> ${OUTF} echo "${divider}" >> ${OUTF}