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系列电影的朋友,应该都还记得 ...
随机推荐
- 2019-3-9,Servlet转跳链接详解
//以下代码,可以传递request和response对象及其属性和变量至指定页面 request.getRequestDispatcher("showAttribut.jsp") ...
- 20165206 2017-2018-2《Java程序设计》课程总结
20165206 2017-2018-2<Java程序设计>课程总结 一.每周作业链接汇总 预备作业1:对师生关系的看法和期望 预备作业2:c语言基础和学习技能的理解 预备作业3:Linu ...
- JQuery之左侧菜单
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- [转] zepto的各种坑
1.编译zepto.模块之前可能有依赖关系,整体顺序参考下面这个即可: MODULES="zepto event ajax form ie detect fx fx_methods asse ...
- (转载)C#压缩解压zip 文件
转载之: C#压缩解压zip 文件 - 大气象 - 博客园http://www.cnblogs.com/greatverve/archive/2011/12/27/csharp-zip.html C# ...
- 如何扩展Orchard
翻译自: http://msdn.microsoft.com/en-us/magazine/hh708754.aspx 动态类型系统 Content item是Orchard中的原子, 比如b ...
- Codeforces 837F Prefix Sums
Prefix Sums 在 n >= 4时候直接暴力. n <= 4的时候二分加矩阵快速幂去check #include<bits/stdc++.h> #define LL l ...
- BZOJ2821 作诗(Poetize) 主席树 bitset
原文链接https://www.lydsy.com/JudgeOnline/problem.php?id=2821 题目传送门 - BZOJ2821 题意 $n$ 个数,$m$ 组询问,每次问 $[l ...
- 简单的线程Thread使用
static void Main(string[] args) { for (int i = 0; i < 5; i++) { aa a = new aa(); a.age = i; Threa ...
- Python之抽象类、抽象方法
抽象类中只能有抽象方法,子类继承抽象类时,不能通过实例化使用其抽象方法,必须实现该方法. Python2 class CopyBase(object): def save(self): raise N ...