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系列电影的朋友,应该都还记得 ...
随机推荐
- models批量生成数据
models批量生成数据 1.将数据生成为 列表序列,通过 bulk_create 将数据一次插入数据库中 def host(request): # 插入数据速度快消耗资源少 Hostlist=[] ...
- 混合编译.c/.cpp与.cu文件
混合编译.c/.cpp与.cu文件 项目中用到cuda编程,写了kernel函数,需要nvcc编译器来编译..c/.cpp的文件,假定用gcc编译. 如何混合编译它们,整体思路是:.cu文件编译出的东 ...
- (2).NET CORE微服务 Micro-Service ---- .NetCore启动配置 和 .NetCoreWebApi
什么是.Net Core?.Net Core是微软开发的另外一个可以跨Linux.Windows.mac等平台的.Net.Net Core相关知识看文章地步dotnet dllname.dll 运行P ...
- Typescript知识梳理
概述 TypeScript简称TS,具有类型系统,且是JavaScript的超集. 它可以编译成普通的JavaScript代码.TypeScript支持任意浏览器,任意环境,任意系统并且是开源的.通过 ...
- COMException: The data necessary to complete this operation is not yet available.
问题描述: 最近在公司AE项目中遇到了下面的问题: COMException: The data necessary to complete this operation is not yet ava ...
- Python_dict部分功能介绍
字典是无序的 x.clear():清除所有元素 x.fromkeys():返回一个新的字典,使前面的key=value x.get():如果k不存在,默认返回一个值,如果存在,则返回存在的值 x.it ...
- Flink--time-window 的高级用法
1.现实世界中的时间是不一致的,在 flink 中被划分为事件时间,提取时间,处理时间三种. 2.如果以 EventTime 为基准来定义时间窗口那将形成 EventTimeWindow,要求消息本身 ...
- docker保存、载入、导出、导入
保存和载入 拿到CONTAINER ID docker ps -a 通过容器id生成镜像dockerlinuxdemoweb:update docker commit b33633d12871 doc ...
- M. Subsequence 南昌邀请赛
链接: https://nanti.jisuanke.com/t/38232 先给出一个s母串 然后给出n个子串 判断是否为母串的子序列 3000ms 2993ms过的.... 蒻鲫的代码: 建立表 ...
- 062 SparkStream内部原理
1.DStream 内部是一系列的RDD组成的,每个RDD与RDD的产生时间形成一个pair保存在内存中(下面有) RDD包含了对应时间段的所有block数据. 2.DStream下的方法 /** T ...