Skip to content
Package smbios provides detection and access to System Management BIOS (SMBIOS) and Desktop Management Interface (DMI) data and structures. Apache 2.0 Licensed.
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd *: update license to 2017-2018 Apr 20, 2018
scripts
smbios smbios: factor out and test windows parsing Sep 7, 2018
.travis.yml smbios: find entry point in memory, add integration test Nov 21, 2017
AUTHORS meta: update AUTHORS Sep 6, 2018
CONTRIBUTING.md
LICENSE.md *: initial commit Nov 9, 2017
README.md

README.md

go-smbios Build Status GoDoc Go Report Card

Package smbios provides detection and access to System Management BIOS (SMBIOS) and Desktop Management Interface (DMI) data and structures. Apache 2.0 Licensed.

Introduction

SMBIOS is a standard mechanism for fetching BIOS and hardware information from within an operating system. It shares some similarities with the older DMI standard, and the two are often confused.

To install this package, run:

$ go get github.com/digitalocean/go-smbios/smbios

This package is based on the SMBIOS 3.1.1 specification, but should work with SMBIOS 2.0 and above.

In general, it's up to hardware manufacturers to properly populate SMBIOS data, and many structures may not be populated correctly or at all; especially on consumer hardware.

The smbios.Structure types created by this package can be decoded using the structure information in the SMBIOS specification. In the future, some common structures may be parsed and readily available by using this package.

Supported operating systems and their SMBIOS retrieval mechanisms include:

  • DragonFlyBSD (/dev/mem)
  • FreeBSD (/dev/mem)
  • Linux (sysfs and /dev/mem)
  • NetBSD (/dev/mem)
  • OpenBSD (/dev/mem)
  • Solaris (/dev/mem)
  • Windows (GetSystemFirmwareTable)

At this time, macOS is not supported, as it does not expose SMBIOS information in the same way as the supported operating systems. Pull requests are welcome to add support for additional operating systems.

Example

See cmd/lssmbios for a runnable example. Note that retrieving SMBIOS information is a privileged operation. On Linux, you may invoke the binary as root directly, or apply the CAP_DAC_OVERRIDE capability to enable reading the information without superuser access.

Here's the gist of it:

// Find SMBIOS data in operating system-specific location.
rc, ep, err := smbios.Stream()
if err != nil {
	log.Fatalf("failed to open stream: %v", err)
}
// Be sure to close the stream!
defer rc.Close()

// Decode SMBIOS structures from the stream.
d := smbios.NewDecoder(rc)
ss, err := d.Decode()
if err != nil {
	log.Fatalf("failed to decode structures: %v", err)
}

// Determine SMBIOS version and table location from entry point.
major, minor, rev := ep.Version()
addr, size := ep.Table()

fmt.Printf("SMBIOS %d.%d.%d - table: address: %#x, size: %d\n",
	major, minor, rev, addr, size)

for _, s := range ss {
	fmt.Println(s)
}
You can’t perform that action at this time.