Skip to content

Instantly share code, notes, and snippets.

@cliffordwhansen
Created January 31, 2023 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cliffordwhansen/e86a20395bc1d800a6eda793b76c3166 to your computer and use it in GitHub Desktop.
Save cliffordwhansen/e86a20395bc1d800a6eda793b76c3166 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Detect and install ipmitool (to be adjusted, this is run on an alpine system)
which ipmitool >/dev/null 2>&1 || (apk update && apk add ipmitool)
# IPMI hostname or IP address
IPMI_HOST=<<ipmi_ip_address>>
# IPMI username
IPMI_USER=<<username>>
# IPMI password
IPMI_PASS=<<password>>
# Check the system event log for errors
EVENT_LOG=$(ipmitool -I lanplus -H $IPMI_HOST -U $IPMI_USER -P $IPMI_PASS sel list)
# Check if the event log contains a specific error code
if echo "$EVENT_LOG" | grep -q "0x46"; then
# Restart the machine
ipmitool -I lanplus -H $IPMI_HOST -U $IPMI_USER -P $IPMI_PASS chassis power reset
# Clear the event log
ipmitool -I lanplus -H $IPMI_HOST -U $IPMI_USER -P $IPMI_PASS sel clear
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment