#! /bin/bash # This script is part of FAI (Fully Automatic Installation) # Copyright (c) 2013-2021 by Thomas Lange, Universitaet zu Koeln # Inventory function, print hardware inventory, without too much configuration information # The format is "key: value", both key and value may contain space, value may also contain : inventory() { # activate all software RAID arrays echo DEVICE partitions > /etc/mdadm/mdadm.conf udevadm trigger cd /sys/class/dmi/id 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:]]+$' lscpu | grep 'Hypervisor vendor:' # memory, RAM mem=$(/usr/sbin/dmidecode -t memory | awk '( /Size:.*MB/ ) { x+=$2 } END { print x/1024 " GB"}') if [ "$mem" = "0 GB" ]; then mem=$(/usr/sbin/dmidecode -t memory | awk '( /Size:.*GB/ ) { x+=$2 } END { print x " GB"}') fi echo "RAMSIZE: $mem" ncpu=$(grep "model name" /proc/cpuinfo | sed -e 's/model name.*://' -e 's/(R)//g' -e 's/(TM)//g' -e 's/^[[:blank:]]\+//'|wc -l) cpuname=$(grep "model name" /proc/cpuinfo | head -1 | sed -e 's/model name.*://' -e 's/(R)//g' -e 's/(TM)//g' -e 's/^[[:blank:]]\+//') echo "CPU: $cpuname" echo "Number of CPU/Cores: $ncpu" nic1=$(ip route | awk '/^default/ {print $5}'|head -1) mac1=$(< /sys/class/net/$nic1/address) echo "Network interface: $nic1" echo "MAC address: $mac1" # print disk infos # $disklist needs to be set, normally done in fai-disk-info local d=1 local dev cap model for dev in $disklist; do cap=$(smartctl -i /dev/$dev | grep Capacity: | grep -Po '\[.+?\]') if [ -z "$cap" ]; then # virtio devices cap=$(blockdev --getsize64 /dev/$dev | numfmt --to=iec | sed -e 's/\(.\)$/ \1/') cap="[$cap]" fi model=$(smartctl -i /dev/$dev | grep -E 'Product:|Device Model:|Model Number:'|sed -e 's/^.*://' -e 's/^ *//') echo "disk$d: $dev $cap $model" (( d++ )) done nvme list vga=$(lspci|grep ' VGA '| sed -e 's/.*VGA compatible controller://') echo "VGA controller: $vga" if [ -d /sys/firmware/efi ]; then efibootmgr fi echo List serial numbers of devices cd /sys/class/dmi/id grep -s . *_serial | sed -e 's/:/: /'| egrep -iv 'serial: 0123456789|: Not |N/A|:[[:blank:]]+$' lsblk -dno name,serial } if [ X$verbose = X1 ]; then inventory |& tee $LOGDIR/inventory.log echo "Inventory data written to $LOGDIR/inventory.log" else inventory > $LOGDIR/inventory.log 2>&1 fi task_savelog