From dd173e4beaf1da11db3bcfb2ccdfe8a623f26e53 Mon Sep 17 00:00:00 2001 From: Alistair Popple Date: Thu, 13 Nov 2014 17:16:05 +1100 Subject: esel: Add a logging backend for bmc based machines This patch adds a backend for bmc based machines running AMI firmware supporting the OEM extended sel commands. Errors are logged in pel format to the bmc. Signed-off-by: Alistair Popple Signed-off-by: Stewart Smith --- external/read_esel.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 external/read_esel.sh (limited to 'external') diff --git a/external/read_esel.sh b/external/read_esel.sh new file mode 100644 index 00000000..492fbce1 --- /dev/null +++ b/external/read_esel.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# Copyright 2013-2014 IBM Corp. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +set -e + +BMC_HOST=$1 +RECORD_ID=$2 + +BMC_USER=admin +BMC_PASS=admin + +if [ -z "$BMC_HOST" -o -z "$RECORD_ID" ]; then + echo "Usage: $0 " + echo "Example: $0 bmc 0xa > pel.bin" + echo '' + echo 'Record ids can be found using ipmitool with the "sel list" command. Records with' + echo 'a description of "OEM record df" contain extended SEL information (in PEL' + echo 'format) which can be extracted with this tool.' + exit -1 +fi + +# Convert a number into 2 hex-bytes in little-endian order +function conv_le { + echo $(for i in $(printf %04x $1 | grep -o .. | tac); do echo -n "0x$i "; done) +} + +function conv_native { + echo -n "0x${2}${1}" +} + +record=$(conv_le $2) +offset=0 +progress=0 + +while [ $progress = 0 ]; do + result=$(ipmitool -H ${BMC_HOST} -I lan -U ${BMC_USER} -P ${BMC_PASS} raw 0x32 0xf1 ${record} $(conv_le ${offset})) + len=$(conv_native $(echo ${result} | cut -d " " -f 1-2)) + progress=$(($(echo ${result} | cut -d " " -f 3))) + data="$data "$(echo -n ${result} | cut -d " " -f 6-) + offset=$(($offset + ${#data}/3)) +done + +echo -n ${data} | cut -d " " -f 1-$(($len)) | xxd -r -p -- cgit v1.2.1