aboutsummaryrefslogtreecommitdiff
path: root/share/hydractl/hwinfo
blob: 725f90f381af0bba7dc3f2721c326f3b50f7cfb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
#
# Gather hardware information and dump into a folder.
#

# Load.
source $APP_BASE/lib/hydra/functions || exit 1
hydra_config_load

# Parameters
BASENAME="`basename $0`"

# This command could be converted to a "hydra <hydra> hwinfo" fact collector, storing results
# at $HYDRA_FOLDER/config/hardware if we had a way to uniquelly determine hardware UUID, independent
# from the operating system.
#
# Some references that might help:
#
#   https://stackoverflow.com/questions/35883313/dmidecode-product-uuid-and-product-serial-what-is-the-difference
#   https://wiki.debian.org/HowToIdentifyADevice/System
#   https://unix.stackexchange.com/questions/211327/get-the-same-uuid-on-different-linux-distributions#211398
#   https://stackoverflow.com/questions/10152762/best-way-to-get-machine-id-on-linux#10152797
#   https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.0.0.pdf
#
# Some files to look around:
#
#   /sys/class/dmi/id/board_serial
#   /sys/class/dmi/id/product_uuid
#   /var/lib/dbus/machine-id
#
# This would work in some systems, while in others wont:
#
#   manufacturer="`$SUDO dmidecode -s system-manufacturer`"
#   version="`$SUDO dmidecode -s system-version`"
#
# Best way would either get a UUID from BIOS or build our own, manual database with arbitrary generated UUIDs.

# Sudo config
if [ "`whoami`" != 'root' ]; then
  SUDO="sudo"
fi

if which lshw &> /dev/null; then
  $SUDO lshw #> lshw.txt
  #$SUDO lshw --json > lshw.json
  #$SUDO lshw --xml  > lshw.xml
fi

if which lscpu &> /dev/null; then
  $SUDO lscpu #> lscpu.txt
fi

if which cpuid &> /dev/null; then
  $SUDO cpuid #> cpuid.txt
fi

if which dmidecode &> /dev/null; then
  $SUDO dmidecode #> dmidecode.txt
  #$SUDO dmidecode --dump-bin dmidecode.bin
fi

if which lspci &> /dev/null; then
  $SUDO lspci #> lspci.txt
fi

if which lsusb &> /dev/null; then
  $SUDO lsusb #> lsusb.txt
fi

if which lsblk &> /dev/null; then
  $SUDO lsblk -O #> lsblk.txt
fi

if which hwinfo &> /dev/null; then
  $SUDO hwinfo #> hwinfo.txt
fi