#!/bin/bash

# 사용자 이름 및 비밀번호 설정
IDRAC_USER="root"
IDRAC_PASS="calvin"

# IP 주소 파일 경로 인자 받기
if [ -z "$1" ]; then
    echo "Usage: $0 <ip_file>"
    exit 1
fi

IP_FILE=$1

if [ ! -f "$IP_FILE" ]; then
    echo "IP file $IP_FILE does not exist."
    exit 1
fi

# 정보 저장 디렉터리 설정
OUTPUT_DIR="idrac_info"
mkdir -p $OUTPUT_DIR

# iDRAC 정보를 가져오는 함수 정의
fetch_idrac_info() {
    local IDRAC_IP=$(cat $IP_FILE)

    # 모든 hwinventory 저장
    local hwinventory=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS hwinventory)
    # 모든 샷시 정보 저장
    local getsysinfo=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS getsysinfo)
    # 모든 SysProfileSettings 저장
    local SysProfileSettings=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get bios.SysProfileSettings)
    # ProcessorSettings 저장
    local ProcessorSettings=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get bios.ProcSettings)
    # Memory Settings 저장
    local MemorySettings=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get bios.MemSettings)
    # Raid Settings 저장
    local STORAGEController=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get STORAGE.Controller.1)

    # 서비스 태그 가져오기
    local SVC_TAG=$(echo "$getsysinfo" | grep -i "SVC Tag" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # Bios Firmware Version 확인
    local Bios_firmware=$(echo "$getsysinfo" | grep -i "System BIOS Version" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # iDRAC Firmware Version 확인
    local iDRAC_firmware=$(echo "$getsysinfo" | grep -i "Firmware Version" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # Intel NIC Firmware Version 확인
    local Intel_NIC_firmware=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get NIC.FrmwImgMenu.1 | grep -i "#FamilyVersion" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # OnBoard NIC Firmware Version 확인
    local Onboard_NIC_firmware=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get NIC.FrmwImgMenu.5 | grep -i "#FamilyVersion" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # R/C Firmware Version 확인
    local Raid_firmware=$(echo "$hwinventory" | grep -i "ControllerFirmwareVersion" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # Bios 설정  Boot Mode 확인
    local Bios_BootMode=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get bios.BiosBootSettings | grep -i "BootMode" | awk -F '=' '{print $2}' | tr -d '[:space:]')

    # Bios SysProfileSettings 설정 정보 확인
    local SysProFileSettings_info1=$(echo "$SysProfileSettings" | grep -i "SysProfile=" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    local SysProFileSettings_info2=$(echo "$SysProfileSettings" | grep -i "ProcPwrPerf" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    local SysProFileSettings_info3=$(echo "$SysProfileSettings" | grep -i "MemFrequency" | awk -F '=' '{print $2}' | tr -d '[:space:]')    
    local SysProFileSettings_info4=$(echo "$SysProfileSettings" | grep -i "ProcTurboMode" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    local SysProFileSettings_info5=$(echo "$SysProfileSettings" | grep -i "PcieAspmL1" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    local SysProFileSettings_info6=$(echo "$SysProfileSettings" | grep -i "ProcCStates" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    local SysProFileSettings_info7=$(echo "$SysProfileSettings" | grep -i "DeterminismSlider" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    local SysProFileSettings_info8=$(echo "$SysProfileSettings" | grep -i "DynamicLinkWidthManagement" | awk -F '=' '{print $2}' | tr -d '[:space:]')

    # Processor Settings - Logical Processor
    local ProcessorSettings_info1=$(echo "$ProcessorSettings" | grep -i "LogicalProc" | awk -F '=' '{print $2}' | tr -d '[:space:]')    
    local ProcessorSettings_info2=$(echo "$ProcessorSettings" | grep -i "ProcVirtualization" | awk -F '=' '{print $2}' | tr -d '[:space:]')  
    local ProcessorSettings_info3=$(echo "$ProcessorSettings" | grep -i "NumaNodesPerSocket" | awk -F '=' '{print $2}' | tr -d '[:space:]')  
    local ProcessorSettings_info4=$(echo "$ProcessorSettings" | grep -i "ProcX2Apic" | awk -F '=' '{print $2}' | tr -d '[:space:]')  
    
    # Memory Settings - Node Interleaving
    local MemorySettings_info1=$(echo "$MemorySettings" | grep -i "DramRefreshDelay" | awk -F '=' '{print $2}' | tr -d '[:space:]')    
    local MemorySettings_info2=$(echo "$MemorySettings" | grep -i "PPROnUCE" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    local MemorySettings_info3=$(echo "$MemorySettings" | grep -i "CECriticalSEL" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    
    # System Settings - Thermal Profile Optimization
    local SystemSettings_info1=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get System.ThermalSettings | grep -i "ThermalProfile" | awk -F '=' '{print $2}')
    # Integrated Devices Settings - SR-IOV Global Enable
    local IntegratedDevicesSettings_info1=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get Bios.IntegratedDevices | grep -i "SriovGlobalEnable" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # Miscellaneous Settings - F1/F2 Prompt on Error
    local IMiscellaneousSettings_info1=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get bios.MiscSettings | grep -i "ErrPrompt" | awk -F '=' '{print $2}' | tr -d '[:space:]')

    # iDRAC Settings - Timezone
    local iDRAC_Settings_info1=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.Time.Timezone | grep -i "Timezone" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # iDRAC Settings - IPMI LAN Selection
    local iDRAC_Settings_info2=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.CurrentNIC | grep -i "ActiveNIC" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # iDRAC Settings - IPMI IP(IPv4)
    local iDRAC_Settings_info3=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.CurrentIPv4 | grep -i "DHCPEnable" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # iDRAC Settings - IPMI IP(IPv6)
    local iDRAC_Settings_info4=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.CurrentIPv6 | grep -i "Enable=" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # iDRAC Settings - Redfish Support
    local iDRAC_Settings_info5=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.Redfish.Enable | grep -i "Enable=" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # iDRAC Settings - SSH Support
    local iDRAC_Settings_info6=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.SSH | grep -i "Enable=" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # iDRAC Settings - AD User Domain Name
    local iDRAC_Settings_info7=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.USERDomain.1.Name | grep -i "Name" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # iDRAC Settings - SC Server Address
    local iDRAC_Settings_info8=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.ActiveDirectory.DomainController1 | grep -i "DomainController1" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # iDRAC Settings - SE AD RoleGroup Name
    local iDRAC_Settings_info9=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.ADGroup.1.Name | grep -i "Name" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # iDRAC Settings - SE AD RoleGroup Dome인
    local iDRAC_Settings_info10=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.ADGroup.1.Domain | grep -i "Domain" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # iDRAC Settings - SE AD RoleGroup Privilege
    local iDRAC_Settings_info11=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.ADGroup.1.Privilege | grep -i "Privilege" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # iDRAC Settings - IDC AD RoleGroup name
    local iDRAC_Settings_info12=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.ADGroup.2.Name | grep -i "Name" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # iDRAC Settings - IDC AD RoleGroup Dome인
    local iDRAC_Settings_info13=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.ADGroup.2.Domain | grep -i "Domain" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # iDRAC Settings - IDC AD RoleGroup Privilege
    local iDRAC_Settings_info14=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.ADGroup.2.Privilege | grep -i "Privilege" | awk -F '=' '{print $2}' | tr -d '[:space:]')        
    # iDRAC Settings - Remote Log (syslog)
    local iDRAC_Settings_info15=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.SysLog.SysLogEnable | grep -i "SysLogEnable" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # iDRAC Settings - syslog server address 1
    local iDRAC_Settings_info16=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.SysLog.Server1 | grep -i "Server1" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # iDRAC Settings - syslog server address 2
    local iDRAC_Settings_info17=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.SysLog.Server2 | grep -i "Server2" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # iDRAC Settings - syslog server port
    local iDRAC_Settings_info18=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.SysLog.Port | grep -i "Port" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # iDRAC Settings - VirtualConsole Port
    local iDRAC_Settings_info19=$(racadm -r $IDRAC_IP -u $IDRAC_USER -p $IDRAC_PASS get iDRAC.VirtualConsole.Port | grep -i "Port" | awk -F '=' '{print $2}' | tr -d '[:space:]')

    # RAID Settings - ProductName 
    local RAID_info0=$(echo "$hwinventory" | grep -i "ProductName = PERC" | awk -F '=' '{print $2}')     
    # RAID Settings - RAIDType
    local RAID_info1=$(echo "$hwinventory" | grep -i "RAIDTypes" | awk -F '=' '{print $2}' | tr -d '[:space:]')    
    # RAID Settings - StripeSize
    local RAID_info2=$(echo "$hwinventory" | grep -i "StripeSize" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # RAID Settings - ReadCachePolicy
    local RAID_info3=$(echo "$hwinventory" | grep -i "ReadCachePolicy" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # RAID Settings - WriteCachePolicy
    local RAID_info4=$(echo "$hwinventory" | grep -i "WriteCachePolicy" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # RAID Settings - PatrolReadRate
    local RAID_info5=$(echo "$STORAGEController" | grep -i "CheckConsistencyRate" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    # RAID Settings - PatrolReadRate
    local RAID_info6=$(echo "$STORAGEController" | grep -i "PatrolReadMode" | awk -F '=' '{print $2}' | tr -d '[:space:]')
    
    # 서비스 태그가 존재하는지 확인
    if [ -z "$SVC_TAG" ]; then
        echo "Failed to retrieve SVC Tag for IP: $IDRAC_IP"
        return
    fi

    local OUTPUT_FILE="$OUTPUT_DIR/$SVC_TAG.txt"
    echo "Dell EMC Server Bios,iDRAC,R/C Setting (SVC Tag: $SVC_TAG)" | tee -a "$OUTPUT_FILE"
    echo -e "\n" >> "$OUTPUT_FILE"
    echo "------------------------------------------Firware Version 정보------------------------------------------" >> "$OUTPUT_FILE"
    # SVC Tag 확인
    echo "1. SVC Tag : $SVC_TAG" >> "$OUTPUT_FILE" 

    # Bios Firmware Version 확인
    echo "2. Bios Firmware : $Bios_firmware" >> "$OUTPUT_FILE"

    # iDRAC Firmware Version 확인
    echo "3. iDRAC Firmware Version : $iDRAC_firmware" >> "$OUTPUT_FILE"

    # Intel NIC Firmware Version 확인
    echo "4. NIC Integrated Firmware Version : $Intel_NIC_firmware" >> "$OUTPUT_FILE"

    # OnBoard NIC Firmware Version 확인
    echo "5. OnBoard NIC Firmware Version : $Onboard_NIC_firmware" >> "$OUTPUT_FILE"
    
    # Raid Controller Firmware Version 확인
    echo "6. Raid Controller Firmware Version : $Raid_firmware" >> "$OUTPUT_FILE"
    echo -e "\n" >> "$OUTPUT_FILE"
        
    echo "---------------------------------------------Bios 설정 정보----------------------------------------------" >> "$OUTPUT_FILE"
    # bios Boot Mode 확인
    echo "01. Bios Boot Mode : $Bios_BootMode" >> "$OUTPUT_FILE"
    
    # SysProfileSettings - System Profile
    echo "02. System Profile Settings - System Profile : $SysProFileSettings_info1" >> "$OUTPUT_FILE"
    
    # SysProfileSettings - CPU Power Management
    echo "03. System Profile Settings - CPU Power Management : $SysProFileSettings_info2" >> "$OUTPUT_FILE"
    
    # SysProfileSettings - Memory Frequency
    echo "04. System Profile Settings - Memory Frequency : $SysProFileSettings_info3" >> "$OUTPUT_FILE"
        
    # SysProfileSettings - Turbo Boost
    echo "05. System Profile Settings - Turbo Boost : $SysProFileSettings_info4" >> "$OUTPUT_FILE" 
    
    # SysProfileSettings - C1E
    echo "06. System Profile Settings - PCI ASPM L1 Link Power Management : $SysProFileSettings_info5" >> "$OUTPUT_FILE"
    
    # SysProfileSettings - C-States
    echo "07. System Profile Settings - C-States : $SysProFileSettings_info6" >> "$OUTPUT_FILE"
    
    # SysProfileSettings - Determinism Slider
    echo "08. System Profile Settings - Determinism Slider : $SysProFileSettings_info7" >> "$OUTPUT_FILE"

    # SysProfileSettings - Dynamic Link Width Management (DLWM)
    echo "08. System Profile Settings - Dynamic Link Width Management (DLWM) : $SysProFileSettings_info8" >> "$OUTPUT_FILE"
    
    # Processor Settings - Logical Processor
    echo "09. Processor Settings - Logical Processor : $ProcessorSettings_info1" >> "$OUTPUT_FILE"    

    # Processor Settings - Virtualization Technology
    echo "10. Processor Settings - Virtualization Technology : $ProcessorSettings_info2" >> "$OUTPUT_FILE"

    # Processor Settings - NUMA Nodes Per Socket
    echo "11. Processor Settings - NUMA Nodes Per Socket : $ProcessorSettings_info3" >> "$OUTPUT_FILE"

    # Processor Settings - x2APIC Mode
    echo "12. Processor Settings - x2APIC Mode : $ProcessorSettings_info4" >> "$OUTPUT_FILE"

    # Memory Settings - Dram Refresh Delayg
    echo "13. Memory Settings - Dram Refresh Delay : $MemorySettings_info1" >> "$OUTPUT_FILE"

    # Memory Settings - DIMM Self Healing (Post Package Repair) on Uncorrectable Memory Error
    echo "14. Memory Settings - DIMM Self Healing (Post Package Repair) on Uncorrectable Memory Error : $MemorySettings_info2" >> "$OUTPUT_FILE"    

    # Memory Settings - Correctable Error Logging
    echo "15. Memory Settings - Correctable Error Logging : $MemorySettings_info3" >> "$OUTPUT_FILE"

    # System Settings - Thermal Profile Optimization
    echo "16. System Settings - Thermal Profile Optimization : $SystemSettings_info1" >> "$OUTPUT_FILE"    

    # Integrated Devices Settings - SR-IOV Global Enable
    echo "17. Integrated Devices Settings - SR-IOV Global Enable : $IntegratedDevicesSettings_info1" >> "$OUTPUT_FILE"  

    # Miscellaneous Settings - F1/F2 Prompt on Error
    echo "18. Miscellaneous Settings - F1/F2 Prompt on Error : $IMiscellaneousSettings_info1" >> "$OUTPUT_FILE" 
    echo -e "\n" >> "$OUTPUT_FILE"
    
    echo "---------------------------------------------iDRAC 설정 정보----------------------------------------------" >> "$OUTPUT_FILE"    
    # iDRAC Settings - Timezone
    echo "01. iDRAC Settings - Timezone : $iDRAC_Settings_info1" >> "$OUTPUT_FILE" 
    # iDRAC Settings - IPMI LAN Selection
    echo "02. iDRAC Settings - IPMI LAN Selection : $iDRAC_Settings_info2" >> "$OUTPUT_FILE"
    # iDRAC Settings - IPMI IP(IPv4)
    echo "03. iDRAC Settings - IPMI IP(IPv4) : $iDRAC_Settings_info3" >> "$OUTPUT_FILE"
    # iDRAC Settings - IPMI IP(IPv6)
    echo "04. iDRAC Settings - IPMI IP(IPv6) : $iDRAC_Settings_info4" >> "$OUTPUT_FILE"
    # iDRAC Settings - Redfish Support
    echo "05. iDRAC Settings - Redfish Support : $iDRAC_Settings_info5" >> "$OUTPUT_FILE"
    # iDRAC Settings - SSH Support
    echo "06. iDRAC Settings - SSH Support : $iDRAC_Settings_info6" >> "$OUTPUT_FILE"
    # iDRAC Settings - AD User Domain Name
    echo "07. iDRAC Settings - AD User Domain Name : $iDRAC_Settings_info7" >> "$OUTPUT_FILE"    
    # iDRAC Settings - SC Server Address
    echo "08. iDRAC Settings - SC Server Address : $iDRAC_Settings_info8" >> "$OUTPUT_FILE"
    # iDRAC Settings - SE AD RoleGroup Name
    echo "09. iDRAC Settings - SE AD RoleGroup Name : $iDRAC_Settings_info9" >> "$OUTPUT_FILE"
    # iDRAC Settings - SE AD RoleGroup Dome인
    echo "10. iDRAC Settings - SE AD RoleGroup Dome인 : $iDRAC_Settings_info10" >> "$OUTPUT_FILE"
    # iDRAC Settings - SE AD RoleGroup Privilege
    echo "11. iDRAC Settings - SE AD RoleGroup Privilege : $iDRAC_Settings_info11" >> "$OUTPUT_FILE"
    # iDRAC Settings - SE IDC RoleGroup Name
    echo "12. iDRAC Settings - IDC AD RoleGroup Name : $iDRAC_Settings_info12" >> "$OUTPUT_FILE"
    # iDRAC Settings - SE IDC RoleGroup Dome인
    echo "13. iDRAC Settings - IDC AD RoleGroup Domain : $iDRAC_Settings_info13" >> "$OUTPUT_FILE" 
    # iDRAC Settings - SE IDC RoleGroup Dome인
    echo "14. iDRAC Settings - IDC AD RoleGroup Privilege : $iDRAC_Settings_info14" >> "$OUTPUT_FILE"
    # iDRAC Settings - Remote Log (syslog)
    echo "15. iDRAC Settings - Remote Log (syslog) : $iDRAC_Settings_info15" >> "$OUTPUT_FILE"
    # iDRAC Settings - Remote Log (syslog)
    echo "16. iDRAC Settings - syslog server address 1 : $iDRAC_Settings_info16" >> "$OUTPUT_FILE"
    # iDRAC Settings - Remote Log (syslog)
    echo "17. iDRAC Settings - syslog server address 2 : $iDRAC_Settings_info17" >> "$OUTPUT_FILE"
    # iDRAC Settings - syslog server port
    echo "18. iDRAC Settings - syslog server port : $iDRAC_Settings_info18" >> "$OUTPUT_FILE"
    # iDRAC Settings - Remote KVM Nonsecure port
    echo "19. iDRAC Settings - Remote KVM Nonsecure port : $iDRAC_Settings_info19" >> "$OUTPUT_FILE"
    echo -e "\n" >> "$OUTPUT_FILE"
    
   # echo "---------------------------------------------Raid 설정 정보----------------------------------------------" >> "$OUTPUT_FILE"
    # RAID Settings - Raid Types
    #echo "01. RAID Settings - Raid ProductName : $RAID_info0" >> "$OUTPUT_FILE"    
    # RAID Settings - Raid Types
    #echo "02. RAID Settings - Raid Typest : $RAID_info1" >> "$OUTPUT_FILE"    
    # RAID Settings - StripeSize
    #echo "03. RAID Settings - StripeSize : $RAID_info2" >> "$OUTPUT_FILE"     
    # RAID Settings - ReadCachePolicy
    #echo "04. RAID Settings - ReadCachePolicy : $RAID_info3" >> "$OUTPUT_FILE" 
    # RAID Settings - ReadCachePolicy
    #echo "05. RAID Settings - WriteCachePolicy : $RAID_info4" >> "$OUTPUT_FILE"
    # RAID Settings - CheckConsistencyRate
    #echo "06. RAID Settings - CheckConsistencyRate : $RAID_info5" >> "$OUTPUT_FILE"
    # RAID Settings - PatrolReadMode
    #echo "07. RAID Settings - PatrolReadMode : $RAID_info6" >> "$OUTPUT_FILE"
    # RAID Settings - period
    #echo "08. RAID Settings - period : 168h" >> "$OUTPUT_FILE"
    # RAID Settings - Power Save
    #echo "09. RAID Settings - Power Save : No" >> "$OUTPUT_FILE"
    # RAID Settings - JBODMODE 
    #echo "10. RAID Settings - JBODMODE : Controller does not support JBOD" >> "$OUTPUT_FILE"    
    # RAID Settings - maxconcurrentpd
    #echo "11. RAID Settings - maxconcurrentpd : 240" >> "$OUTPUT_FILE"    
    
    # 임시 파일 삭제
    rm -f $IP_FILE
}

export -f fetch_idrac_info
export IDRAC_USER
export IDRAC_PASS
export OUTPUT_DIR

# 시작 시간 기록
START_TIME=$(date +%s)

# IP 목록 파일을 읽어 병렬로 작업 수행
fetch_idrac_info

# 종료 시간 기록
END_TIME=$(date +%s)

# 소요 시간 계산
ELAPSED_TIME=$(($END_TIME - $START_TIME))
ELAPSED_HOURS=$(($ELAPSED_TIME / 3600))
ELAPSED_MINUTES=$((($ELAPSED_TIME % 3600) / 60))
ELAPSED_SECONDS=$(($ELAPSED_TIME % 60))

echo "정보 수집 완료."
echo "수집 완료 시간: $ELAPSED_HOURS 시간, $ELAPSED_MINUTES 분, $ELAPSED_SECONDS 초."
