来一发猎取CentOS办事器信息shell剧本
如果您觉得本篇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教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们!
来一发猎取CentOS办事器信息shell剧本
没人回帖。。。我来个吧 未来的学习之路将是以指数增加的方式增长的。从网管员来说,命令行实际上就是规则,它总是有效的,同时也是灵活的。 笔者五分钟后就给出了解决方法: “首先备份原文件到其他目录,然后删掉/usr/local/unispim/unispimsp.ksc,编辑 /usr/local/unispim/unispimsp.ini,最后重启动计算机 再次,Linux是用C语言编写的,我们有学习C语言的基础,读程序和编写代码方面存在的困难小一点,也是我们能较快掌握的原因之一。? 安装一个新的软件时先看README,再看INSTALL然后看FAQ,最后才动手安装,这样遇到问题就知道为什么。如果Linux说明文档不看,结果出了问题再去论坛来找答案反而浪费时间。 让我树立了很大的信心学好这门课程,也学到了不少专业知识和技能。?
页:
[1]