Check System Details

# Gather machine configuration information
echo "Machine Configuration"
echo "----------------------"

# Operating System
echo "Operating System: $(lsb_release -d | cut -f2-)"

# CPU Information
echo "CPU: $(lscpu | awk -F: '/Model name/ {print $2}' | xargs)"
echo "Processors: $(lscpu | awk -F: '/Socket(s)/ {print $2}' | xargs)"
echo "Physical Cores: $(lscpu | awk -F: '/Core(s) per socket/ {print $2}' | xargs)"
echo "Cores: $(nproc)"

# RAM Information
echo "RAM: $(free -h | awk '/^Mem/ {print $2}')"

# Network Details
echo "Network Details"
echo "----------------"

# Iterate through network interfaces and retrieve details
while read -r interface; do
    interface_name=$(echo "$interface" | cut -d':' -f1 | xargs)
    manufacturer_model=$(lspci | grep -i "$interface_name" | cut -d':' -f3- | xargs)
    speed=$(ethtool "$interface_name" | awk -F: '/Speed/ {print $2}' | xargs)

    echo "NIC: $interface_name"
    echo "Manufacturer & Model: $manufacturer_model"
    echo "Speed: $speed"
done < <(ip link show | grep 'state UP')

# Check if NVIDIA GPU is present
if lspci | grep -i 'NVIDIA' &>/dev/null; then
    echo "GPU Details"
    echo "----------------"
    echo "NVIDIA GPU: $(lspci | grep -i 'NVIDIA' | cut -d':' -f3- | xargs)"

    # Extract GPU details using nvidia-smi
    GPU_MEMORY=$(nvidia-smi --query-gpu=memory.total --format=csv,noheader,nounits | xargs)
    GPU_CORES=$(nvidia-smi --query-gpu=cuda_cores --format=csv,noheader,nounits | xargs)
    GPU_MANUFACTURER=$(nvidia-smi --query-gpu=name --format=csv,noheader,nounits | xargs)

    echo "GPU Memory: $GPU_MEMORY"
    echo "GPU Cores: $GPU_CORES"
    echo "GPU Manufacturer: $GPU_MANUFACTURER"
fi

if [ -z "$GPU_MEMORY" ]; then
    echo "No NVIDIA GPU detected."
fi