Created
July 14, 2023 07:45
-
-
Save podanypepa/4749365fb60e56ec631d9615644ad42a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/jaypipes/ghw" | |
) | |
func main() { | |
fmt.Println("MEMORY") | |
mem, memerr := ghw.Memory() | |
if memerr == nil { | |
fmt.Println(mem) | |
} | |
fmt.Println() | |
fmt.Println("CPU") | |
cpu, cpuerr := ghw.CPU() | |
if cpuerr == nil { | |
fmt.Println(cpu) | |
} | |
fmt.Println() | |
fmt.Println("DISK") | |
block, diskerr := ghw.Block() | |
if diskerr == nil { | |
for _, d := range block.Disks { | |
for _, p := range d.Partitions { | |
fmt.Println(p.Name, p.SizeBytes, p.MountPoint, p.UUID) | |
} | |
} | |
} | |
fmt.Println() | |
fmt.Println("TOPOLOGY") | |
topology, toperr := ghw.Topology() | |
if toperr == nil { | |
fmt.Println(topology) | |
} | |
fmt.Println() | |
fmt.Println("NETWORK") | |
net, neterr := ghw.Network() | |
if neterr == nil { | |
fmt.Println(net) | |
for _, n := range net.NICs { | |
fmt.Println(n.Name, n.IsVirtual, n.MacAddress, n.Speed) | |
} | |
} | |
fmt.Println() | |
fmt.Println("PCI") | |
pci, pcierr := ghw.PCI() | |
if pcierr == nil { | |
fmt.Println(pci) | |
for _, p := range pci.ListDevices() { | |
fmt.Println(p.Class.Name, p.Vendor.Name, p.Subclass.Name) | |
} | |
} | |
fmt.Println() | |
fmt.Println("CHASSIS") | |
chassis, chaserr := ghw.Chassis() | |
if chaserr == nil { | |
fmt.Println(chassis) | |
} | |
fmt.Println() | |
fmt.Println("BIOS") | |
bios, bioserr := ghw.BIOS() | |
if bioserr == nil { | |
fmt.Println(bios) | |
} | |
fmt.Println() | |
fmt.Println("BASEBOARD") | |
baseboard, boarderr := ghw.Baseboard() | |
if boarderr == nil { | |
fmt.Println(baseboard) | |
} | |
fmt.Println() | |
fmt.Println("PRODUCT") | |
product, proderr := ghw.Product() | |
if proderr == nil { | |
fmt.Println(product) | |
} | |
} | |
// output: | |
// | |
// my macbook pro with m2 chip: | |
// MEMORY | |
// CPU | |
// DISK | |
// disk0s1 524288000 | |
// disk0s2 494384795648 | |
// disk0s3 5368664064 | |
// disk1s1 5368664064 AE8E13CE-B3E1-4D65-8E1A-6784E48AC15C | |
// disk1s2 5368664064 17B7792E-A91B-435A-89B3-9D82C4C1B908 | |
// disk2s1 524288000 /System/Volumes/iSCPreboot DA966B4A-73D0-45A1-8BAA-2C1588B7C1BD | |
// disk2s2 524288000 /System/Volumes/xarts 4FEA39C1-7671-4D86-B3B7-C3773804438A | |
// disk2s3 524288000 /System/Volumes/Hardware 31D9CAB0-2E0A-4B25-8C60-3386FDDB78FC | |
// disk2s4 524288000 FC3C4C43-9C80-42A8-95C0-683604980FEB | |
// disk3s1 494384795648 /System/Volumes/Update/mnt1 02A0E879-B0EE-4FB2-BDDE-D1B80823E2C5 | |
// disk3s1s1 494384795648 / 5D74F069-D560-4315-8ABB-E8D6D81D2747 | |
// disk3s2 494384795648 /System/Volumes/Preboot 688AA9C5-7060-4CAA-8211-BBFEED8B6A1F | |
// disk3s3 494384795648 DBAB0E28-5E85-472F-89A0-DC559E501912 | |
// disk3s4 494384795648 /System/Volumes/Update D32E1D1C-A884-4148-A21C-79A3A7716146 | |
// disk3s5 494384795648 /System/Volumes/Data 6B15478D-56B3-4893-B940-F11FB324A777 | |
// disk3s6 494384795648 /System/Volumes/VM F87D8877-D4B5-4BD7-9A2C-399613E9E892 | |
// TOPOLOGY | |
// NETWORK | |
// PCI | |
// WARNING: error detecting system topology: topologyFillInfo not implemented on darwin | |
// CHASSIS | |
// BIOS | |
// BASEBOARD | |
// PRODUCT | |
// | |
// aws ec2 linux machine: | |
// | |
// MEMORY | |
// memory (4GB physical, 4GB usable) | |
// | |
// CPU | |
// cpu (1 physical package, 2 cores, 2 hardware threads) | |
// | |
// DISK | |
// xvda1 12750667264 / c472567b-8b67-d249-963d-59b45f92e235 | |
// xvda14 3145728 acf51e78-545c-044f-a88e-a123f094acb4 | |
// xvda15 130023424 /boot/efi 163e3e6e-4265-7144-b2c1-0f12b681edc4 | |
// | |
// TOPOLOGY | |
// topology SMP (1 nodes) | |
// | |
// NETWORK | |
// net (10 NICs) | |
// br-d58ac598d47d true 10000Mb/s | |
// br-e2316b442463 true 10000Mb/s | |
// docker0 true 10000Mb/s | |
// eth0 false 0a:84:46:2d:e7:ff | |
// veth3d0fee1 true 10000Mb/s | |
// veth59f497f true 10000Mb/s | |
// veth679838b true 10000Mb/s | |
// veth71e4229 true 10000Mb/s | |
// veth9de2132 true 10000Mb/s | |
// vethc09fa17 true 10000Mb/s | |
// | |
// PCI | |
// PCI (6 devices) | |
// Bridge Intel Corporation Host bridge | |
// Bridge Intel Corporation ISA bridge | |
// Mass storage controller Intel Corporation IDE interface | |
// Bridge Intel Corporation Bridge | |
// Display controller Cirrus Logic VGA compatible controller | |
// Unassigned class XenSource, Inc. unknown | |
// | |
// CHASSIS | |
// chassis type=Other vendor=Xen | |
// | |
// BIOS | |
// bios vendor=Xen version=4.2.amazon date=08/24/2006 | |
// | |
// BASEBOARD | |
// WARNING: Unable to read board_asset_tag: open /sys/class/dmi/id/board_asset_tag: no such file or directory | |
// WARNING: Unable to read board_serial: open /sys/class/dmi/id/board_serial: no such file or directory | |
// WARNING: Unable to read board_vendor: open /sys/class/dmi/id/board_vendor: no such file or directory | |
// WARNING: Unable to read board_version: open /sys/class/dmi/id/board_version: no such file or directory | |
// WARNING: Unable to read board_name: open /sys/class/dmi/id/board_name: no such file or directory | |
// baseboard vendor=unknown version=unknown product=unknown | |
// | |
// PRODUCT | |
// product name=HVM domU vendor=Xen serial=ec277c89-fadc-ec18-7c44-92ab5f252646 uuid=ec277c89-fadc-ec18-7c44-92ab5f252646 version=4.2.amazon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment