A-A+

快速查看服务器硬件配置信息

2013年07月22日 系统运维 暂无评论 阅读 585 次

a7c5f6c2gw1e6055giz74j20dw0af3z3.jpg (500×375)

通过shell脚本查看服务器的硬件信息和系统的版本信息等情况

#!/bin/bash
if [[ -f /usr/bin/lsb_release ]]; then
OS=$(/usr/bin/lsb_release -a |grep Description |awk -F : '{print $2}' |sed 's/^[ t]*//g')
else
OS=$(cat /etc/issue |sed -n '1p')
fi
OS_version=$(uname -m)
kernel_version=$(uname -r)
CPU=$(grep 'model name' /proc/cpuinfo |uniq |awk -F : '{print $2}' |sed 's/^[ t]*//g'  |sed 's/ +/ /g')
Counts=$(grep 'physical id' /proc/cpuinfo |sort |uniq |wc -l)
Cores=$(grep 'cpu cores' /proc/cpuinfo |uniq |awk -F : '{print $2}' |sed 's/^[ t]*//g')
PROCESSOR=$(grep 'processor' /proc/cpuinfo |sort |uniq |wc -l)
Mode=$(getconf LONG_BIT)

Numbers=$(grep 'lm' /proc/cpuinfo |wc -l)
if (( ${Numbers} > 0)); then lm=64
else lm=32
fi

Total=$(cat /proc/meminfo |grep 'MemTotal' |awk -F : '{print $2}' |sed 's/^[ t]*//g')
Number=$(dmidecode | grep -A16 "Memory Device$" |grep Size|sort |sed 's/^[ t]*//g')
SwapTotal=$(cat /proc/meminfo |grep 'SwapTotal' |awk -F : '{print $2}' |sed 's/^[ t]*//g')
Buffers=$(cat /proc/meminfo |grep 'Buffers' |awk -F : '{print $2}' |sed 's/^[ t]*//g')
Cached=$(cat /proc/meminfo |grep '<Cached>' |awk -F : '{print $2}' |sed 's/^[ t]*//g')
Available=$(free -m |grep - |awk -F : '{print $2}' |awk '{print $2}')
Max_Capacity=$(dmidecode -t memory -q |grep 'Maximum Capacity' |awk -F : '{print $2}' |sed 's/^[ t]*//g')

Disk=$(fdisk -l |grep 'Disk' |awk -F , '{print $1}')
Partion=$(df -hlP |sed -n '2,$p')

Line='==========='

echo -e "${Line}nOS:n${OS}n${Line}"
echo -e "OS_version:n${OS_version}n${Line}"
echo -e "Kernel_version:n${kernel_version}n${Line}"
echo -e "CPU model:n${CPU}n${Line}"
echo -e "Total of physical CPU:n${Counts}n${Line}"
echo -e "Number of CPU coresn${Cores}n${Line}"
echo -e "Number of logical CPUs:n${PROCESSOR}n${Line}"
echo -e "Present Mode Of CPU:n${Mode}n${Line}"
echo -e "Support Mode Of CPU:n${lm}n${Line}"
echo -e "Total Memory:n${Total}n${Line}"
echo -e "Total Swap:n${SwapTotal}n${Line}"
echo -e "Buffers:n${Buffers}n${Line}"
echo -e "Cached:n${Cached}n${Line}"
echo -e "Available Memory:n${Available} MBn${Line}"
echo -e "Maxinum Memory Capacity:n${Max_Capacity}n${Line}"
echo -e "Number of Physical Memory:n${Number}n${Line}"
echo -e "Amount Of Disks:n${Disk}n${Line}"
echo -e "Usage Of partions:n${Partion}n${Line}"

 

给我留言

Copyright © 2011-2016 零下二十四度Theme By  Ality  京ICP备16007547号   关于本站

用户登录