DELL服务器硬件信息采集SHELL脚本
DELL服务器硬件信息采集SHELL脚本
最近需要做资产列表,要采集DELL服务器的硬件信息,包括如下信息:
1、操作系统信息(类型,版本,内核,平台,主机名)
2、主板信息(厂商,机型,序列号)
3、CPU信息(型号,个数,物理核数)
4、内存(条数,单条容量)
5、磁盘(个数,单个容量,磁盘类型,Raid级别)
执行前请先安装MegaRAID,为了提高工作效率,我们使用SHELL脚本来实现,如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #!/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/MegaCli 64 -LDInfo -Lall -aALL |grep "RAID" |awk '{print $3}' |cut -b 9 -9 ` disknumber=`/opt/MegaRAID/MegaCli/MegaCli 64 -LDInfo -Lall -aALL | grep "Drives" |awk -F ":" '{print $2}' ` disktype=`/opt/MegaRAID/MegaCli/MegaCli 64 -PDList -aALL | grep "PD Type" |head -1 |awk -F: '{print $2}' ` diskcapacity=`/opt/MegaRAID/MegaCli/MegaCli 64 -PDList -aALL | grep "Raw Size" | head -1 | awk '{print $3}' ` printf "DISK: $disknumber" * "$diskcapacity" GB "$disktype (Raid Level: $raidlevel)\n" } diskinfo |
如对您有帮助,支持下呗!
微信

支付宝

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类