Skip to content

Instantly share code, notes, and snippets.

@ixs
Created November 30, 2015 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ixs/8c74e171242625fc043d to your computer and use it in GitHub Desktop.
Save ixs/8c74e171242625fc043d to your computer and use it in GitHub Desktop.
Clear the IPMI SEL log before it gets full and synchronize the system time.
#!/bin/sh
# Clear the system event log on the BMC when it is more than 80% full.
THRESH=80
SEL_STATE=$(/usr/bin/ipmitool sel info 2> /dev/null)
if [ $? -ne 0 ]; then
echo Problem fetching SEL info.
exit 255
fi
SEL_GAUGE=$(echo "$SEL_STATE" | awk '/Percent Used/ { printf "%d\n", $4 }')
if [ $SEL_GAUGE -ge $THRESH ]; then
/usr/bin/ipmitool sel clear > /dev/null
logger -t "$(basename $0)[$$]" "IPMI System Event Log at ${SEL_GAUGE}% capacity. Cleared..."
fi
# Set the date of the local SEL clock once per 24h
if [ "$(date +%H)" -eq "0" ]; then
SEL_TIME=$(date -d "$(ipmitool sel time get)" +%s)
SYS_TIME=$(date +%s)
if [ "$SEL_TIME" -ne "$SYS_TIME" ]; then
if [ "$SEL_TIME" -gt "$SYS_TIME" ]; then
DIFF=$(($SEL_TIME - $SYS_TIME))
else
DIFF=$(($SYS_TIME - $SEL_TIME))
fi
/usr/bin/ipmitool sel time set "$(date +"%m/%d/%Y %H:%M:%S")" > /dev/null
logger -t "$(basename $0)[$$]" "IPMI System Event Log clock differed by ${DIFF}s from system clock.. Corrected..."
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment