DELL服务器硬件信息采集SHELL脚本,dell采集shell脚本


最近需要做资产列表,要采集DELL服务器的硬件信息,包括如下信息:

1、操作系统信息(类型,版本,内核,平台,主机名)

2、主板信息(厂商,机型,序列号)

3、CPU信息(型号,个数,物理核数)

4、内存(条数,单条容量)

5、磁盘(个数,单个容量,磁盘类型,Raid级别)

执行前请先安装MegaRAID,为了提高工作效率,我们使用SHELL脚本来实现,如下:

#!/bin/sh

#getosinformation

functionget_os_info(){

release=`cat/etc/redhat-release|awk'{print$1"_"$3}'`

kname=`uname-s`

nodename=`uname-n`

kernal=`uname-r`

bit=`uname-i`

printf"OS_RELEASE:$release"_"$bitn"

printf"OS_DETAIL:$kname$nodename$kernal$bitn"

}

get_os_info

#getvendor,model,sn...

functionmotherboard(){

vendor=`dmidecode-t1|grep"Manufacturer"|awk'{print$2}'`

model=`dmidecode-t1|grep"Product"|awk'{print$4}'`

sn=`dmidecode-t1|grep"Serial"|awk'{print$3}'`

printf"MODEL:$vendor$modeln"

printf"SN:$snn"

}

motherboard

functionmemory(){

count=`dmidecode-q-t172|grep"Size"|grep-v"NoModuleInstalled"|awk'{print$2}'|uniq-c|awk'{print$1}'`

capacity=`dmidecode-q-t172|grep"Size"|grep-v"NoModuleInstalled"|awk'{print$2}'|uniq-c|awk'{print$2}'`

capacity=`expr$capacity/1024`

printf"MEM:$count"*"$capacity"G"n"

}

memory

functioncpuinfo(){

cpu_model=`cat/proc/cpuinfo|grep"modelname"|head-1|awk-F:'{print$2}'`

cpu_count=`cat/proc/cpuinfo|grep"coreid"|grep"0"|uniq-c|awk'{print$1}'`

cpu_total_cores=`cat/proc/cpuinfo|grep"processor"|wc-l`

single_cores=`expr$cpu_total_cores/$cpu_count`

printf"CPU:$cpu_model($cpu_count"*"$single_cores"Cores")n"

}

cpuinfo

functiondiskinfo(){

raidlevel=`/opt/MegaRAID/MegaCli/MegaCli64-LDInfo-Lall-aALL|grep"RAID"|awk'{print$3}'|cut-b9-9`

disknumber=`/opt/MegaRAID/MegaCli/MegaCli64-LDInfo-Lall-aALL|grep"Drives"|awk-F":"'{print$2}'`

disktype=`/opt/MegaRAID/MegaCli/MegaCli64-PDList-aALL|grep"PDType"|head-1|awk-F:'{print$2}'`

diskcapacity=`/opt/MegaRAID/MegaCli/MegaCli64-PDList-aALL|grep"RawSize"|head-1|awk'{print$3}'`

printf"DISK:$disknumber"*"$diskcapacity"GB"$disktype(RaidLevel:$raidlevel)n"

}

diskinfo

脚本执行结果如下:

OS_RELEASE:CentOS_6.5_x86_64

OS_DETAIL:Linuxappsrv2.6.32-431.el6.x86_64x86_64

MODEL:DellR730

SN:CDFGHJL

MEM:4*8G

CPU:Intel(R)Xeon(R)CPUE5-2630v3@2.40GHz(2*8Cores)

DISK:2*279.396GBSAS(RaidLevel:1)


相关内容

    暂无相关文章