Boavizta / Energizta

:electric_plug: A collaborative project to collect and report open-data on the energy consumption of servers.
https://boavizta.github.io/Energizta/
34 stars 4 forks source link

Hardware : Collect architectural features #3

Closed da-ekchajzer closed 12 months ago

da-ekchajzer commented 2 years ago

Problem

For each evaluation, we need to collect information about the underlying architecture to identify the variables involved in changing the consumption profile.

Solution

Boagent from Boavizta already has a hardware module that could be used for this task : https://github.com/Boavizta/boagent/tree/main/boagent/hardware

maethor commented 1 year ago

lshw should be able to provide everything we need, and it has a -sanitize option to remove all sensible information.

sudo lshw -disable usb -disable pnp -sanitize -notime -short # Very short, but will need to be parsed on our side
sudo lshw -disable usb -disable pnp -sanitize -notime -json # Too long to my taste. May be easier to parse on our side… or not.
❯❯❯ sudo lshw -disable usb -disable pnp -sanitize -notime -short
Chemin matériel   Périphérique  Classe         Description
=============================================================
                                   system         QuantaMicro X10E-9N (S3E)
/0                                 bus            S3E-MB
/0/0                               memory         64KiB BIOS
/0/34                              memory         256KiB L1 cache
/0/35                              memory         1MiB L2 cache
/0/36                              memory         8MiB L3 cache
/0/37                              processor      Intel(R) Xeon(R) CPU E3-1240 v6 @ 3.70GHz
/0/38                              memory         32GiB Mémoire Système
/0/38/0                            memory         Project-Id-Version: @(#) $Id: fr.po 2151 2010-03-15 20:26:20Z lyonel 
/0/38/1                            memory         16GiB DIMM DDR4 Synchrone 2133 MHz (0,5 ns)
/0/38/2                            memory         Project-Id-Version: @(#) $Id: fr.po 2151 2010-03-15 20:26:20Z lyonel 
/0/38/3                            memory         16GiB DIMM DDR4 Synchrone 2133 MHz (0,5 ns)
/0/100                             bridge         Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers
/0/100/1                           bridge         6th-10th Gen Core Processor PCIe Controller (x16)
/0/100/1/0         enp1s0f0        network        I350 Gigabit Network Connection
/0/100/1/0.1       enp1s0f1        network        I350 Gigabit Network Connection
/0/100/14                          bus            100 Series/C230 Series Chipset Family USB 3.0 xHCI Controller
/0/100/14.2                        generic        100 Series/C230 Series Chipset Family Thermal Subsystem
/0/100/16                          communication  100 Series/C230 Series Chipset Family MEI Controller #1
/0/100/16.1                        communication  100 Series/C230 Series Chipset Family MEI Controller #2
/0/100/17          scsi2           storage        Q170/Q150/B150/H170/H110/Z170/CM236 Chipset SATA Controller [AHCI Mod
/0/100/17/0        /dev/sda        disk           256GB Micron_1100_MTFD
/0/100/17/0/1      /dev/sda1       volume         299MiB Linux raid autodetect partition
/0/100/17/0/2      /dev/sda2       volume         2097MiB Linux swap volume
/0/100/17/0/3      /dev/sda3       volume         236GiB Linux raid autodetect partition
/0/100/17/1        /dev/sdb        disk           256GB Micron_1100_MTFD
/0/100/17/1/1      /dev/sdb1       volume         299MiB Linux raid autodetect partition
/0/100/17/1/2      /dev/sdb2       volume         2097MiB Linux swap volume
/0/100/17/1/3      /dev/sdb3       volume         236GiB Linux raid autodetect partition
/0/100/17/0.0.0    /dev/sdc        disk           256GB Micron_1100_MTFD
/0/100/17/0.0.0/1  /dev/sdc1       volume         299MiB Linux raid autodetect partition
/0/100/17/0.0.0/2  /dev/sdc2       volume         2097MiB Linux swap volume
/0/100/17/0.0.0/3  /dev/sdc3       volume         236GiB Linux raid autodetect partition
/0/100/1c                          bridge         100 Series/C230 Series Chipset Family PCI Express Root Port #1
/0/100/1c/0                        bridge         AST1150 PCI-to-PCI Bridge
/0/100/1c/0/0                      display        ASPEED Graphics Family
/0/100/1f                          bridge         C236 Chipset LPC/eSPI Controller
/0/100/1f.2                        memory         Memory controller
/0/100/1f.4                        bus            100 Series/C230 Series Chipset Family SMBus

❯❯❯ sudo lshw -disable usb -disable pnp -sanitize -notime -json
[                           
{
  "id" : "computer",
  "class" : "system",
  "claimed" : true,
  "handle" : "DMI:0001",
  "description" : "Rack Mount Chassis",
  "product" : "QuantaMicro X10E-9N (S3E)",
  "vendor" : "Quanta Cloud Technology Inc.",
  "version" : "N/A",
  "serial" : "[REMOVED]",
  "width" : 64,
  "configuration" : {
    "chassis" : "rackmount",
    "family" : "Default string",
    "sku" : "S3E",
    "uuid" : "[REMOVED]"
  },
  "capabilities" : {
    "smbios-3.0.0" : "SMBIOS version 3.0.0",
    "dmi-3.0.0" : "DMI version 3.0.0",
    "smp" : "Symmetric Multi-Processing",
    "vsyscall32" : "exécution d'applications 32 bits"
  }    {
      "id" : "core",
      "class" : "bus",
      "claimed" : true,
      "handle" : "DMI:0002",
      "description" : "Carte mère",
      "product" : "S3E-MB",
      "vendor" : "Quanta Cloud Technology Inc.",
      "physid" : "0",
      "version" : "31S3EMB0010",
      "serial" : "[REMOVED]",
      "slot" : "3"        {
          "id" : "firmware",
          "class" : "memory",
          "claimed" : true,
          "description" : "BIOS",
          "vendor" : "American Megatrends Inc.",
          "physid" : "0",
          "version" : "S3E_3B09.01",
          "date" : "12/14/2017",
          "units" : "bytes",
          "size" : 65536,
          "capacity" : 8388608,
          "capabilities" : {
            "pci" : "bus PCI",
            "upgrade" : "BIOS EEPROM can be upgraded",
            "shadowing" : "BIOS shadowing",
            "cdboot" : "Démarrage depuis un CD-ROM/DVD",
            "bootselect" : "Selectable boot path",
            "socketedrom" : "BIOS ROM is socketed",
            "edd" : "Enhanced Disk Drive extensions",
            "int5printscreen" : "Print Screen key",
            "int14serial" : "INT14 serial line control",
            "int17printer" : "INT17 printer control",
            "acpi" : "ACPI",
            "usb" : "USB legacy emulation",
            "biosbootspecification" : "BIOS boot specification",
            "uefi" : "UEFI specification is supported"
          }
        },
        {
          "id" : "cache:0",
          "class" : "memory",
          "claimed" : true,
          "handle" : "DMI:0034",
          "description" : "L1 cache",
          "physid" : "34",
          "slot" : "L1 Cache",
          "units" : "bytes",
          "size" : 262144,
          "capacity" : 262144,
          "configuration" : {
            "level" : "1"
          },
          "capabilities" : {
            "synchronous" : "Synchrone",
            "internal" : "Interne",
            "write-back" : "Write-back"
          }
        },
        {
          "id" : "cache:1",
          "class" : "memory",
          "claimed" : true,
          "handle" : "DMI:0035",
          "description" : "L2 cache",
          "physid" : "35",
          "slot" : "L2 Cache",
          "units" : "bytes",
          "size" : 1048576,
          "capacity" : 1048576,
          "configuration" : {
            "level" : "2"
          },
          "capabilities" : {
            "synchronous" : "Synchrone",
            "internal" : "Interne",
            "write-back" : "Write-back",
            "unified" : "Cache unifié"
          }
        },
        {
          "id" : "cache:2",
          "class" : "memory",
          "claimed" : true,
          "handle" : "DMI:0036",
          "description" : "L3 cache",
          "physid" : "36",
          "slot" : "L3 Cache",
          "units" : "bytes",
          "size" : 8388608,
          "capacity" : 8388608,
          "configuration" : {
            "level" : "3"
          },
          "capabilities" : {
            "synchronous" : "Synchrone",
            "internal" : "Interne",
            "write-back" : "Write-back",
            "unified" : "Cache unifié"
          }
        },
        {
          "id" : "cpu",
          "class" : "processor",
          "claimed" : true,
          "handle" : "DMI:0037",
          "description" : "CPU",
          "product" : "Intel(R) Xeon(R) CPU E3-1240 v6 @ 3.70GHz",
          "vendor" : "Intel Corp.",
          "physid" : "37",
          "businfo" : "cpu@0",
          "version" : "Intel(R) Xeon(R) CPU E3-1240 v6 @ 3.70GHz",
          "serial" : "[REMOVED]",
          "slot" : "CPU",
          "units" : "Hz",
          "size" : 3907145000,
          "capacity" : 4100000000,
          "width" : 64,
          "clock" : 100000000,
          "configuration" : {
            "cores" : "4",
            "enabledcores" : "4",
            "threads" : "8"
          },
          "capabilities" : {
            "lm" : "64bits extensions (x86-64)",
            "fpu" : "mathematical co-processor",
            "fpu_exception" : "FPU exceptions reporting",
            "wp" : true,
            "vme" : "virtual mode extensions",
            "de" : "debugging extensions",
            "pse" : "page size extensions",
            "tsc" : "time stamp counter",
            "msr" : "model-specific registers",
            "pae" : "4GB+ memory addressing (Physical Address Extension)",
            "mce" : "machine check exceptions",
            "cx8" : "compare and exchange 8-byte",
            "apic" : "on-chip advanced programmable interrupt controller (APIC)",
            "sep" : "fast system calls",
            "mtrr" : "memory type range registers",
            "pge" : "page global enable",
            "mca" : "machine check architecture",
            "cmov" : "conditional move instruction",
            "pat" : "page attribute table",
            "pse36" : "36-bit page size extensions",
            "clflush" : true,
            "dts" : "debug trace and EMON store MSRs",
            "acpi" : "thermal control (ACPI)",
            "mmx" : "multimedia extensions (MMX)",
            "fxsr" : "fast floating point save/restore",
            "sse" : "streaming SIMD extensions (SSE)",
            "sse2" : "streaming SIMD extensions (SSE2)",
            "ss" : "self-snoop",
            "ht" : "HyperThreading",
            "tm" : "thermal interrupt and status",
            "pbe" : "pending break event",
            "syscall" : "fast system calls",
            "nx" : "no-execute bit (NX)",
            "pdpe1gb" : true,
            "rdtscp" : true,
            "x86-64" : "64bits extensions (x86-64)",
            "constant_tsc" : true,
            "art" : true,
            "arch_perfmon" : true,
            "pebs" : true,
            "bts" : true,
            "rep_good" : true,
            "nopl" : true,
            "xtopology" : true,
            "nonstop_tsc" : true,
            "cpuid" : true,
            "aperfmperf" : true,
            "pni" : true,
            "pclmulqdq" : true,
            "dtes64" : true,
            "monitor" : true,
            "ds_cpl" : true,
            "vmx" : true,
            "smx" : true,
            "est" : true,
            "tm2" : true,
            "ssse3" : true,
            "sdbg" : true,
            "fma" : true,
            "cx16" : true,
            "xtpr" : true,
            "pdcm" : true,
            "pcid" : true,
            "sse4_1" : true,
            "sse4_2" : true,
            "x2apic" : true,
            "movbe" : true,
            "popcnt" : true,
            "tsc_deadline_timer" : true,
            "aes" : true,
            "xsave" : true,
            "avx" : true,
            "f16c" : true,
            "rdrand" : true,
            "lahf_lm" : true,
            "abm" : true,
            "3dnowprefetch" : true,
            "cpuid_fault" : true,
            "epb" : true,
            "invpcid_single" : true,
            "pti" : true,
            "tpr_shadow" : true,
            "vnmi" : true,
            "flexpriority" : true,
            "ept" : true,
            "vpid" : true,
            "ept_ad" : true,
            "fsgsbase" : true,
            "tsc_adjust" : true,
            "bmi1" : true,
            "hle" : true,
            "avx2" : true,
            "smep" : true,
            "bmi2" : true,
            "erms" : true,
            "invpcid" : true,
            "rtm" : true,
            "mpx" : true,
            "rdseed" : true,
            "adx" : true,
            "smap" : true,
            "clflushopt" : true,
            "intel_pt" : true,
            "xsaveopt" : true,
            "xsavec" : true,
            "xgetbv1" : true,
            "xsaves" : true,
            "dtherm" : true,
            "ida" : true,
            "arat" : true,
            "pln" : true,
            "pts" : true,
            "hwp" : true,
            "hwp_notify" : true,
            "hwp_act_window" : true,
            "hwp_epp" : true,
            "cpufreq" : "CPU Frequency scaling"
          }
        },
        {
          "id" : "memory",
          "class" : "memory",
          "claimed" : true,
          "handle" : "DMI:0038",
          "description" : "Mémoire Système",
          "physid" : "38",
          "slot" : "Carte mère",
          "units" : "bytes",
          "size" : 34359738368,
          "configuration" : {
            "errordetection" : "ecc"
          },
          "capabilities" : {
            "ecc" : "Single-bit error-correcting code (ECC)"
          }            {
              "id" : "bank:0",
              "class" : "memory",
              "claimed" : true,
              "handle" : "DMI:0039",
              "description" : "Project-Id-Version: @(#) $Id: fr.po 2151 2010-03-15 20:26:20Z lyonel $Report-Msgid-Bugs-To: POT-Creation-Date: 2009-10-08 14:02+0200PO-Revision-Date: 2009-10-08 14:06+0100Last-Translator: Lyonel Vincent <lyonel@ezix.org>Language-Team: MIME-Version: 1.0Content-Type: text/plain; charset=UTF-8Content-Transfer-Encoding: 8bitProject-Id-Version: @(#) $Id: fr.po 2151 2010-03-15 20:26:20Z lyonel $Report-Msgid-Bugs-To: POT-Creation-Date: 2009-10-08 14:02+0200PO-Revision-Date: 2009-10-08 14:06+0100Last-Translator: Lyonel Vincent <lyonel@ezix.org>Language-Team: MIME-Version: 1.0Content-Type: text/plain; charset=UTF-8Content-Transfer-Encoding: 8bit [vide]",
              "physid" : "0",
              "slot" : "DIMM A1"
            },
            {
              "id" : "bank:1",
              "class" : "memory",
              "claimed" : true,
              "handle" : "DMI:003A",
              "description" : "DIMM DDR4 Synchrone 2133 MHz (0,5 ns)",
              "product" : "M391A2K43BB1-CPB",
              "vendor" : "Samsung",
              "physid" : "1",
              "serial" : "[REMOVED]",
              "slot" : "DIMM A0",
              "units" : "bytes",
              "size" : 17179869184,
              "width" : 64,
              "clock" : 2133000000
            },
            {
              "id" : "bank:2",
              "class" : "memory",
              "claimed" : true,
              "handle" : "DMI:003B",
              "description" : "Project-Id-Version: @(#) $Id: fr.po 2151 2010-03-15 20:26:20Z lyonel $Report-Msgid-Bugs-To: POT-Creation-Date: 2009-10-08 14:02+0200PO-Revision-Date: 2009-10-08 14:06+0100Last-Translator: Lyonel Vincent <lyonel@ezix.org>Language-Team: MIME-Version: 1.0Content-Type: text/plain; charset=UTF-8Content-Transfer-Encoding: 8bitProject-Id-Version: @(#) $Id: fr.po 2151 2010-03-15 20:26:20Z lyonel $Report-Msgid-Bugs-To: POT-Creation-Date: 2009-10-08 14:02+0200PO-Revision-Date: 2009-10-08 14:06+0100Last-Translator: Lyonel Vincent <lyonel@ezix.org>Language-Team: MIME-Version: 1.0Content-Type: text/plain; charset=UTF-8Content-Transfer-Encoding: 8bit [vide]",
              "physid" : "2",
              "slot" : "DIMM B1"
            },
            {
              "id" : "bank:3",
              "class" : "memory",
              "claimed" : true,
              "handle" : "DMI:003C",
              "description" : "DIMM DDR4 Synchrone 2133 MHz (0,5 ns)",
              "product" : "M391A2K43BB1-CPB",
              "vendor" : "Samsung",
              "physid" : "3",
              "serial" : "[REMOVED]",
              "slot" : "DIMM B0",
              "units" : "bytes",
              "size" : 17179869184,
              "width" : 64,
              "clock" : 2133000000
            },

        },
        {
          "id" : "pci",
          "class" : "bridge",
          "claimed" : true,
          "handle" : "PCIBUS:0000:00",
          "description" : "Host bridge",
          "product" : "Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers",
          "vendor" : "Intel Corporation",
          "physid" : "100",
          "businfo" : "pci@0000:00:00.0",
          "version" : "05",
          "width" : 32,
          "clock" : 33000000,
          "configuration" : {
            "driver" : "ie31200_edac"
          }            {
              "id" : "pci:0",
              "class" : "bridge",
              "claimed" : true,
              "handle" : "PCIBUS:0000:01",
              "description" : "PCI bridge",
              "product" : "6th-10th Gen Core Processor PCIe Controller (x16)",
              "vendor" : "Intel Corporation",
              "physid" : "1",
              "businfo" : "pci@0000:00:01.0",
              "version" : "05",
              "width" : 32,
              "clock" : 33000000,
              "configuration" : {
                "driver" : "pcieport"
              },
              "capabilities" : {
                "pci" : true,
                "pm" : "Power Management",
                "msi" : "Message Signalled Interrupts",
                "pciexpress" : "PCI Express",
                "normal_decode" : true,
                "bus_master" : "bus mastering",
                "cap_list" : "PCI capabilities listing"
              }                {
                  "id" : "network:0",
                  "class" : "network",
                  "claimed" : true,
                  "handle" : "PCI:0000:01:00.0",
                  "description" : "Ethernet interface",
                  "product" : "I350 Gigabit Network Connection",
                  "vendor" : "Intel Corporation",
                  "physid" : "0",
                  "businfo" : "pci@0000:01:00.0",
                  "logicalname" : "enp1s0f0",
                  "version" : "01",
                  "serial" : "[REMOVED]",
                  "units" : "bit/s",
                  "size" : 1000000000,
                  "capacity" : 1000000000,
                  "width" : 32,
                  "clock" : 33000000,
                  "configuration" : {
                    "autonegotiation" : "on",
                    "broadcast" : "yes",
                    "driver" : "igb",
                    "driverversion" : "5.10.0-14-amd64",
                    "duplex" : "full",
                    "firmware" : "1.63, 0x800009fa, 1.1276.0",
                    "ip" : "[REMOVED]",
                    "latency" : "0",
                    "link" : "yes",
                    "multicast" : "yes",
                    "port" : "twisted pair",
                    "speed" : "1Gbit/s"
                  },
                  "capabilities" : {
                    "pm" : "Power Management",
                    "msi" : "Message Signalled Interrupts",
                    "msix" : "MSI-X",
                    "pciexpress" : "PCI Express",
                    "bus_master" : "bus mastering",
                    "cap_list" : "PCI capabilities listing",
                    "rom" : "extension ROM",
                    "ethernet" : true,
                    "physical" : "Interface physique",
                    "tp" : "paire torsadée",
                    "10bt" : "10Mbit/s",
                    "10bt-fd" : "10Mbit/s (full duplex)",
                    "100bt" : "100Mbit/s",
                    "100bt-fd" : "100Mbit/s (full duplex)",
                    "1000bt-fd" : "1Gbit/s (full duplex)",
                    "autonegotiation" : "Auto-négotiation"
                  }
                },
                {
                  "id" : "network:1",
                  "class" : "network",
                  "disabled" : true,
                  "claimed" : true,
                  "handle" : "PCI:0000:01:00.1",
                  "description" : "Ethernet interface",
                  "product" : "I350 Gigabit Network Connection",
                  "vendor" : "Intel Corporation",
                  "physid" : "0.1",
                  "businfo" : "pci@0000:01:00.1",
                  "logicalname" : "enp1s0f1",
                  "version" : "01",
                  "serial" : "[REMOVED]",
                  "units" : "bit/s",
                  "capacity" : 1000000000,
                  "width" : 32,
                  "clock" : 33000000,
                  "configuration" : {
                    "autonegotiation" : "on",
                    "broadcast" : "yes",
                    "driver" : "igb",
                    "driverversion" : "5.10.0-14-amd64",
                    "firmware" : "1.63, 0x800009fa, 1.1276.0",
                    "latency" : "0",
                    "link" : "no",
                    "multicast" : "yes",
                    "port" : "twisted pair"
                  },
                  "capabilities" : {
                    "pm" : "Power Management",
                    "msi" : "Message Signalled Interrupts",
                    "msix" : "MSI-X",
                    "pciexpress" : "PCI Express",
                    "bus_master" : "bus mastering",
                    "cap_list" : "PCI capabilities listing",
                    "rom" : "extension ROM",
                    "ethernet" : true,
                    "physical" : "Interface physique",
                    "tp" : "paire torsadée",
                    "10bt" : "10Mbit/s",
                    "10bt-fd" : "10Mbit/s (full duplex)",
                    "100bt" : "100Mbit/s",
                    "100bt-fd" : "100Mbit/s (full duplex)",
                    "1000bt-fd" : "1Gbit/s (full duplex)",
                    "autonegotiation" : "Auto-négotiation"
                  }
                },

            },
            {
              "id" : "usb",
              "class" : "bus",
              "claimed" : true,
              "handle" : "PCI:0000:00:14.0",
              "description" : "USB controller",
              "product" : "100 Series/C230 Series Chipset Family USB 3.0 xHCI Controller",
              "vendor" : "Intel Corporation",
              "physid" : "14",
              "businfo" : "pci@0000:00:14.0",
              "version" : "31",
              "width" : 64,
              "clock" : 33000000,
              "configuration" : {
                "driver" : "xhci_hcd",
                "latency" : "0"
              },
              "capabilities" : {
                "pm" : "Power Management",
                "msi" : "Message Signalled Interrupts",
                "xhci" : true,
                "bus_master" : "bus mastering",
                "cap_list" : "PCI capabilities listing"
              }
            },
            {
              "id" : "generic",
              "class" : "generic",
              "claimed" : true,
              "handle" : "PCI:0000:00:14.2",
              "description" : "Signal processing controller",
              "product" : "100 Series/C230 Series Chipset Family Thermal Subsystem",
              "vendor" : "Intel Corporation",
              "physid" : "14.2",
              "businfo" : "pci@0000:00:14.2",
              "version" : "31",
              "width" : 64,
              "clock" : 33000000,
              "configuration" : {
                "driver" : "intel_pch_thermal",
                "latency" : "0"
              },
              "capabilities" : {
                "pm" : "Power Management",
                "msi" : "Message Signalled Interrupts",
                "bus_master" : "bus mastering",
                "cap_list" : "PCI capabilities listing"
              }
            },
            {
              "id" : "communication:0",
              "class" : "communication",
              "handle" : "PCI:0000:00:16.0",
              "description" : "Communication controller",
              "product" : "100 Series/C230 Series Chipset Family MEI Controller #1",
              "vendor" : "Intel Corporation",
              "physid" : "16",
              "businfo" : "pci@0000:00:16.0",
              "version" : "31",
              "width" : 64,
              "clock" : 33000000,
              "configuration" : {
                "latency" : "0"
              },
              "capabilities" : {
                "pm" : "Power Management",
                "msi" : "Message Signalled Interrupts",
                "bus_master" : "bus mastering",
                "cap_list" : "PCI capabilities listing"
              }
            },
            {
              "id" : "communication:1",
              "class" : "communication",
              "handle" : "PCI:0000:00:16.1",
              "description" : "Communication controller",
              "product" : "100 Series/C230 Series Chipset Family MEI Controller #2",
              "vendor" : "Intel Corporation",
              "physid" : "16.1",
              "businfo" : "pci@0000:00:16.1",
              "version" : "31",
              "width" : 64,
              "clock" : 33000000,
              "configuration" : {
                "latency" : "0"
              },
              "capabilities" : {
                "pm" : "Power Management",
                "msi" : "Message Signalled Interrupts",
                "bus_master" : "bus mastering",
                "cap_list" : "PCI capabilities listing"
              }
            },
            {
              "id" : "sata",
              "class" : "storage",
              "claimed" : true,
              "handle" : "PCI:0000:00:17.0",
              "description" : "SATA controller",
              "product" : "Q170/Q150/B150/H170/H110/Z170/CM236 Chipset SATA Controller [AHCI Mode]",
              "vendor" : "Intel Corporation",
              "physid" : "17",
              "businfo" : "pci@0000:00:17.0",
              "logicalname" : ["scsi2", "scsi3", "scsi4"],
              "version" : "31",
              "width" : 32,
              "clock" : 66000000,
              "configuration" : {
                "driver" : "ahci",
                "latency" : "0"
              },
              "capabilities" : {
                "sata" : true,
                "msi" : "Message Signalled Interrupts",
                "pm" : "Power Management",
                "ahci_1.0" : true,
                "bus_master" : "bus mastering",
                "cap_list" : "PCI capabilities listing",
                "emulated" : "Emulated device"
              }                {
                  "id" : "disk:0",
                  "class" : "disk",
                  "claimed" : true,
                  "handle" : "SCSI:02:00:00:00",
                  "description" : "ATA Disk",
                  "product" : "Micron_1100_MTFD",
                  "physid" : "0",
                  "businfo" : "scsi@2:0.0.0",
                  "logicalname" : "/dev/sda",
                  "dev" : "8:0",
                  "version" : "U031",
                  "serial" : "[REMOVED]",
                  "units" : "bytes",
                  "size" : 256060514304,
                  "configuration" : {
                    "ansiversion" : "5",
                    "logicalsectorsize" : "512",
                    "sectorsize" : "512",
                    "signature" : "7b3acf81"
                  },
                  "capabilities" : {
                    "partitioned" : "Partitioned disk",
                    "partitioned:dos" : "MS-DOS partition table"
                  }                    {
                      "id" : "volume:0",
                      "class" : "volume",
                      "claimed" : true,
                      "description" : "Linux raid autodetect partition",
                      "physid" : "1",
                      "businfo" : "scsi@2:0.0.0,1",
                      "logicalname" : "/dev/sda1",
                      "dev" : "8:1",
                      "capacity" : 313524224,
                      "capabilities" : {
                        "primary" : "Primary partition",
                        "bootable" : "Bootable partition (active)",
                        "multi" : "Multi-volumes"
                      }
                    },
                    {
                      "id" : "volume:1",
                      "class" : "volume",
                      "claimed" : true,
                      "description" : "Linux swap volume",
                      "physid" : "2",
                      "businfo" : "scsi@2:0.0.0,2",
                      "logicalname" : "/dev/sda2",
                      "dev" : "8:2",
                      "version" : "1",
                      "serial" : "[REMOVED]",
                      "size" : 2198863872,
                      "capacity" : 2198863872,
                      "configuration" : {
                        "filesystem" : "swap",
                        "pagesize" : "4096"
                      },
                      "capabilities" : {
                        "primary" : "Primary partition",
                        "nofs" : "No filesystem",
                        "swap" : "Linux swap",
                        "initialized" : "initialized volume"
                      }
                    },
                    {
                      "id" : "volume:2",
                      "class" : "volume",
                      "claimed" : true,
                      "description" : "Linux raid autodetect partition",
                      "physid" : "3",
                      "businfo" : "scsi@2:0.0.0,3",
                      "logicalname" : "/dev/sda3",
                      "dev" : "8:3",
                      "capacity" : 253546725376,
                      "capabilities" : {
                        "primary" : "Primary partition",
                        "multi" : "Multi-volumes"
                      }
                    },

                },
                {
                  "id" : "disk:1",
                  "class" : "disk",
                  "claimed" : true,
                  "handle" : "SCSI:03:00:00:00",
                  "description" : "ATA Disk",
                  "product" : "Micron_1100_MTFD",
                  "physid" : "1",
                  "businfo" : "scsi@3:0.0.0",
                  "logicalname" : "/dev/sdb",
                  "dev" : "8:16",
                  "version" : "U031",
                  "serial" : "[REMOVED]",
                  "units" : "bytes",
                  "size" : 256060514304,
                  "configuration" : {
                    "ansiversion" : "5",
                    "logicalsectorsize" : "512",
                    "sectorsize" : "512",
                    "signature" : "56157179"
                  },
                  "capabilities" : {
                    "partitioned" : "Partitioned disk",
                    "partitioned:dos" : "MS-DOS partition table"
                  }                    {
                      "id" : "volume:0",
                      "class" : "volume",
                      "claimed" : true,
                      "description" : "Linux raid autodetect partition",
                      "physid" : "1",
                      "businfo" : "scsi@3:0.0.0,1",
                      "logicalname" : "/dev/sdb1",
                      "dev" : "8:17",
                      "capacity" : 313524224,
                      "capabilities" : {
                        "primary" : "Primary partition",
                        "bootable" : "Bootable partition (active)",
                        "multi" : "Multi-volumes"
                      }
                    },
                    {
                      "id" : "volume:1",
                      "class" : "volume",
                      "claimed" : true,
                      "description" : "Linux swap volume",
                      "physid" : "2",
                      "businfo" : "scsi@3:0.0.0,2",
                      "logicalname" : "/dev/sdb2",
                      "dev" : "8:18",
                      "version" : "1",
                      "serial" : "[REMOVED]",
                      "size" : 2198863872,
                      "capacity" : 2198863872,
                      "configuration" : {
                        "filesystem" : "swap",
                        "pagesize" : "4096"
                      },
                      "capabilities" : {
                        "primary" : "Primary partition",
                        "nofs" : "No filesystem",
                        "swap" : "Linux swap",
                        "initialized" : "initialized volume"
                      }
                    },
                    {
                      "id" : "volume:2",
                      "class" : "volume",
                      "claimed" : true,
                      "description" : "Linux raid autodetect partition",
                      "physid" : "3",
                      "businfo" : "scsi@3:0.0.0,3",
                      "logicalname" : "/dev/sdb3",
                      "dev" : "8:19",
                      "capacity" : 253546725376,
                      "capabilities" : {
                        "primary" : "Primary partition",
                        "multi" : "Multi-volumes"
                      }
                    },

                },
                {
                  "id" : "disk:2",
                  "class" : "disk",
                  "claimed" : true,
                  "handle" : "SCSI:04:00:00:00",
                  "description" : "ATA Disk",
                  "product" : "Micron_1100_MTFD",
                  "physid" : "0.0.0",
                  "businfo" : "scsi@4:0.0.0",
                  "logicalname" : "/dev/sdc",
                  "dev" : "8:32",
                  "version" : "U031",
                  "serial" : "[REMOVED]",
                  "units" : "bytes",
                  "size" : 256060514304,
                  "configuration" : {
                    "ansiversion" : "5",
                    "logicalsectorsize" : "512",
                    "sectorsize" : "512",
                    "signature" : "1e6065d4"
                  },
                  "capabilities" : {
                    "partitioned" : "Partitioned disk",
                    "partitioned:dos" : "MS-DOS partition table"
                  }                    {
                      "id" : "volume:0",
                      "class" : "volume",
                      "claimed" : true,
                      "description" : "Linux raid autodetect partition",
                      "physid" : "1",
                      "businfo" : "scsi@4:0.0.0,1",
                      "logicalname" : "/dev/sdc1",
                      "dev" : "8:33",
                      "capacity" : 313524224,
                      "capabilities" : {
                        "primary" : "Primary partition",
                        "bootable" : "Bootable partition (active)",
                        "multi" : "Multi-volumes"
                      }
                    },
                    {
                      "id" : "volume:1",
                      "class" : "volume",
                      "claimed" : true,
                      "description" : "Linux swap volume",
                      "physid" : "2",
                      "businfo" : "scsi@4:0.0.0,2",
                      "logicalname" : "/dev/sdc2",
                      "dev" : "8:34",
                      "version" : "1",
                      "serial" : "[REMOVED]",
                      "size" : 2198863872,
                      "capacity" : 2198863872,
                      "configuration" : {
                        "filesystem" : "swap",
                        "pagesize" : "4096"
                      },
                      "capabilities" : {
                        "primary" : "Primary partition",
                        "nofs" : "No filesystem",
                        "swap" : "Linux swap",
                        "initialized" : "initialized volume"
                      }
                    },
                    {
                      "id" : "volume:2",
                      "class" : "volume",
                      "claimed" : true,
                      "description" : "Linux raid autodetect partition",
                      "physid" : "3",
                      "businfo" : "scsi@4:0.0.0,3",
                      "logicalname" : "/dev/sdc3",
                      "dev" : "8:35",
                      "capacity" : 253546725376,
                      "capabilities" : {
                        "primary" : "Primary partition",
                        "multi" : "Multi-volumes"
                      }
                    },

                },

            },
            {
              "id" : "pci:1",
              "class" : "bridge",
              "claimed" : true,
              "handle" : "PCIBUS:0000:02",
              "description" : "PCI bridge",
              "product" : "100 Series/C230 Series Chipset Family PCI Express Root Port #1",
              "vendor" : "Intel Corporation",
              "physid" : "1c",
              "businfo" : "pci@0000:00:1c.0",
              "version" : "f1",
              "width" : 32,
              "clock" : 33000000,
              "configuration" : {
                "driver" : "pcieport"
              },
              "capabilities" : {
                "pci" : true,
                "pciexpress" : "PCI Express",
                "msi" : "Message Signalled Interrupts",
                "pm" : "Power Management",
                "normal_decode" : true,
                "bus_master" : "bus mastering",
                "cap_list" : "PCI capabilities listing"
              }                {
                  "id" : "pci",
                  "class" : "bridge",
                  "claimed" : true,
                  "handle" : "PCIBUS:0000:03",
                  "description" : "PCI bridge",
                  "product" : "AST1150 PCI-to-PCI Bridge",
                  "vendor" : "ASPEED Technology, Inc.",
                  "physid" : "0",
                  "businfo" : "pci@0000:02:00.0",
                  "version" : "03",
                  "width" : 32,
                  "clock" : 33000000,
                  "capabilities" : {
                    "pci" : true,
                    "msi" : "Message Signalled Interrupts",
                    "pm" : "Power Management",
                    "pciexpress" : "PCI Express",
                    "normal_decode" : true,
                    "bus_master" : "bus mastering",
                    "cap_list" : "PCI capabilities listing"
                  }                    {
                      "id" : "display",
                      "class" : "display",
                      "claimed" : true,
                      "handle" : "PCI:0000:03:00.0",
                      "description" : "VGA compatible controller",
                      "product" : "ASPEED Graphics Family",
                      "vendor" : "ASPEED Technology, Inc.",
                      "physid" : "0",
                      "businfo" : "pci@0000:03:00.0",
                      "version" : "30",
                      "width" : 32,
                      "clock" : 33000000,
                      "configuration" : {
                        "driver" : "ast",
                        "latency" : "0"
                      },
                      "capabilities" : {
                        "pm" : "Power Management",
                        "msi" : "Message Signalled Interrupts",
                        "vga_controller" : true,
                        "bus_master" : "bus mastering",
                        "cap_list" : "PCI capabilities listing",
                        "rom" : "extension ROM"
                      }
                    },

                },

            },
            {
              "id" : "isa",
              "class" : "bridge",
              "claimed" : true,
              "handle" : "PCI:0000:00:1f.0",
              "description" : "ISA bridge",
              "product" : "C236 Chipset LPC/eSPI Controller",
              "vendor" : "Intel Corporation",
              "physid" : "1f",
              "businfo" : "pci@0000:00:1f.0",
              "version" : "31",
              "width" : 32,
              "clock" : 33000000,
              "configuration" : {
                "latency" : "0"
              },
              "capabilities" : {
                "isa" : true,
                "bus_master" : "bus mastering"
              }
            },
            {
              "id" : "memory",
              "class" : "memory",
              "handle" : "PCI:0000:00:1f.2",
              "description" : "Memory controller",
              "product" : "100 Series/C230 Series Chipset Family Power Management Controller",
              "vendor" : "Intel Corporation",
              "physid" : "1f.2",
              "businfo" : "pci@0000:00:1f.2",
              "version" : "31",
              "width" : 32,
              "clock" : 33000000,
              "configuration" : {
                "latency" : "0"
              },
              "capabilities" : {
                "bus_master" : "bus mastering"
              }
            },
            {
              "id" : "serial",
              "class" : "bus",
              "claimed" : true,
              "handle" : "PCI:0000:00:1f.4",
              "description" : "SMBus",
              "product" : "100 Series/C230 Series Chipset Family SMBus",
              "vendor" : "Intel Corporation",
              "physid" : "1f.4",
              "businfo" : "pci@0000:00:1f.4",
              "version" : "31",
              "width" : 64,
              "clock" : 33000000,
              "configuration" : {
                "driver" : "i801_smbus",
                "latency" : "0"
              }
            },

        },

    },

]
da-ekchajzer commented 1 year ago

Wow ! It seems pretty complete. You need to be root to access this command ?

I believe that anyway the API should be able to parse the output of this command. Do you think the output is normalized between distros ?

maethor commented 12 months ago

One year latter, this is what we do in energizta.sh :

# Remove header | Filter out some unused lines | Convert line by line to json dicts (with 2 or 3 keys) | Convert everthing to json list
# Parsing `lshw -json` with jq could be easier but we do not want jq as a global dependency
# So let's hope `lshw -short` format does not change too much
hardware="$(lshw -short 2>/dev/null | sed '0,/^=======/d' | grep -Ev "Ethernet interface|PnP device|Project-Id-Version" | grep -Ev "  (volume|bus)  " | sed 's/^[^ ]*  *//g' | sed -r 's/^([^ ]+)  +([^ ]+)  +(.*)/{"system": "\2", "logicalname": "\1",  "product": "\3"}/g' | sed -r 's/^([^ ]+)  +(.*)$/{"class": "\1", "product": "\2"}/g' | sed ':a; N; $!ba; s/\n/,\n/g' | sed '1 i\[' | sed '$a\]')"

I am closing this issue.