#!/bin/bash # ================================================ # 脚本名称: 高级系统信息查询工具 # 描述: 该脚本用于查询系统详细信息,采用彩色美化输出 # 版本: 2.0 # 作者: 基于DHDAXCW脚本优化 # ================================================ # 颜色定义 BLACK='\033[0;30m' RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' WHITE='\033[0;37m' BRIGHT_BLACK='\033[0;90m' BRIGHT_RED='\033[0;91m' BRIGHT_GREEN='\033[0;92m' BRIGHT_YELLOW='\033[0;93m' BRIGHT_BLUE='\033[0;94m' BRIGHT_PURPLE='\033[0;95m' BRIGHT_CYAN='\033[0;96m' BRIGHT_WHITE='\033[0;97m' NC='\033[0m' # No Color # 边框样式 border_top() { echo -e "${BRIGHT_BLUE}┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓${NC}" } border_bottom() { echo -e "${BRIGHT_BLUE}┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛${NC}" } border_middle() { echo -e "${BRIGHT_BLUE}┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫${NC}" } section_title() { echo -e "${BRIGHT_BLUE}┃ ${BRIGHT_CYAN}$1${BRIGHT_BLUE}${NC}" } item_output() { echo -e "${BRIGHT_BLUE}┃ ${YELLOW}$1${BRIGHT_WHITE}$2${NC}" } # 清屏并显示标题 clear border_top section_title " 🚀 高级系统信息查询工具" border_middle # CPU 信息 section_title "🧠 CPU 详细信息" item_output "总核心数: " "$(nproc)" if [ -f /proc/cpuinfo ]; then item_output "型号名称: " "$(grep 'model name' /proc/cpuinfo | head -n1 | cut -d':' -f2 | sed 's/^\s*//')" item_output "当前频率: " "$(grep 'cpu MHz' /proc/cpuinfo | head -n1 | cut -d':' -f2 | sed 's/^\s*//') MHz" item_output "缓存大小: " "$(grep 'cache size' /proc/cpuinfo | head -n1 | cut -d':' -f2 | sed 's/^\s*//')" item_output "架构类型: " "$(lscpu | grep 'Architecture' | cut -d':' -f2 | sed 's/^\s*//')" item_output "每插槽核心数: " "$(lscpu | grep 'Core(s) per socket' | cut -d':' -f2 | sed 's/^\s*//')" item_output "每核心线程数: " "$(lscpu | grep 'Thread(s) per core' | cut -d':' -f2 | sed 's/^\s*//')" MAX_FREQ=$(lscpu | grep -E 'CPU max MHz|CPU MHz max' | cut -d':' -f2 | sed 's/^\s*//') MIN_FREQ=$(lscpu | grep -E 'CPU min MHz|CPU MHz min' | cut -d':' -f2 | sed 's/^\s*//') item_output "最大频率: " "${MAX_FREQ:-未知} MHz" item_output "最小频率: " "${MIN_FREQ:-未知} MHz" else echo -e "${BRIGHT_BLUE}┃ ${RED}CPU 信息不可用(/proc/cpuinfo 文件缺失)${NC}" fi border_middle # 内存信息 section_title "💾 内存信息" free_output=$(free -h) echo -e "${BRIGHT_BLUE}┃ ${BRIGHT_GREEN}${free_output}${NC}" | sed 's/^/┃ /' border_middle # 磁盘信息 section_title "📦 磁盘信息" df_output=$(df -h | grep -E '^/dev/') echo -e "${BRIGHT_BLUE}┃ ${BRIGHT_GREEN}${df_output}${NC}" | sed 's/^/┃ /' border_middle # 网卡信息 section_title "🌐 网络接口信息" if command -v ethtool >/dev/null 2>&1; then for iface in $(ip -br addr show | awk '{print $1}' | grep -v '^lo$'); do echo -e "${BRIGHT_BLUE}┃ ${YELLOW}接口名称: ${BRIGHT_PURPLE}$iface${NC}" echo -e "${BRIGHT_BLUE}┃ ${GREEN}状态: ${BRIGHT_CYAN}$(ip -br addr show | grep "^$iface" | awk '{print $2}')${NC}" echo -e "${BRIGHT_BLUE}┃ ${GREEN}IP 地址: ${BRIGHT_CYAN}$(ip -br addr show | grep "^$iface" | awk '{print $3}')${NC}" echo -e "${BRIGHT_BLUE}┃ ${GREEN}速率: ${BRIGHT_CYAN}$(ethtool "$iface" 2>/dev/null | grep 'Speed:' | awk '{print $2}' || echo '未知')${NC}" echo -e "${BRIGHT_BLUE}┃${NC}" done else echo -e "${BRIGHT_BLUE}┃ ${YELLOW}ethtool 未安装,仅显示基本网卡信息${NC}" ip -br addr show | awk '{print "'"${BRIGHT_BLUE}┃ ${GREEN}接口: ${BRIGHT_CYAN}"' $1 "'"${GREEN}\t状态: ${BRIGHT_CYAN}"' $2 "'"${GREEN}\tIP: ${BRIGHT_CYAN}"' $3 "'"${NC}"'"}' fi border_middle # 系统详情 section_title "🖥️ 系统详情" item_output "内核信息: " "$(uname -a)" [ -f /proc/version ] && item_output "版本信息: " "$(cat /proc/version)" [ -f /etc/issue.net ] && item_output "发行版 (net): " "$(cat /etc/issue.net)" [ -f /etc/issue ] && item_output "发行版: " "$(cat /etc/issue)" border_middle # 资源限制 section_title "🔒 资源限制" ulimit_output=$(ulimit -a) echo -e "${BRIGHT_BLUE}┃ ${BRIGHT_GREEN}${ulimit_output}${NC}" | sed 's/^/┃ /' border_bottom # 结束信息 echo -e "\n${BRIGHT_BLUE}┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓${NC}" echo -e "${BRIGHT_BLUE}┃ ${BRIGHT_GREEN}系统信息查询完成 ${BRIGHT_YELLOW}✔${BRIGHT_BLUE} ┃${NC}" echo -e "${BRIGHT_BLUE}┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛${NC}\n"