-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
# 获取CPU信息 | ||
cpu_count=$(grep -c '^processor' /proc/cpuinfo) | ||
cpu_model=$(grep 'model name' /proc/cpuinfo | awk -F ': ' '{print $2}' | head -1) | ||
cpu_frequency=$(grep 'cpu MHz' /proc/cpuinfo | awk -F ': ' '{print $2}' | head -1) | ||
|
||
# 获取内存信息(以MB为单位) | ||
mem_total=$(free -m | awk '/^Mem:/ {print $2}') | ||
mem_used=$(free -m | awk '/^Mem:/ {print $3}') | ||
mem_free=$(free -m | awk '/^Mem:/ {print $4}') | ||
|
||
# 获取硬盘信息 | ||
disk_total=$(df -h --output=size / | awk 'NR==2' | sed 's/G//') | ||
disk_used=$(df -h --output=used / | awk 'NR==2' | sed 's/G//') | ||
disk_free=$(df -h --output=avail / | awk 'NR==2' | sed 's/G//') | ||
|
||
# 输出结果 | ||
echo "--------系统信息---------" | ||
echo -e "CPU数量:$cpu_count | CPU频率:$cpu_frequency MHz" | ||
echo -e "CPU型号:$cpu_model" | ||
echo "------------------------" | ||
echo -e "内存大小:$mem_total MB | 已使用:$mem_used MB | 未使用:$mem_free MB" | ||
echo "------------------------" | ||
echo -e "磁盘大小:$disk_total G | 已使用:$disk_used G | 未使用:$disk_free G" | ||
echo "------------------------" |