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系列电影的朋友,应该都还记得 ...
随机推荐
- reactnative的js里的super的作用
class Blink extends Component{ constructor(props){ super(props); this.state = { showText: true }; se ...
- ES优化总结
ES优化总结(特别是在bulk大量数据到ES的时候) https://blog.csdn.net/chenxun_2010/article/details/78602795 将 ELASTICSEAR ...
- 最短路径算法之Dijkstra算法
参考:<大话数据结构> 这是一个按照路径长度递增的次序产生最短路径的算法.它并不是一次求出源点到目标点的最短路径,而是一步步求出它们之间顶点的最短路径,过程中都是基于已经求出的最短路径的基 ...
- [转] React 中组件间通信的几种方式
在使用 React 的过程中,不可避免的需要组件间进行消息传递(通信),组件间通信大体有下面几种情况: 父组件向子组件通信 子组件向父组件通信 跨级组件之间通信 非嵌套组件间通信 下面依次说下这几种通 ...
- [转] iOS9系统自带字体
Family: Thonburi Font: Thonburi-Bold Font: Thonburi Font: Thonburi-Light 1 2 3 4 Family: Khmer Sanga ...
- wb 黑名单批量操作
0. 参考 yu961549745/WeiboBlackList 微博批量拉黑 1. 代码 block.py 更新内容:多线程,urllib.request 改为 requests + sessio ...
- Coolpy网络部署说明(局域网)
本文将介绍Coolpy第一种方案的网络部署方法.以方便大家学习如何让coolpy设备部署到相应的应用场景中.本例将以水星MW310R无线路由器作为演示路由器. 1.局域网部署 即coolpy设备=&g ...
- Python_自定义模块
自定义模块例子(web简单框架): 专门处理逻辑的包:处理各种访问需求 数据库的交互:面临各种的查询,删改 ,dba, 配置文件(全局配置文件):列存储数据的地方,HTML代码存储地方 实现: 代码: ...
- 51Nod1675 序列变换 数论 莫比乌斯反演
原文http://www.cnblogs.com/zhouzhendong/p/8665675.html 题目传送门 - 51Nod1675 题意 给定序列$a,b$,让你求满足$\gcd(x,y)= ...
- UOJ#23. 【UR #1】跳蚤国王下江南 仙人掌 Tarjan 点双 圆方树 点分治 多项式 FFT
原文链接https://www.cnblogs.com/zhouzhendong/p/UOJ23.html 题目传送门 - UOJ#23 题意 给定一个有 n 个节点的仙人掌(可能有重边). 对于所有 ...