ironic-inspector硬件信息收集
主机上报
ironic-inspector流程会在小系统里收集裸机的硬件信息,然后上报到ironic-conductor。
其中收集硬件信息主要使用hwinfo和lshw命令。Centos可以使用如下命令安装:
yum -y install lshw
yum -y install hwinfo
cpu核心数
function cpu_cores() {
hwinfo --cpu | grep -c "Hardware Class: cpu"
}
磁盘大小
function disk() {
# XXX: This is returning only the first disk discovered, which is very likely to be insufficient on machines that present us with multiple disks
# XXX: This is likely reporting in TB, but the units are not guaranteed. Maybe convert to bytes?
lshw -C disk | grep size | awk -F'(' '{ print $2 }' | tr -d ')' | head -1
}
从上面的代码可以看出在存在多块硬盘的时候,上报的是第一块硬盘。
如果环境做过raid,看到的是raid之后的盘。
lshw -C disk看到的具体内容如下:
[root@64ef4b1c9859459da8f0387fc880b590 home]# lshw -C disk
*-disk
description: SCSI Disk
product: ServeRAID M5210
vendor: IBM
physical id: 2.0.0
bus info: scsi@0:2.0.0
logical name: /dev/sda
version: 4.62
serial: 00643eae284ef5a51f3023ed0bb00506
size: 557GiB (598GB)
capabilities: partitioned partitioned:dos
configuration: ansiversion=5 logicalsectorsize=512 sectorsize=512 signature=0009c5fd
*-cdrom
description: DVD-RAM writer
product: DVD-RW DU8A6SH
vendor: PLDS
physical id: 0.0.0
bus info: scsi@1:0.0.0
logical name: /dev/cdrom
logical name: /dev/sr0
version: DL64
capabilities: removable audio cd-r cd-rw dvd dvd-r dvd-ram
configuration: ansiversion=5 status=nodisc
内存大小
function ram() {
# XXX: /proc may not be the best place to get this from, but hwinfo reports weird values (e.g. "1GB + 512MB" on a test VM of mine)
_KB=$(grep MemTotal /proc/meminfo | awk '{ print $2 }')
echo "$((_KB * 1024)) bytes"
}
这里内存信息的获取也是使用的/proc/meminfo。但是这一点与我们在
ironic node show $NODE_ID里看到的还是有差异,在社区文档上
有这么一段解释:
RAM information: total (total size in bytes), physical_mb
(physically installed memory size in MiB, optional).
Note The difference is that the latter includes the memory region reserved by
the kernel and is always slightly bigger. It also matches what the Nova
flavor would contain for this node and thus is used by the inspection
process instead of total.
翻译过来就是我们最终看到的内存是kernel预留的 + /proc/meminfo看到的。
reserve_memory可以通过dmesg |grep reserve来查看,具体如下:
[ 0.000000] Memory: 228249932k/236978176k available (6449k kernel code, 2680172k absent, 6048072k reserved, 4273k data, 1624k init)
raw disk
function raw_network() {
hwinfo --network
}
raw network
function raw_network() {
hwinfo --network
}
pxe mac
function pxe_mac() {
local bootif_re='BOOTIF=([^ ]+)' _mac
if [[ $(cat /proc/cmdline) =~ $bootif_re ]]; then
# If we were booted using pxelinux and its config file has the
# IPAPPEND 2 stanza under the entry we booted from, then pxelinux
# will have appended a BOOTIF argument to the kernel parameters telling
# us what MAC address we are booting with. From that, we can derive the
# boot interface with no problems.
_mac="${BASH_REMATCH[1]//-/:}"
_mac="${_mac#*:}"
elif [[ -d /sys/firmware/efi ]] && which efibootmgr &>/dev/null; then
# Likewise, if we booted via the network while running in UEFI mode, and
# efibootmgr is installed, we can determine the MAC address of the nic we
# booted from. It would be good to have code that can also do this using
# efivars or parsing the stuff under /sys/firmware/efi/efivars directly,
# but that is a trickier thing to do.
local -A boot_entries
local bootent_re='^Boot([0-9]{4})'
local efimac_re='MAC\(([0-9a-f]+)'
local k v current_bootent
while read line; do
k="${line%% *}"
v="${line#* }"
if [[ $k = BootCurrent:* ]]; then
current_bootent="${line##BootCurrent: }"
elif [[ $k =~ $bootent_re ]]; then
boot_entries["${BASH_REMATCH[1]}"]="$v"
fi
done < <(efibootmgr -v)
if [[ ${boot_entries["$current_bootent"]} =~ $efimac_re ]]; then
_mac=''
for o in 0 2 4 6 8 10; do
_mac+="${BASH_REMATCH[1]:$o:2}:"
done
_mac=${_mac%:}
fi
fi
if [[ ! $_mac ]]; then
# If none of the exact methods worked, fall back on the heuristic
# method and just return the mac addresses of all the interfaces
# that have a link. Hopefully whatever consumes this info is smarter
# than we are.
local _info1 _info2 _dev
_info1=$(hwinfo --network|grep -B2 "Link detected: yes"|grep -C1 "HW Address:")
_info2=$(echo "${_info1}"|awk '/Device File: (vlan*|br*)/{for(x=NR-2;x<=NR+2;x++)d[x];}{a[NR]=$0}END{for(i=1;i<=NR;i++)if(!(i in d))print a[i]}')
_dev=$(echo "${_info1}" | grep "Device File:"|awk -F':' {'print $2'}|tr -d ' ')
_mac=$(echo "${_info2}" | grep "HW Address:"|awk -F'ss:' {'print $2'}|tr -d ' ')
fi
echo $_mac
export HW_DISCOVERY_BOOT_IFACE="$_mac"
}
ironic-inspector硬件信息收集的更多相关文章
- 10 个用于收集硬件信息的 Linux 命令
知道自己的Linux系统运行在什么样的硬件组件上总是好的,因为如果涉及到在系统上安装软件包和驱动程序的话,这将有助于你处理兼容性问题. 因此,下面我们将给出一些非常有用的命令,它们可以帮助你提取你的L ...
- Linux检查和收集硬件信息的常用命令总结
Linux检查和收集硬件信息的常用命令总结 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. Linux基础真的很重要,基础不牢,地动山摇.这句话我是听老男孩创始人冉总说的一句话,起初 ...
- 最简单的方法是使用标准的 Linux GUI 程序之一: i-nex 收集硬件信息,并且类似于 Windows 下流行的 CPU-Z 的显示。 HardInfo 显示硬件具体信息,甚至包括一组八个的流行的性能基准程序,你可以用它们评估你的系统性能。 KInfoCenter 和 Lshw 也能够显示硬件的详细信息,并且可以从许多软件仓库中获取。
最简单的方法是使用标准的 Linux GUI 程序之一: i-nex 收集硬件信息,并且类似于 Windows 下流行的 CPU-Z 的显示. HardInfo 显示硬件具体信息,甚至包括一组八个的流 ...
- 检查和收集 Linux 硬件信息的 7 个命令
http://blog.sae.sina.com.cn/archives/3910 在Linux系统中,有许多命令可用于查询主机的硬件信息.一些命令只针对特定的硬件组件,比如CPU.内存,一些命令可以 ...
- How Ironic Inspector Works
翻译官网概述. 操作员将节点注册为Ironic,例如 通过openstack baremetal CLI命令. 电源管理认证应该在这一步提供给Ironic. 如节点状态所述,节点被置于正确的自省状态. ...
- ironic组件硬件自检服务——ironic-inspector
介绍 ironic-inspector是一个用于硬件自检的辅助型服务,它可以对被ironic组件管理的裸金属节点进行硬件自检,通过在裸金属节点上运行内存系统,发现裸金属节点的硬件信息,例如CPU数量和 ...
- 人人都是 DBA(IX)服务器信息收集脚本汇编
什么?有个 SQL 执行了 8 秒! 哪里出了问题?臣妾不知道啊,得找 DBA 啊. DBA 人呢?离职了!!擦!!! 程序员在无处寻求帮助时,就得想办法自救,努力让自己变成 "伪 DBA& ...
- 小白日记7:kali渗透测试之主动信息收集-发现(一)--二层发现:arping/shell脚本,Netdiscover,scapy
主动信息收集 被动信息收集可能不准确,可以用主动信息收集验证 特点:直接与目标系统交互通信,无法避免留下访问痕迹 解决方法:1.使用受控的第三方电脑进行探测,使用代理 (做好被封杀的准备) 2 ...
- Kali Linux信息收集工具
http://www.freebuf.com/column/150118.html 可能大部分渗透测试者都想成为网络空间的007,而我个人的目标却是成为Q先生! 看过007系列电影的朋友,应该都还记得 ...
随机推荐
- 区分TCP包的顺序
确认TCP包的顺序: 使用抓包工具抓包之后,通常按照时间先后排序的,而不是数据的内容逻辑先后.查找内容的先后的关键在于查看TCP中的Sequence number和Acknowledgment num ...
- mysql的innodb存储引擎
innodb是支持事务的存储引擎,支持ACID特性的ACID(指数据库事务正确执行的四个基本要素的缩写) 包含:原子性(Atomicity).一致性(Consistency).隔离性(Isolatio ...
- settings.py常见配置项
settings.py常见配置项 1. 配置Django_Admin依照中文界面显示 LANGUAGE_CODE = 'zh-hans' 2. 数据库配置(默认使用sqlite3) 1 .默认使用的s ...
- SQL得到任意一个存储过程的参数列表sp_procedure_params_rowset
SQL得到任意一个存储过程的参数列表sp_procedure_params_rowsetexec sp_procedure_params_rowset 'up_rpt营业收入汇总表' PROCEDUR ...
- jdk1.8学习、jdk1.9学习、jdk10.0学习和总结
由于中文参考资料很少,参考链接: https://www.oschina.net/translate/109-new-features-in-jdk-10 http://chuansong.me/n/ ...
- NetCore 生成RSA公私钥对,公钥加密私钥解密,私钥加密公钥解密
using Newtonsoft.Json; using Org.BouncyCastle.Crypto; using Org.BouncyCastle.Crypto.Encodings; using ...
- js判断手机邮箱格式(正则)
function fun() { var realname = document.getElementById("realname"); var telephone = docum ...
- Java中随机数生成的问题
[生成随机数序列] 我们只能利用Math.random()方法只能生成一个在[0,1)之间的double类型浮点数. 但如果我们想要生成[min, max]之间的随机整数时该怎么办呢? 此时可以用: ...
- Java中String直接赋字符串和new String的区别(面试常考)
摘取自:https://www.cnblogs.com/guozhenqiang/p/5633269.html 解析Java中的String对象的数据类型 1. String是一个对象. 因为对象的 ...
- TF之AE:AE实现TF自带数据集AE的encoder之后decoder之前的非监督学习分类—Jason niu
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt #Import MNIST data from t ...