Linux配置简单采集

#!/bin/bash
#CPU逻辑个数
cpu_processor=$(cat /proc/cpuinfo | grep processor | wc -l)
#CPU物理个数
cpu_num=$(cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l)
#物理内存
server_memory=$(cat /proc/meminfo | grep "MemTotal" | awk '{print $2/1024/1024}')
#GB
disk_GB=$(df -P -B 1m | awk '{print $2}' | grep -v '[^0-9]' | awk NF | awk 'BEGIN {count=0;} {count=count+$0;} END{print count/1024}') printf "CPU逻辑个数:%s\nCPU物理个数: %s\n物理内存: %s\n磁盘容量:%s\n" $cpu_processor $cpu_num $server_memory $disk_GB
上一篇:Python编程小技巧(一)


下一篇:codevs 1576 最长严格上升子序列