Code Monkey home page Code Monkey logo

dmidecode's Introduction

dmidecode

Build and Test codecov Go Report Card Release MIT License

纯Golang实现的dmidecode, 零依赖, 支持Linux, Unix, Windows

功能和命令行的dmidecode工具一样, 使用方式参考: example

开发过程相关小博客: 使用Golang重新实现dmidecode

安装方式

$ go get "github.com/yumaojun03/dmidecode"

使用样例

package main

import (
	"fmt"
	"os"

	"github.com/yumaojun03/dmidecode"
)

func checkError(err error) {
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}

func main() {
	dmi, err := dmidecode.New()
	checkError(err)

	infos, err := dmi.BIOS()
	// 支持以下类型的解析
	// dmi.BaseBoard()
	// dmi.Chassis()
	// dmi.MemoryArray()
	// dmi.MemoryDevice()
	// dmi.Onboard()
	// dmi.PortConnector()
	// dmi.Processor()
	// dmi.ProcessorCache()
	// dmi.Slot()
	// dmi.System()
	checkError(err)

	for i := range infos {
		fmt.Println(infos[i])
	}
}

CLI 使用

$ go run cmd/main.go -d -t [bios, system, baseboard, chassis, onboard, port, processor, memory, slot]

dmidecode's People

Contributors

0x1un avatar danile71 avatar huhaibo avatar ktdynamic avatar luhuaei avatar mmsoon avatar oldtree avatar xuebuqing avatar xuyi avatar yumaojun03 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dmidecode's Issues

机载设备获取不正确,On Board Device获取不出来

我的命令行输出:
On Board Device 1 Information
Type: Video
Status: Disabled
Description: VMware SVGA II
On Board Device 2 Information
Type: Sound
Status: Disabled
Description: ES1371
使用dmi.Onboard()获取失败:
获取出来是这个:SMBIOS 2.7.0 - table: address: 0xe0010, size: 28932

feature request: Obtain OEM info

like

sudo dmidecode -t 11

output like:

# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 3.2.0 present.

Handle 0x0B00, DMI type 11, 5 bytes
OEM Strings
	String 1: Dell System
	String 2: 5[0000]
	String 3: 14[1]
	String 4: 26[0]
	String 5: 17[A4B60183CF8FDCD8]
	String 6: 17[A6BDC5E1EE433F13]
	String 7: 18[0]
	String 8: 19[1]
	String 9: 19[1]

wrong system-uuid

image

As of version 2.6 of the SMBIOS specification, the first 3 fields of the UUID are supposed to be encoded on little-endian.

the version should be SMBIOS version, not system-version.

Hello, smbios/structrue.go的GetString函数可能数组越界panic

func (s *Structure) GetString(offset int) string {
if offset > s.FormattedCount()-1 {
return "Unknown"
}

index := s.Formatted[offset]

if index == 0 {
	return "Unknown"
}

return s.Strings[index-1]  // 这里是否需要判断下是否越界,否则异常下会直接panic?

}

cpuid似乎解析的不对

命令:dmidecode -t 4

dmidecode 3.2

Getting SMBIOS data from sysfs.
SMBIOS 2.7 present.

Handle 0x0004, DMI type 4, 42 bytes
Processor Information
Socket Designation: CPU #000
Type: Central Processor
Family: Unknown
Manufacturer: GenuineIntel
ID: EA 06 09 00 FF FB 8B 1F
Version: Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz
Voltage: 3.3 V
External Clock: Unknown
Max Speed: 30000 MHz
Current Speed: 3000 MHz
Status: Populated, Enabled
Upgrade: ZIF Socket
L1 Cache Handle: 0x0094
L2 Cache Handle: 0x0114
L3 Cache Handle: Not Provided
Serial Number: Not Specified
Asset Tag: Not Specified
Part Number: Not Specified
Core Count: 2
Core Enabled: 2
Characteristics:
64-bit capable
Multi-Core
Execute Protection
这是我命令行返回的CPU信息,我获取到的ID是0,我想获取的是这个 ID: EA 06 09 00 FF FB 8B 1F

dmidecode -t processor bug

cmd/main.go

	case "processor":
		infos, err := decoder.Processor()
		checkDecodeErr(t, err)
		for i := range infos {
			fmt.Println(infos[i])
		}
		pcinfos, err := decoder.ProcessorCache()
		checkDecodeErr(t, err)
		for i := range infos {
			fmt.Println(pcinfos[i])
		}

should be

	case "processor":
		infos, err := decoder.Processor()
		checkDecodeErr(t, err)
		for i := range infos {
			fmt.Println(infos[i])
		}
		pcinfos, err := decoder.ProcessorCache()
		checkDecodeErr(t, err)
		for i := range pcinfos {
			fmt.Println(pcinfos[i])
		}

centos6下执行报错

SMBIOS 2.7.0 - table: address: 0xcf42c000, size: 4858
panic: runtime error: index out of range [36] with length 36

goroutine 1 [running]:
github.com/yumaojun03/dmidecode/parser/processor.ParseProcessor(0xc0002ca980, 0xc0002ca980, 0x2, 0xc00023b8a0)
	/data/apps/gopath/pkg/mod/github.com/yumaojun03/[email protected]/parser/processor/parse.go:47 +0x8ef
github.com/yumaojun03/dmidecode.(*Decoder).Processor(0xc000222280, 0xc00021d904, 0x4, 0xc00021d904, 0x4, 0x4)
	/data/apps/gopath/pkg/mod/github.com/yumaojun03/[email protected]/decoder.go:195 +0x115

permission denied

failed to open stream: open /sys/firmware/dmi/tables/smbios_entry_point: permission denied
这个该怎么解决,已经加过777的权限了

runtime error: invalid memory address or nil pointer

env:
Red Hat Enterprise Linux Server release 6.10 (Santiago)
Linux version 2.6.32-754.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC) ) #1 SMP Thu May 24 18:18:25 EDT 2018

error:
failed to open stream: no SMBIOS entry point found in memorypanic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x9c5449]

goroutine 1 [running]:
github.com/yumaojun03/dmidecode.(*Decoder).System(0x0, 0xc00000e018, 0xc000575d70, 0x1, 0x1, 0x3c)
C:/Users/ss/go/pkg/mod/github.com/yumaojun03/[email protected]/decoder.go:104 +0x29

Is it not supported by the system or for other reasons?

友善R1S开发板不行

ARM64,UBUNTU
failed to open stream: read /dev/mem: bad address

应该是dmi, err := dmidecode.New()就报错了

ls -l /dev/mem
crw-r----- 1 root kmem 1, 1 Feb 12 2016 /dev/mem

dmidecode 报

dmidecode 3.0

No SMBIOS nor DMI entry point found, sorry.

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.