Code Monkey home page Code Monkey logo

go-smbios's Introduction

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)
}

go-smbios's People

Contributors

mdlayher avatar chris-dudley avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.