본문 바로가기

스크립트

하이퍼쓰레딩(Hyper Threading) 활성화 상태 확인하는 스크립트

반응형

하이퍼쓰레딩(Hyper Threading) 활성화 상태 확인하는 스크립트

vim cpu-HTT.sh
#!/bin/bash

# Function to print a separator line
print_separator() {
    printf -- "============================\n"
}

# Set the output file name
output_file="cpu.txt"

# HostName
hostname >> "$output_file"

# IP
#ifconfig bind0 | awk -F'[ :]+' '/inet addr/{print $4}' >> "$output_file"
ifconfig enp3s0f0 | grep -oP 'inet \K[\d.]+' >> "$output_file"

# Product Name
dmidecode -s system-product-name >> "$output_file"

# CPU Model Name
cpu_model=$(grep "model name" /proc/cpuinfo | head -n 1 | awk -F':' '{print $2}' | sed 's/^[[:space:]]*//')
echo "$cpu_model" >> "$output_file"

# CPU Socket
cpu_sockets=$(grep "physical id" /proc/cpuinfo | sort -u | wc -l)
echo "$cpu_sockets" >> "$output_file"

# CPU Core
cpu_cores=$(dmidecode -t processor | awk -F':' '/Core Count/{print $2}' | uniq | sed 's/^[[:space:]]*//')
echo "$cpu_cores" >> "$output_file"

print_separator
cat "$output_file"
print_separator

# Hyper-threading technology
total_threads=$(expr $cpu_sockets \* $cpu_cores \* 2)
actual_threads=$(grep processor /proc/cpuinfo | wc -l)

if [ "$total_threads" -eq "$actual_threads" ]; then
    echo "Hyper-threading Technology: Enabled"
else
    echo "Hyper-threading Technology: Disabled"
fi

# Remove the output file
rm -f "$output_file"
chmod +x cpu-HTT.sh
$ bash cpu-HTT.sh
============================
bind
192.168.20.22
ProLiant DL380p Gen8
Intel(R) Xeon(R) CPU E5-2650L 0 @ 1.80GHz
2
8
============================
Hyper-threading Technology: Disabled

 

728x90
반응형