# 检查iostat是否已经安装
# if command -v iostat &> /dev/null
# then
   # echo "iostat is already installed."
# else
   # echo "iostat is not installed. Attempting to install..."

    # 尝试使用apt-get（用于Debian、Ubuntu等）
   # if command -v apt-get &> /dev/null#
   # then
      # sudo apt-get update
      # sudo apt-get install -y sysstat
    # 尝试使用yum（用于CentOS、RHEL等）
   # elif command -v yum &> /dev/null
   # then
       # sudo yum install -y sysstat
   # else
       # echo "Could not install iostat. Package manager not found."
       # exit 1
   # fi
# fi



检查是否已经安装版本检测
if command -v lsb_release &> /dev/null
then
   echo "lsb_release is already installed."
else
   echo "lsb_release is not installed. Attempting to install..."

    尝试使用apt-get（用于Debian、Ubuntu等）
   if command -v apt-get &> /dev/null#
   then
      sudo apt-get update
      sudo apt-get install lsb-release
    尝试使用yum（用于CentOS、RHEL等）
   elif command -v yum &> /dev/null
   then
       sudo yum install redhat-lsb-core
   else
       echo "Could not install lsb_release. Package manager not found."
       exit 1
   fi
fi

# 定义输出文件
output_file="system_info.txt"

# 获取主机名
hostnamectl set-hostname k8s_node01
echo "主机名：" >> $output_file
hostname >> $output_file
echo "" >> $output_file

获取系统版本
echo "系统版本：" >> $output_file
uname -a >> $output_file
echo "" >> $output_file

# # 获取CPU型号
# echo "CPU型号：" >> $output_file
# lscpu | grep "Model name" >> $output_file
# echo "" >> $output_file

# # 获取内存大小
# echo "内存大小：" >> $output_file
# free -h | grep "Mem" >> $output_file
# echo "" >> $output_file

# # 获取磁盘大小
# echo "磁盘大小：" >> $output_file
# df -h >> $output_file
# echo "" >> $output_file

# # 获取磁盘IOPS
# echo "磁盘IOPS：" >> $output_file
# iostat >> $output_file
# echo "" >> $output_file

# 获取网络地址
echo "网络地址：" >> $output_file
ip addr >> $output_file
echo "" >> $output_file

# # 获取网卡信息
# echo "网卡信息：" >> $output_file
# lshw -class network >> $output_file
# echo "" >> $output_file


