Created
November 30, 2015 00:54
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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