#!/bin/bash BMC_IP=$1 BMC_USER=$2 BMC_PW=$3 BMC_INFO="${BMC_USER}:${BMC_PW}" if [ $# -lt 3 ];then echo "Script Usage:" echo " ./Outband_Collect_OneKeyLog.sh " exit 0 fi # Get BoardSN BoardSN=`ipmitool -H ${BMC_IP} -I lanplus -U ${BMC_USER} -P ${BMC_PW} fru print | grep "Board Serial" | awk '{print $4}'` if [ "${BoardSN}" = "" ];then echo "Error: Can't Get BoardSN, please check network connection or user&password !" exit 1 fi time=`date "+%Y-%m-%dT%H:%M:%S"` LOG_FILENAME="Product_${BoardSN}_${time}.tar.gz" # Post message to BMC to collect all log echo -e "\n Step 1. Post Collect all log to BMC" curl -k -u $BMC_INFO -X POST -H "Content-Length: 0" https://${BMC_IP}/redfish/v1/Managers/1/LogServices/Actions/public/CollectAllLog # Wait 60 seconds to Complete echo -e "\n Waiting 150 seconds for collect all log ..." sleep 150 # Download Onekeylog echo -e "\n Step 2. Download Onekeylog" curl -k -u $BMC_INFO -X POST -H "Content-Length: 0" https://${BMC_IP}/redfish/v1/Managers/1/LogServices/Actions/public/DownloadAllLog --output $LOG_FILENAME # Complete echo -e "\n Complete Download Onekeylog"