Documentation ¶
Overview ¶
package ghw can determine various hardware-related information about the host computer:
* Memory * CPU * Block storage * Topology * Network * PCI * GPU
Memory ¶
Information about the host computer's memory can be retrieved using the Memory function which returns a pointer to a MemoryInfo struct.
package main import ( "fmt" "github.com/jaypipes/ghw" ) func main() { memory, err := ghw.Memory() if err != nil { fmt.Printf("Error getting memory info: %v", err) } fmt.Println(memory.String()) }
CPU ¶
The CPU function returns a CPUInfo struct that contains information about the CPUs on the host system.
package main import ( "fmt" "math" "strings" "github.com/jaypipes/ghw" ) func main() { cpu, err := ghw.CPU() if err != nil { fmt.Printf("Error getting CPU info: %v", err) } fmt.Printf("%v\n", cpu) for _, proc := range cpu.Processors { fmt.Printf(" %v\n", proc) for _, core := range proc.Cores { fmt.Printf(" %v\n", core) } if len(proc.Capabilities) > 0 { // pretty-print the (large) block of capability strings into rows // of 6 capability strings rows := int(math.Ceil(float64(len(proc.Capabilities)) / float64(6))) for row := 1; row < rows; row = row + 1 { rowStart := (row * 6) - 1 rowEnd := int(math.Min(float64(rowStart+6), float64(len(proc.Capabilities)))) rowElems := proc.Capabilities[rowStart:rowEnd] capStr := strings.Join(rowElems, " ") if row == 1 { fmt.Printf(" capabilities: [%s\n", capStr) } else if rowEnd < len(proc.Capabilities) { fmt.Printf(" %s\n", capStr) } else { fmt.Printf(" %s]\n", capStr) } } } } }
Block storage ¶
Information about the host computer's local block storage is returned from the Block function. This function returns a pointer to a BlockInfo struct.
package main import ( "fmt" "github.com/jaypipes/ghw" ) func main() { block, err := ghw.Block() if err != nil { fmt.Printf("Error getting block storage info: %v", err) } fmt.Printf("%v\n", block) for _, disk := range block.Disks { fmt.Printf(" %v\n", disk) for _, part := range disk.Partitions { fmt.Printf(" %v\n", part) } } }
Topology ¶
Information about the host computer's architecture (NUMA vs. SMP), the host's node layout and processor caches can be retrieved from the Topology function. This function returns a pointer to a TopologyInfo struct.
package main import ( "fmt" "github.com/jaypipes/ghw" ) func main() { topology, err := ghw.Topology() if err != nil { fmt.Printf("Error getting topology info: %v", err) } fmt.Printf("%v\n", topology) for _, node := range topology.Nodes { fmt.Printf(" %v\n", node) for _, cache := range node.Caches { fmt.Printf(" %v\n", cache) } } }
Network ¶
Information about the host computer's networking hardware is returned from the Network function. This function returns a pointer to a NetworkInfo struct.
package main import ( "fmt" "github.com/jaypipes/ghw" ) func main() { net, err := ghw.Network() if err != nil { fmt.Printf("Error getting network info: %v", err) } fmt.Printf("%v\n", net) for _, nic := range net.NICs { fmt.Printf(" %v\n", nic) enabledCaps := make([]int, 0) for x, cap := range nic.Capabilities { if cap.IsEnabled { enabledCaps = append(enabledCaps, x) } } if len(enabledCaps) > 0 { fmt.Printf(" enabled capabilities:\n") for _, x := range enabledCaps { fmt.Printf(" - %s\n", nic.Capabilities[x].Name) } } } }
PCI ¶
ghw contains a PCI database inspection and querying facility that allows developers to not only gather information about devices on a local PCI bus but also query for information about hardware device classes, vendor and product information.
**NOTE**: Parsing of the PCI-IDS file database is provided by the separate http://github.com/jaypipes/pcidb library. You can read that library's README for more information about the various structs that are exposed on the PCIInfo struct.
PCIInfo.ListDevices is used to iterate over a host's PCI devices:
package main import ( "fmt" "github.com/jaypipes/ghw" ) func main() { pci, err := ghw.PCI() if err != nil { fmt.Printf("Error getting PCI info: %v", err) } fmt.Printf("host PCI devices:\n") fmt.Println("====================================================") devices := pci.ListDevices() if len(devices) == 0 { fmt.Printf("error: could not retrieve PCI devices\n") return } for _, device := range devices { vendor := device.Vendor vendorName := vendor.Name if len(vendor.Name) > 20 { vendorName = string([]byte(vendorName)[0:17]) + "..." } product := device.Product productName := product.Name if len(product.Name) > 40 { productName = string([]byte(productName)[0:37]) + "..." } fmt.Printf("%-12s\t%-20s\t%-40s\n", device.Address, vendorName, productName) } }
The following code snippet shows how to call the PCIInfo.GetDevice method and use its returned PCIDevice struct pointer:
package main import ( "fmt" "os" "github.com/jaypipes/ghw" ) func main() { pci, err := ghw.PCI() if err != nil { fmt.Printf("Error getting PCI info: %v", err) } addr := "0000:00:00.0" if len(os.Args) == 2 { addr = os.Args[1] } fmt.Printf("PCI device information for %s\n", addr) fmt.Println("====================================================") deviceInfo := pci.GetDevice(addr) if deviceInfo == nil { fmt.Printf("could not retrieve PCI device information for %s\n", addr) return } vendor := deviceInfo.Vendor fmt.Printf("Vendor: %s [%s]\n", vendor.Name, vendor.ID) product := deviceInfo.Product fmt.Printf("Product: %s [%s]\n", product.Name, product.ID) subsystem := deviceInfo.Subsystem subvendor := pci.Vendors[subsystem.VendorID] subvendorName := "UNKNOWN" if subvendor != nil { subvendorName = subvendor.Name } fmt.Printf("Subsystem: %s [%s] (Subvendor: %s)\n", subsystem.Name, subsystem.ID, subvendorName) class := deviceInfo.Class fmt.Printf("Class: %s [%s]\n", class.Name, class.ID) subclass := deviceInfo.Subclass fmt.Printf("Subclass: %s [%s]\n", subclass.Name, subclass.ID) progIface := deviceInfo.ProgrammingInterface fmt.Printf("Programming Interface: %s [%s]\n", progIface.Name, progIface.ID) }
GPU ¶
Information about the host computer's graphics hardware is returned from the GPU function. This function returns a pointer to a GPUInfo struct.
package main import ( "fmt" "github.com/jaypipes/ghw" ) func main() { gpu, err := ghw.GPU() if err != nil { fmt.Printf("Error getting GPU info: %v", err) } fmt.Printf("%v\n", gpu) for _, card := range gpu.GraphicsCards { fmt.Printf(" %v\n", card) } }
Index ¶
- Constants
- Variables
- func DiskBusPath(disk string) string
- func DiskModel(disk string) string
- func DiskNUMANodeID(disk string) int
- func DiskPhysicalBlockSizeBytes(disk string) uint64
- func DiskSerialNumber(disk string) string
- func DiskSizeBytes(disk string) uint64
- func DiskVendor(disk string) string
- func DiskWWN(disk string) string
- func PartitionInfo(part string) (string, string, bool)
- func PartitionIsReadOnly(part string) bool
- func PartitionMountPoint(part string) string
- func PartitionSizeBytes(part string) uint64
- func PartitionType(part string) string
- type Architecture
- type BlockInfo
- type BusType
- type CPUInfo
- type Disk
- type DriveType
- type GPUInfo
- type GraphicsCard
- type HostInfo
- type MemoryCache
- type MemoryCacheType
- type MemoryInfo
- type NIC
- type NICCapability
- type NetworkInfo
- type PCIAddress
- type PCIDevice
- type PCIInfo
- type Partition
- type Processor
- type ProcessorCore
- type SortByLogicalProcessorId
- type SortByMemoryCacheLevelTypeFirstProcessor
- type StorageController
- type TopologyInfo
- type TopologyNode
- type WithOption
Constants ¶
const (
UNKNOWN = "unknown"
)
Variables ¶
Functions ¶
func DiskBusPath ¶
DiskBusPath has been deprecated in 0.2. Please use the Disk.BusPath attribute. TODO(jaypipes): Remove in 1.0.
func DiskModel ¶
DiskModel has been deprecated in 0.2. Please use the Disk.Model attribute. TODO(jaypipes): Remove in 1.0.
func DiskNUMANodeID ¶
DiskNUMANodeID has been deprecated in 0.2. Please use the Disk.NUMANodeID attribute. TODO(jaypipes): Remove in 1.0.
func DiskPhysicalBlockSizeBytes ¶
DiskPhysicalBlockSizeBytes has been deprecated in 0.2. Please use the Disk.PhysicalBlockSizeBytes attribute. TODO(jaypipes): Remove in 1.0.
func DiskSerialNumber ¶
DiskSerialNumber has been deprecated in 0.2. Please use the Disk.SerialNumber attribute. TODO(jaypipes): Remove in 1.0.
func DiskSizeBytes ¶
DiskSizeBytes has been deprecated in 0.2. Please use the Disk.SizeBytes attribute. TODO(jaypipes): Remove in 1.0.
func DiskVendor ¶
DiskVendor has been deprecated in 0.2. Please use the Disk.Vendor attribute. TODO(jaypipes): Remove in 1.0.
func DiskWWN ¶
DiskWWN has been deprecated in 0.2. Please use the Disk.WWN attribute. TODO(jaypipes): Remove in 1.0.
func PartitionInfo ¶
PartitionInfo has been deprecated in 0.2. Please use the Partition struct. TODO(jaypipes): Remove in 1.0.
func PartitionIsReadOnly ¶
PartitionIsReadOnly has been deprecated in 0.2. Please use the Partition.IsReadOnly attribute. TODO(jaypipes): Remove in 1.0.
func PartitionMountPoint ¶
PartitionMountPoint has been deprecated in 0.2. Please use the Partition.MountPoint attribute. TODO(jaypipes): Remove in 1.0.
func PartitionSizeBytes ¶
PartitionSizeBytes has been deprecated in 0.2. Please use the Partition.SizeBytes attribute. TODO(jaypipes): Remove in 1.0.
func PartitionType ¶
PartitionType has been deprecated in 0.2. Please use the Partition.Type attribute. TODO(jaypipes): Remove in 1.0.
Types ¶
type Architecture ¶
type Architecture int
Architecture describes the overall hardware architecture. It can be either Symmetric Multi-Processor (SMP) or Non-Uniform Memory Access (NUMA)
const ( // SMP is a Symmetric Multi-Processor system ARCHITECTURE_SMP Architecture = iota // NUMA is a Non-Uniform Memory Access system ARCHITECTURE_NUMA )
func (Architecture) MarshalJSON ¶
func (a Architecture) MarshalJSON() ([]byte, error)
NOTE(jaypipes): since serialized output is as "official" as we're going to get, let's lowercase the string output when serializing, in order to "normalize" the expected serialized output
func (Architecture) String ¶
func (a Architecture) String() string
type BlockInfo ¶
type BlockInfo struct { // TODO(jaypipes): Deprecate this field and replace with TotalSizeBytes TotalPhysicalBytes uint64 `json:"total_size_bytes"` Disks []*Disk `json:"disks"` Partitions []*Partition `json:"-"` }
BlockInfo describes all disk drives and partitions in the host system.
func Block ¶
func Block(opts ...*WithOption) (*BlockInfo, error)
Block returns a BlockInfo struct that describes the block storage resources of the host system.
func (*BlockInfo) JSONString ¶
JSONString returns a string with the block information formatted as JSON under a top-level "block:" key
func (*BlockInfo) YAMLString ¶
YAMLString returns a string with the block information formatted as YAML under a top-level "block:" key
type BusType ¶
type BusType int
func (BusType) MarshalJSON ¶
NOTE(jaypipes): since serialized output is as "official" as we're going to get, let's lowercase the string output when serializing, in order to "normalize" the expected serialized output
type CPUInfo ¶
type CPUInfo struct { // TotalCores is the total number of physical cores the host system // contains TotalCores uint32 `json:"total_cores"` // TotalThreads is the total number of hardware threads the host system // contains TotalThreads uint32 `json:"total_threads"` // Processors is a slice of Processor struct pointers, one for each // physical processor package contained in the host Processors []*Processor `json:"processors"` }
CPUInfo describes all central processing unit (CPU) functionality on a host. Returned by the `ghw.CPU()` function.
func CPU ¶
func CPU(opts ...*WithOption) (*CPUInfo, error)
CPU returns a CPUInfo struct that contains information about the CPUs on the host system
func (*CPUInfo) JSONString ¶
JSONString returns a string with the cpu information formatted as JSON under a top-level "cpu:" key
func (*CPUInfo) YAMLString ¶
YAMLString returns a string with the cpu information formatted as YAML under a top-level "cpu:" key
type Disk ¶
type Disk struct { Name string `json:"name"` SizeBytes uint64 `json:"size_bytes"` PhysicalBlockSizeBytes uint64 `json:"physical_block_size_bytes"` DriveType DriveType `json:"drive_type"` StorageController StorageController `json:"storage_controller"` // NOTE(jaypipes): BusType is DEPRECATED. Use the DriveType and // StorageController fields instead BusType BusType `json:"-"` BusPath string `json:"bus_path"` // TODO(jaypipes): Convert this to a TopologyNode struct pointer and then // add to serialized output as "numa_node,omitempty" NUMANodeID int `json:"-"` Vendor string `json:"vendor"` Model string `json:"model"` SerialNumber string `json:"serial_number"` WWN string `json:"wwn"` Partitions []*Partition `json:"partitions"` }
Disk describes a single disk drive on the host system. Disk drives provide raw block storage resources.
type DriveType ¶
type DriveType int
DriveType describes the general category of drive device
func (DriveType) MarshalJSON ¶
NOTE(jaypipes): since serialized output is as "official" as we're going to get, let's lowercase the string output when serializing, in order to "normalize" the expected serialized output
type GPUInfo ¶
type GPUInfo struct {
GraphicsCards []*GraphicsCard `json:"cards"`
}
func GPU ¶
func GPU(opts ...*WithOption) (*GPUInfo, error)
func (*GPUInfo) JSONString ¶
JSONString returns a string with the gpu information formatted as JSON under a top-level "gpu:" key
func (*GPUInfo) YAMLString ¶
YAMLString returns a string with the gpu information formatted as YAML under a top-level "gpu:" key
type GraphicsCard ¶
type GraphicsCard struct { // the PCI address where the graphics card can be found Address string `json:"address"` // The "index" of the card on the bus (generally not useful information, // but might as well include it) Index int `json:"index"` // pointer to a PCIDevice struct that describes the vendor and product // model, etc // TODO(jaypipes): Rename this field to PCI, instead of DeviceInfo DeviceInfo *PCIDevice `json:"pci"` // Topology node that the graphics card is affined to. Will be nil if the // architecture is not NUMA. Node *TopologyNode `json:"node,omitempty"` }
func (*GraphicsCard) String ¶
func (card *GraphicsCard) String() string
type HostInfo ¶
type HostInfo struct { Memory *MemoryInfo `json:"memory"` Block *BlockInfo `json:"block"` CPU *CPUInfo `json:"cpu"` Topology *TopologyInfo `json:"topology"` Network *NetworkInfo `json:"network"` GPU *GPUInfo `json:"gpu"` }
HostInfo is a wrapper struct containing information about the host system's memory, block storage, CPU, etc
func Host ¶
func Host(opts ...*WithOption) (*HostInfo, error)
Host returns a pointer to a HostInfo struct that contains fields with information about the host system's CPU, memory, network devices, etc
func (*HostInfo) JSONString ¶
JSONString returns a string with the host information formatted as JSON under a top-level "host:" key
func (*HostInfo) String ¶
String returns a newline-separated output of the HostInfo's component structs' String-ified output
func (*HostInfo) YAMLString ¶
YAMLString returns a string with the host information formatted as YAML under a top-level "host:" key
type MemoryCache ¶
type MemoryCache struct { Level uint8 `json:"level"` Type MemoryCacheType `json:"type"` SizeBytes uint64 `json:"size_bytes"` // The set of logical processors (hardware threads) that have access to the // cache LogicalProcessors []uint32 `json:"logical_processors"` }
func (*MemoryCache) String ¶
func (c *MemoryCache) String() string
type MemoryCacheType ¶
type MemoryCacheType int
const ( MEMORY_CACHE_TYPE_UNIFIED MemoryCacheType = iota MEMORY_CACHE_TYPE_INSTRUCTION MEMORY_CACHE_TYPE_DATA )
func (MemoryCacheType) MarshalJSON ¶
func (a MemoryCacheType) MarshalJSON() ([]byte, error)
NOTE(jaypipes): since serialized output is as "official" as we're going to get, let's lowercase the string output when serializing, in order to "normalize" the expected serialized output
func (MemoryCacheType) String ¶
func (a MemoryCacheType) String() string
type MemoryInfo ¶
type MemoryInfo struct { TotalPhysicalBytes int64 `json:"total_physical_bytes"` TotalUsableBytes int64 `json:"total_usable_bytes"` // An array of sizes, in bytes, of memory pages supported by the host SupportedPageSizes []uint64 `json:"supported_page_sizes"` }
func Memory ¶
func Memory(opts ...*WithOption) (*MemoryInfo, error)
func (*MemoryInfo) JSONString ¶
func (i *MemoryInfo) JSONString(indent bool) string
JSONString returns a string with the memory information formatted as JSON under a top-level "memory:" key
func (*MemoryInfo) String ¶
func (i *MemoryInfo) String() string
func (*MemoryInfo) YAMLString ¶
func (i *MemoryInfo) YAMLString() string
YAMLString returns a string with the memory information formatted as YAML under a top-level "memory:" key
type NIC ¶
type NIC struct { Name string `json:"name"` MacAddress string `json:"mac_address"` IsVirtual bool `json:"is_virtual"` Vendor string `json:"vendor"` Model string `json:"model"` Capabilities []*NICCapability `json:"capabilities"` }
type NICCapability ¶
type NetworkInfo ¶
type NetworkInfo struct {
NICs []*NIC `json:"nics"`
}
func Network ¶
func Network(opts ...*WithOption) (*NetworkInfo, error)
func (*NetworkInfo) JSONString ¶
func (i *NetworkInfo) JSONString(indent bool) string
JSONString returns a string with the net information formatted as JSON under a top-level "net:" key
func (*NetworkInfo) String ¶
func (i *NetworkInfo) String() string
func (*NetworkInfo) YAMLString ¶
func (i *NetworkInfo) YAMLString() string
YAMLString returns a string with the net information formatted as YAML under a top-level "net:" key
type PCIAddress ¶
func PCIAddressFromString ¶
func PCIAddressFromString(address string) *PCIAddress
Given a string address, returns a complete PCIAddress struct, filled in with domain, bus, slot and function components. The address string may either be in $BUS:$SLOT.$FUNCTION (BSF) format or it can be a full PCI address that includes the 4-digit $DOMAIN information as well: $DOMAIN:$BUS:$SLOT.$FUNCTION.
Returns "" if the address string wasn't a valid PCI address.
type PCIDevice ¶
type PCIDevice struct { // The PCI address of the device Address string `json:"address"` Vendor *pcidb.Vendor `json:"vendor"` Product *pcidb.Product `json:"product"` Subsystem *pcidb.Product `json:"subsystem"` // optional subvendor/sub-device information Class *pcidb.Class `json:"class"` // optional sub-class for the device Subclass *pcidb.Subclass `json:"subclass"` // optional programming interface ProgrammingInterface *pcidb.ProgrammingInterface `json:"programming_interface"` }
func (*PCIDevice) MarshalJSON ¶
NOTE(jaypipes) PCIDevice has a custom JSON marshaller because we don't want to serialize the entire PCIDB information for the Vendor (which includes all of the vendor's products, etc). Instead, we simply serialize the ID and human-readable name of the vendor, product, class, etc.
type PCIInfo ¶
type PCIInfo struct { // hash of class ID -> class information Classes map[string]*pcidb.Class // hash of vendor ID -> vendor information Vendors map[string]*pcidb.Vendor // hash of vendor ID + product/device ID -> product information Products map[string]*pcidb.Product // contains filtered or unexported fields }
func PCI ¶
func PCI(opts ...*WithOption) (*PCIInfo, error)
func (*PCIInfo) GetDevice ¶
GetDevice returns a pointer to a PCIDevice struct that describes the PCI device at the requested address. If no such device could be found, returns nil
func (*PCIInfo) ListDevices ¶
ListDevices returns a list of pointers to PCIDevice structs present on the host system
type Partition ¶
type Partition struct { Disk *Disk `json:"-"` Name string `json:"name"` Label string `json:"label"` MountPoint string `json:"mount_point"` SizeBytes uint64 `json:"size_bytes"` Type string `json:"type"` IsReadOnly bool `json:"read_only"` }
Partition describes a logical division of a Disk.
func DiskPartitions ¶
DiskPartitions has been deprecated in 0.2. Please use the Disk.Partitions attribute. TODO(jaypipes): Remove in 1.0.
type Processor ¶
type Processor struct { // TODO(jaypipes): Deprecated in 0.2, remove in 1.0 Id int `json:"-"` // ID is the physical processor `uint32` ID according to the system ID int `json:"id"` // NumCores is the number of physical cores in the processor package NumCores uint32 `json:"total_cores"` // NumThreads is the number of hardware threads in the processor package NumThreads uint32 `json:"total_threads"` // Vendor is a string containing the vendor name Vendor string `json:"vendor"` // Model` is a string containing the vendor's model name Model string `json:"model"` // Capabilities is a slice of strings indicating the features the processor // has enabled Capabilities []string `json:"capabilities"` // Cores is a slice of ProcessorCore` struct pointers that are packed onto // this physical processor Cores []*ProcessorCore `json:"cores"` }
Processor describes a physical host central processing unit (CPU).
func Processors ¶
func Processors() []*Processor
Processors has been DEPRECATED in 0.2 and will be REMOVED in 1.0. Please use the CPUInfo.Processors attribute. TODO(jaypipes): Remove in 1.0
func (*Processor) HasCapability ¶
HasCapability returns true if the Processor has the supplied cpuid capability, false otherwise. Example of cpuid capabilities would be 'vmx' or 'sse4_2'. To see a list of potential cpuid capabilitiies, see the section on CPUID feature bits in the following article:
type ProcessorCore ¶
type ProcessorCore struct { // TODO(jaypipes): Deprecated in 0.2, remove in 1.0 Id int `json:"-"` // ID is the `uint32` identifier that the host gave this core. Note that // this does *not* necessarily equate to a zero-based index of the core // within a physical package. For example, the core IDs for an Intel Core // i7 are 0, 1, 2, 8, 9, and 10 ID int `json:"id"` // Index is the zero-based index of the core on the physical processor // package Index int `json:"index"` // NumThreads is the number of hardware threads associated with the core NumThreads uint32 `json:"total_threads"` // LogicalProcessors is a slice of ints representing the logical processor // IDs assigned to any processing unit for the core LogicalProcessors []int `json:"logical_processors"` }
ProcessorCore describes a physical host processor core. A processor core is a separate processing unit within some types of central processing units (CPU).
func (*ProcessorCore) String ¶
func (c *ProcessorCore) String() string
String returns a short string indicating important information about the processor core
type SortByLogicalProcessorId ¶
type SortByLogicalProcessorId []uint32
func (SortByLogicalProcessorId) Len ¶
func (a SortByLogicalProcessorId) Len() int
func (SortByLogicalProcessorId) Less ¶
func (a SortByLogicalProcessorId) Less(i, j int) bool
func (SortByLogicalProcessorId) Swap ¶
func (a SortByLogicalProcessorId) Swap(i, j int)
type SortByMemoryCacheLevelTypeFirstProcessor ¶
type SortByMemoryCacheLevelTypeFirstProcessor []*MemoryCache
func (SortByMemoryCacheLevelTypeFirstProcessor) Len ¶
func (a SortByMemoryCacheLevelTypeFirstProcessor) Len() int
func (SortByMemoryCacheLevelTypeFirstProcessor) Less ¶
func (a SortByMemoryCacheLevelTypeFirstProcessor) Less(i, j int) bool
func (SortByMemoryCacheLevelTypeFirstProcessor) Swap ¶
func (a SortByMemoryCacheLevelTypeFirstProcessor) Swap(i, j int)
type StorageController ¶
type StorageController int
StorageController is a category of block storage controller/driver. It represents more of the physical hardware interface than the storage protocol, which represents more of the software interface.
See discussion on https://github.com/jaypipes/ghw/issues/117
const ( STORAGE_CONTROLLER_UNKNOWN StorageController = iota STORAGE_CONTROLLER_IDE // Integrated Drive Electronics STORAGE_CONTROLLER_SCSI // Small computer system interface STORAGE_CONTROLLER_NVME // Non-volatile Memory Express STORAGE_CONTROLLER_VIRTIO // Virtualized storage controller/driver )
func (StorageController) MarshalJSON ¶
func (sc StorageController) MarshalJSON() ([]byte, error)
NOTE(jaypipes): since serialized output is as "official" as we're going to get, let's lowercase the string output when serializing, in order to "normalize" the expected serialized output
func (StorageController) String ¶
func (sc StorageController) String() string
type TopologyInfo ¶
type TopologyInfo struct { Architecture Architecture `json:"architecture"` Nodes []*TopologyNode `json:"nodes"` }
TopologyInfo describes the system topology for the host hardware
func Topology ¶
func Topology(opts ...*WithOption) (*TopologyInfo, error)
Topology returns a TopologyInfo struct that describes the system topology of the host hardware
func (*TopologyInfo) JSONString ¶
func (i *TopologyInfo) JSONString(indent bool) string
JSONString returns a string with the topology information formatted as JSON under a top-level "topology:" key
func (*TopologyInfo) String ¶
func (i *TopologyInfo) String() string
func (*TopologyInfo) YAMLString ¶
func (i *TopologyInfo) YAMLString() string
YAMLString returns a string with the topology information formatted as YAML under a top-level "topology:" key
type TopologyNode ¶
type TopologyNode struct { // TODO(jaypipes): Deprecated in 0.2, remove in 1.0 Id int `json:"-"` ID int `json:"id"` Cores []*ProcessorCore `json:"cores"` Caches []*MemoryCache `json:"caches"` }
TopologyNode is an abstract construct representing a collection of processors and various levels of memory cache that those processors share. In a NUMA architecture, there are multiple NUMA nodes, abstracted here as multiple TopologyNode structs. In an SMP architecture, a single TopologyNode will be available in the TopologyInfo struct and this single struct can be used to describe the levels of memory caching available to the single physical processor package's physical processor cores
func TopologyNodes ¶
func TopologyNodes() ([]*TopologyNode, error)
TopologyNodes has been deprecated in 0.2. Please use the TopologyInfo.Nodes attribute. TODO(jaypipes): Remove in 1.0.
func (*TopologyNode) String ¶
func (n *TopologyNode) String() string
type WithOption ¶
type WithOption struct { // To facilitate querying of sysfs filesystems that are bind-mounted to a // non-default root mountpoint, we allow users to set the GHW_CHROOT environ // vairable to an alternate mountpoint. For instance, assume that the user of // ghw is a Golang binary being executed from an application container that has // certain host filesystems bind-mounted into the container at /host. The user // would ensure the GHW_CHROOT environ variable is set to "/host" and ghw will // build its paths from that location instead of / Chroot *string }
WithOption is used to represent optionally-configured settings. Each field is a pointer to some concrete value so that we can tell when something has been set or left unset.
func WithChroot ¶
func WithChroot(dir string) *WithOption