博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
DELL服务器硬件信息采集SHELL脚本
阅读量:4655 次
发布时间:2019-06-09

本文共 2129 字,大约阅读时间需要 7 分钟。

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

最近需要做资产列表,要采集DELL服务器的硬件信息,包括如下信息:
1、操作系统信息(类型,版本,内核,平台,主机名)
2、主板信息(厂商,机型,序列号)
3、CPU信息(型号,个数,物理核数)
4、内存(条数,单条容量)
5、磁盘(个数,单个容量,磁盘类型,Raid级别)
 执行前请先安装MegaRAID,为了提高工作效率,我们使用SHELL脚本来实现,如下:

#!/bin/sh #get os information function get_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"_"$bit\n"    printf "OS_DETAIL: $kname $nodename $kernal $bit\n"} get_os_info #get vendor, model, sn... function motherboard() {    vendor=`dmidecode -t 1|grep "Manufacturer"|awk '{print $2}'`    model=`dmidecode -t 1|grep "Product"|awk '{print $4}'`    sn=`dmidecode -t 1|grep "Serial" |awk '{print $3}'`    printf "MODEL: $vendor $model\n"    printf "SN: $sn\n"} motherboard function memory() {    count=`dmidecode  -q -t 17 2 |grep  "Size" |grep -v "No Module Installed"|awk '{print $2}'|uniq -c|awk '{print $1}'`    capacity=`dmidecode  -q -t 17 2 |grep  "Size" |grep -v "No Module Installed"|awk '{print $2}'|uniq -c|awk '{print $2}'`    capacity=`expr $capacity / 1024`    printf "MEM: $count"*"$capacity"G"\n"} memory function cpuinfo() {    cpu_model=`cat /proc/cpuinfo|grep "model name"|head -1|awk -F: '{print $2}'`    cpu_count=`cat /proc/cpuinfo|grep "core id"|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 function diskinfo() {    raidlevel=`/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL |grep "RAID"|awk '{print $3}'|cut -b 9-9`    disknumber=`/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL | grep "Drives"|awk -F ":" '{print $2}'`    disktype=`/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL | grep "PD Type"|head -1|awk -F: '{print $2}'`    diskcapacity=`/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL | grep "Raw Size" | head -1 | awk '{print $3}'`    printf "DISK: $disknumber"*"$diskcapacity"GB"$disktype (Raid Level: $raidlevel)\n"} diskinfo

 

转载于:https://www.cnblogs.com/Dev0ps/p/7844460.html

你可能感兴趣的文章
一系列网络流题目-2016.10.17
查看>>
第一次作业
查看>>
Codeforces Round #216 (Div. 2) E. Valera and Queries 树状数组 离线处理
查看>>
webpack初识一
查看>>
day 32 css后续补充以及js 简单入门
查看>>
android ViewSwitcher实现程序列表分屏和动画效果(仿Launcher)
查看>>
各版本android源码下载
查看>>
Android ADT安装
查看>>
nodejs初体验
查看>>
C# 将DataTable表中的数据批量插入到数据库表中的方法
查看>>
前博客 http://bbs.landingbj.com/mytopic.jsp?action=mytopic&username=57071
查看>>
edgeR使用学习【转载】
查看>>
2018徐州网络赛H. Ryuji doesn't want to study
查看>>
nodejs REPL清屏
查看>>
Io流笔记
查看>>
仿照tomcat服务器
查看>>
(转载)php中$_SERVER[PHP_SELF] 和 $_SERVER[SCRIPT_NAME]之间的区别
查看>>
[转]YII2 常用数据库操作
查看>>
Python基础检测:20171105
查看>>
...
查看>>