#!/bin/sh
# $Copyright$
# Copyright (C) Fujitsu Technology Solutions 2009
# All rights reserved
#
# $Copyright$
# Copyright (C) Fujitsu Siemens Computers GmbH 2006, 2007
# All rights reserved
#
# $Id: SVreadLog.sh,v 1.3 2006-11-13 10:52:48+01 richter Exp richter $
#
# NAME
#	SVreadLog - Display the ServerView Message Log
#
# SYNOPSIS
#	SVreadLog [-h] [-d|-e]
#
# DESCRIPTION
# 	This script reads and displays the ServerView Message Log maintained
#	by ServerView. On IPMI-based systems, the ServerView Message Log
#	includes important entries from the IPMI SEL as kept in the BMC.
#
# OPTIONS
#	If called without options, the script displays all SEL entries
#	in neutral (English) language
#	h	displays help information
#	d   displays in German language
#	e   displays in English language
#
# SEE ALSO
#	eecdcp(8)
#	ServerControl Command Interface (SCCI) Specification
#
# EXIT STATUS
#	0 OK
#	1 Runtime Error
#	2 Argument Error
#
# CHANGE HISTORY
#	May 2006, -rit
#		Initial implementation.

# ----------------------------------------------------------------------
# Initialization
# ----------------------------------------------------------------------

MYSELF="${0##*/}"

status=0
language=
critical=0

# Internationalized Messages

USAGE="#### Usage:
    $0 [-ch] [-d|-e]
    Call without options displays all log messages in English language
    Options:
    c	displays only MAJOR and CRITICAL severity messages
    h   display this message
    d   displays in German language
    e   displays in English language\n"

# ----------------------------------------------------------------------
# Main
# ----------------------------------------------------------------------

while getopts chde optChar; do
	case "$optChar" in
	c)	critical=1 ;;
	d)	language="de" ;;
	e)	language="en" ;;
	h|[?])
		printf "$USAGE"
		[ "$1" = "-h" ] && exit 0
		exit 2
		;;
	esac
done

if [ $critical -eq 1 ]; then
	eecdcp -l $language | egrep 'Severity|MAJOR|CRITICAL'
else
	eecdcp -l $language
fi

status=$?

# ----------------------------------------------------------------------
# Done
# ----------------------------------------------------------------------

exit $status

# EOF
