diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/Makefile.am | 2 | ||||
-rw-r--r-- | contrib/Makefile.in | 4 | ||||
-rw-r--r-- | contrib/log_bmc.sh | 88 |
3 files changed, 92 insertions, 2 deletions
diff --git a/contrib/Makefile.am b/contrib/Makefile.am index c067dcb..98cec70 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -35,7 +35,7 @@ dist_pkgdata_DATA = oem_ibm_sel_map EXTRA_DIST = README \ bmclanconf ipmi.init.basic ipmi.init.redhat \ exchange-bmc-os-info.init.redhat exchange-bmc-os-info.service.redhat \ - exchange-bmc-os-info.sysconf \ + exchange-bmc-os-info.sysconf log_bmc.sh\ ipmievd.init.redhat ipmievd.init.suse ipmievd.init.debian \ collect_data.sh create_rrds.sh create_webpage_compact.sh create_webpage.sh \ bmc-snmp-proxy bmc-snmp-proxy.service bmc-snmp-proxy.sysconf diff --git a/contrib/Makefile.in b/contrib/Makefile.in index bd77fb7..868dd15 100644 --- a/contrib/Makefile.in +++ b/contrib/Makefile.in @@ -222,6 +222,8 @@ INTF_OPEN = @INTF_OPEN@ INTF_OPEN_LIB = @INTF_OPEN_LIB@ INTF_SERIAL = @INTF_SERIAL@ INTF_SERIAL_LIB = @INTF_SERIAL_LIB@ +INTF_USB = @INTF_USB@ +INTF_USB_LIB = @INTF_USB_LIB@ IPMITOOL_INTF_LIB = @IPMITOOL_INTF_LIB@ LD = @LD@ LDFLAGS = @LDFLAGS@ @@ -321,7 +323,7 @@ dist_pkgdata_DATA = oem_ibm_sel_map EXTRA_DIST = README \ bmclanconf ipmi.init.basic ipmi.init.redhat \ exchange-bmc-os-info.init.redhat exchange-bmc-os-info.service.redhat \ - exchange-bmc-os-info.sysconf \ + exchange-bmc-os-info.sysconf log_bmc.sh\ ipmievd.init.redhat ipmievd.init.suse ipmievd.init.debian \ collect_data.sh create_rrds.sh create_webpage_compact.sh create_webpage.sh \ bmc-snmp-proxy bmc-snmp-proxy.service bmc-snmp-proxy.sysconf diff --git a/contrib/log_bmc.sh b/contrib/log_bmc.sh new file mode 100644 index 0000000..c7bbb76 --- /dev/null +++ b/contrib/log_bmc.sh @@ -0,0 +1,88 @@ +#!/bin/sh +############################################################################# +# +# log_bmc.sh: Add SEL entries to indicate OS Boot/Install status. +# +# version: 0.1 +# +# Authors: Charles Rose <charles_rose@dell.com> +# Jordan Hargrave <jordan_hargrave@dell.com> +# +# Description: Script to log OS boot/install status to the BMC. Primarily +# meant for use in automated installs and start up scripts. +# Will provide administrators with OS boot/install status in +# BMC and aid with debugging. +# +# Example usage: +# # ./log_bmc.sh inst_start +# # ipmitool sel list +# b | 05/07/2014 | 12:07:32 | OS Boot | Installation started +# +# See here for details: +# https://fedoraproject.org/wiki/Features/AgentFreeManagement +# +############################################################################# +IPMI_CMD="/usr/bin/ipmitool" + +############################################################################# +# SEL Event types from ipmi_sel.h +OS_STOP="0x20" +OS_BOOT="0x1f" +# SEL Event data from ipmi_sel.h +GRACEFUL_SHUTDOWN="0x03" # OS Stop/Shutdown: Installation started +BOOT_COMPLETED="0x01" # OS Boot: Installation started +INSTALL_STARTED="0x07" # OS Boot: Installation started +INSTALL_COMPLETED="0x08" # OS Boot: Installation completed +INSTALL_ABORTED="0x09" # OS Boot: Installation aborted +INSTALL_FAILED="0x0a" # OS Boot: Installation failed + +########################################################################## + +# check for ipmi functionality. +check_ipmi() +{ + # ensures presence of ipmitool and /dev/ipmi* + ${IPMI_CMD} mc info > /dev/null 2>&1 + [ $? -ne 0 ] && RETVAL=2 +} + +# Write out the events to SEL +ipmi_sel_add() +{ + # Refer ipmitool(1) event for details on format. + printf "0x04 %s 0x00 0x6f %s 0x00 0x00" ${type} ${status} > \ + ${tmpfile} && \ + ${IPMI_CMD} sel add ${tmpfile} > /dev/null 2>&1 + [ $? -ne 0 ] && RETVAL=3 +} + +### Main +# Most of the status is for this event type +tmpfile=$(/usr/bin/mktemp) +RETVAL=0 +type=${OS_BOOT} + +case ${1} in + os_shutdown) type=${OS_STOP}; status=${GRACEFUL_SHUTDOWN} ;; + os_boot) status=${BOOT_COMPLETED} ;; + inst_start) status=${INSTALL_STARTED} ;; + inst_complete) status=${INSTALL_COMPLETED} ;; + inst_abort) status=${INSTALL_ABORTED} ;; + inst_fail) status=${INSTALL_FAILED} ;; + *) RETVAL=1 ;; +esac + +[ ${RETVAL} -eq 0 ] && check_ipmi +[ ${RETVAL} -eq 0 ] && ipmi_sel_add ${status} + +case ${RETVAL} in + 0) ;; + 1) printf -- %s\\n "Usage: $0 <os_boot|os_shutdown|inst_start|inst_complete|inst_abort|inst_fail>" ;; + 2) printf -- %s\\n "failed to communicate with BMC." ;; + 3) printf -- %s\\n "error adding ipmi sel entry." ;; +esac + +[ -f ${tmpfile} ] && rm -f ${tmpfile} > /dev/null 2>&1 + +exit ${RETVAL} +### End |