|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们!此剧本已在ubuntu和centos版本上测试经由过程,剧本以下:
#!/bin/bash
Line============
#linux刊行版称号
if[[-f/usr/bin/lsb_release]];then
OS=$(/usr/bin/lsb_release-a|grepDescription|awk-F:{print$2}|seds/^[ ]*//g)
else
OS=$(cat/etc/issue|sed-n1p)
fi
echo-e"${Line}
OS:
${OS}
${Line}"
######################################################################################################
#检察体系是不是为64位:uname-m,若呈现x86_64,则为64位
OS_version=$(uname-m)
echo-e"OS_version:
${OS_version}
${Line}"
#体系内核版本
kernel_version=$(uname-r)
echo-e"Kernel_version:
${kernel_version}
${Line}"
#cpu型号
CPU=$(grepmodelname/proc/cpuinfo|uniq|awk-F:{print$2}|seds/^[ ]*//g|seds/+//g)
echo-e"CPUmodel:
${CPU}
${Line}"
#物理cpu个数
Counts=$(grepphysicalid/proc/cpuinfo|sort|uniq|wc-l)
echo-e"TotalofphysicalCPU:
${Counts}
${Line}"
#物理cpu内核数
Cores=$(grepcpucores/proc/cpuinfo|uniq|awk-F:{print$2}|seds/^[ ]*//g)
echo-e"NumberofCPUcores
${Cores}
${Line}"
#逻辑cpu个数
PROCESSOR=$(grepprocessor/proc/cpuinfo|sort|uniq|wc-l)
echo-e"NumberoflogicalCPUs:
${PROCESSOR}
${Line}"
#检察CPU以后运转形式是64位仍是32位
Mode=$(getconfLONG_BIT)
echo-e"PresentModeOfCPU:
${Mode}
${Line}"
#检察CPU是不是撑持64位手艺:grepflags/proc/cpuinfo,若flags信息中包括lm字段,则撑持64位
Numbers=$(greplm/proc/cpuinfo|wc-l)
if((${Numbers}>0));thenlm=64
elselm=32
fi
echo-e"SupportModeOfCPU:
${lm}
${Line}"
######################################################################
#Memtotal内存总巨细
Total=$(cat/proc/meminfo|grepMemTotal|awk-F:{print$2}|seds/^[ ]*//g)
echo-e"TotalMemory:
${Total}
${Line}"
#体系撑持最年夜内存
Max_Capacity=$(dmidecode-tmemory-q|grepMaximumCapacity|awk-F:{print$2}|seds/^[ ]*//g)
echo-e"MaxinumMemoryCapacity:
${Max_Capacity}
${Line}"
#检察内存范例、频次、条数、最年夜撑持内存等信息:dmidecode-tmemory,或dmidecode|grep-A16"MemoryDevice$"
#上面为统计内存条数
Number=$(dmidecode|grep-A16"MemoryDevice$"|grepSize|sort|seds/^[ ]*//g|grep-vNoModuleInstalled|wc-l)
echo-e"NumberofPhysicalMemory:
${Number}
${Line}"
#SwapTotalswap分区总巨细
SwapTotal=$(cat/proc/meminfo|grepSwapTotal|awk-F:{print$2}|seds/^[ ]*//g)
echo-e"TotalSwap:
${SwapTotal}
${Line}"
#Bufferssize
Buffers=$(cat/proc/meminfo|grepBuffers|awk-F:{print$2}|seds/^[ ]*//g)
echo-e"Buffers:
${Buffers}
${Line}"
#Cachedsize
Cached=$(cat/proc/meminfo|grep<Cached>|awk-F:{print$2}|seds/^[ ]*//g)
echo-e"Cached:
${Cached}
${Line}"
#余暇内存+buffers/cache
Available=$(free-m|grep-|awk-F:{print$2}|awk{print$2})
echo-e"AvailableMemory:
${Available}MB
${Line}"
#显现硬盘,和巨细
Disk=$(fdisk-l|grepDisk|awk-F,{print$1}|seds/Diskidentifier.*//g|sed/^$/d)
echo-e"AmountOfDisks:
${Disk}
${Line}"
#各挂载分区利用情形
Partion=$(df-hlP|sed-n2,$p)
echo-e"UsageOfpartions:
${Partion}
${Line}"
----------------------------------------------------------------------------------------
测试了局展现:
===========
OS:
RedHatEnterpriseLinuxServerrelease5.6(Tikanga)
===========
OS_version:
i686
===========
Kernel_version:
2.6.18-238.el5
===========
CPUmodel:
AMDA6-3400MAPUwithRadeon(tm)HDGraphics
===========
TotalofphysicalCPU:
2
===========
NumberofCPUcores
2
===========
NumberoflogicalCPUs:
4
===========
PresentModeOfCPU:
32
===========
SupportModeOfCPU:
64
===========
TotalMemory:
514744kB
===========
MaxinumMemoryCapacity:
1024GB
===========
NumberofPhysicalMemory:
1
===========
TotalSwap:
1044216kB
===========
Buffers:
101936kB
===========
Cached:
267356kB
===========
AvailableMemory:
369MB
===========
AmountOfDisks:
Disk/dev/sda:107.3GB
===========
UsageOfpartions:
/dev/sda396G4.6G87G6%/
/dev/sda199M12M83M13%/boot
tmpfs252M0252M0%/dev/shm
/dev/hdc3.0G3.0G0100%/media/RHEL_5.6i386DVD
===========
本文出自“Linux手艺”博客,请务必保存此出处http://chenronghua.blog.51cto.com/7972352/1309854
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们! |
|