前言:
此刻你们对“linux扫描硬件”可能比较着重,同学们都想要分析一些“linux扫描硬件”的相关知识。那么小编同时在网摘上网罗了一些关于“linux扫描硬件””的相关知识,希望小伙伴们能喜欢,小伙伴们快快来了解一下吧!#!/bin/bash>/opt/script/hardwareinfo.txt>noip.txtecho "######## start check ########"echo "Please wait ............."echo "######## `date +%Y-%m-%d` start check ########" >>/opt/script/hardwareinfo.txtfor ip in `cat /opt/script/ntp.txt`do ping -c 2 -w 3 ${ip} >/dev/null 2>&1 if [ $? -eq 1 ];then echo "$ip不通" echo $ip >>/opt/script/noip.txt else echo "$ip硬件配置情况如下:">>/opt/script/hardwareinfo.txt echo "CPU 数量:">>/opt/script/hardwareinfo.txt ssh $ip cat /proc/cpuinfo |grep "physical id"|sort |uniq| wc -l >>/opt/script/hardwareinfo.txt echo "CPU 型号:">>/opt/script/hardwareinfo.txt ssh $ip cat /proc/cpuinfo |grep name |sed -n '1p'| awk '{print $4 $5 $6 $7 $8 $9}' >>/opt/script/hardwareinfo.txt echo "CPU 核心数:">>/opt/script/hardwareinfo.txt ssh $ip cat /proc/cpuinfo | grep "processor" |wc -l >>/opt/script/hardwareinfo.txt echo "内存(M):">>/opt/script/hardwareinfo.txt ssh $ip free -m |awk '{print $2}'|sed -n '2p' >>/opt/script/hardwareinfo.txt echo "硬盘容量(G):">>/opt/script/hardwareinfo.txt ssh $ip /sbin/fdisk -l |sed -n '2p'|awk '{print $2}' >>/opt/script/hardwareinfo.txt echo "网卡数量:">>/opt/script/hardwareinfo.txt ssh $ip /sbin/lspci | grep Ethernet | wc -l >>/opt/script/hardwareinfo.txt echo "服务器序列号:">>/opt/script/hardwareinfo.txt ssh $ip /usr/sbin/dmidecode | grep -i 'serial number' | sed -n '1p' | awk '{print $3}' >>/opt/script/hardwareinfo.txt echo "服务器型号:">>/opt/script/hardwareinfo.txt ssh $ip /usr/sbin/dmidecode | grep -i 'Product Name' | sed -n '1p' | awk '{print $3 $4}' >>/opt/script/hardwareinfo.txt echo "服务器操作系统版本:">>/opt/script/hardwareinfo.txt ssh $ip cat /etc/redhat-release >>/opt/script/hardwareinfo.txt echo "服务器内核版本:">>/opt/script/hardwareinfo.txt ssh $ip /bin/uname -srmo >>/opt/script/hardwareinfo.txt echo "####### check end ###########" >>/opt/script/hardwareinfo.txt fidoneecho "####### check end ###########"echo "####### `date +%Y-%m-%d` check end ###########" >>/opt/script/hardwareinfo.txt
效果如下:
10.1.1.1硬件配置情况如下:
CPU 数量:
2
CPU 型号:
Intel(R)Xeon(R)CPUE5-2620v2@
CPU 核心数:
24
内存(M):
128707
硬盘容量(G):
/dev/sda:9999.2
网卡数量:
4
服务器序列号:
xxxxxxxxx
服务器型号:
PowerEdgeR720xd
服务器操作系统版本:
CentOS Linux release 7.1.1503 (Core)
服务器内核版本:
Linux 3.10.0-229.el7.x86_64 x86_64 GNU/Linux
####### check end ###########
ntp.txt文件就是一行一个IP地址就行
标签: #linux扫描硬件