| 1 |
#! /bin/bash |
| 2 |
|
| 3 |
# This script is part of FAI (Fully Automatic Installation) |
| 4 |
# Copyright (c) 2013-2021 by Thomas Lange, Universitaet zu Koeln |
| 5 |
|
| 6 |
# Inventory function, print hardware inventory, without too much configuration information |
| 7 |
|
| 8 |
# The format is "key: value", both key and value may contain space, value may also contain : |
| 9 |
|
| 10 |
|
| 11 |
inventory() { |
| 12 |
|
| 13 |
# activate all software RAID arrays |
| 14 |
echo DEVICE partitions > /etc/mdadm/mdadm.conf |
| 15 |
udevadm trigger |
| 16 |
|
| 17 |
cd /sys/class/dmi/id |
| 18 |
grep -s . {board_,bios_,product_}* | sed -e 's/:/: /'| grep -E -iv 'board_version|System Product Name|System Version|System Serial Number|123456789|To Be Filled|: Not |N/A|:[[:blank:]]+$' |
| 19 |
|
| 20 |
lscpu | grep 'Hypervisor vendor:' |
| 21 |
|
| 22 |
# memory, RAM |
| 23 |
mem=$(/usr/sbin/dmidecode -t memory | awk '( /Size:.*MB/ ) { x+=$2 } END { print x/1024 " GB"}') |
| 24 |
if [ "$mem" = "0 GB" ]; then |
| 25 |
mem=$(/usr/sbin/dmidecode -t memory | awk '( /Size:.*GB/ ) { x+=$2 } END { print x " GB"}') |
| 26 |
fi |
| 27 |
echo "RAMSIZE: $mem" |
| 28 |
|
| 29 |
ncpu=$(grep "model name" /proc/cpuinfo | sed -e 's/model name.*://' -e 's/(R)//g' -e 's/(TM)//g' -e 's/^[[:blank:]]\+//'|wc -l) |
| 30 |
cpuname=$(grep "model name" /proc/cpuinfo | head -1 | sed -e 's/model name.*://' -e 's/(R)//g' -e 's/(TM)//g' -e 's/^[[:blank:]]\+//') |
| 31 |
echo "CPU: $cpuname" |
| 32 |
echo "Number of CPU/Cores: $ncpu" |
| 33 |
|
| 34 |
nic1=$(ip route | awk '/^default/ {print $5}'|head -1) |
| 35 |
mac1=$(< /sys/class/net/$nic1/address) |
| 36 |
echo "Network interface: $nic1" |
| 37 |
echo "MAC address: $mac1" |
| 38 |
|
| 39 |
# print disk infos |
| 40 |
# $disklist needs to be set, normally done in fai-disk-info |
| 41 |
local d=1 |
| 42 |
local dev cap model |
| 43 |
for dev in $disklist; do |
| 44 |
cap=$(smartctl -i /dev/$dev | grep Capacity: | grep -Po '\[.+?\]') |
| 45 |
if [ -z "$cap" ]; then # virtio devices |
| 46 |
cap=$(blockdev --getsize64 /dev/$dev | numfmt --to=iec | sed -e 's/\(.\)$/ \1/') |
| 47 |
cap="[$cap]" |
| 48 |
fi |
| 49 |
model=$(smartctl -i /dev/$dev | grep -E 'Product:|Device Model:|Model Number:'|sed -e 's/^.*://' -e 's/^ *//') |
| 50 |
echo "disk$d: $dev $cap $model" |
| 51 |
(( d++ )) |
| 52 |
done |
| 53 |
nvme list |
| 54 |
|
| 55 |
vga=$(lspci|grep ' VGA '| sed -e 's/.*VGA compatible controller://') |
| 56 |
echo "VGA controller: $vga" |
| 57 |
|
| 58 |
if [ -d /sys/firmware/efi ]; then |
| 59 |
efibootmgr |
| 60 |
fi |
| 61 |
|
| 62 |
echo List serial numbers of devices |
| 63 |
cd /sys/class/dmi/id |
| 64 |
grep -s . *_serial | sed -e 's/:/: /'| egrep -iv 'serial: 0123456789|: Not |N/A|:[[:blank:]]+$' |
| 65 |
lsblk -dno name,serial |
| 66 |
} |
| 67 |
|
| 68 |
if [ X$verbose = X1 ]; then |
| 69 |
inventory |& tee $LOGDIR/inventory.log |
| 70 |
echo "Inventory data written to $LOGDIR/inventory.log" |
| 71 |
else |
| 72 |
inventory > $LOGDIR/inventory.log 2>&1 |
| 73 |
fi |
| 74 |
task_savelog |