yumaojun03 / dmidecode Goto Github PK
View Code? Open in Web Editor NEW纯Golang实现的dmidecode, 零依赖, 支持Linux, Unix, Windows
License: MIT License
纯Golang实现的dmidecode, 零依赖, 支持Linux, Unix, Windows
License: MIT License
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]
dmi, _ := dmidecode.New()
infos, _ :=dmi.System()
infos为什么不返回一个对象,而返回一个数组呢?
想读取UUID或其他特定一个值的时候很不方便
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?
}
failed to open stream: open /sys/firmware/dmi/tables/smbios_entry_point: permission denied
这个该怎么解决,已经加过777的权限了
我的命令行输出:
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
dmi.OEM undefined (type *dmidecode.Decoder has no field or method OEM)
大佬帮看看。
命令:dmidecode -t 4
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
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])
}
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 报
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?
Line 73 in 3e5ab70
调用库的时候,老是输出版本信息,可以默认去掉吗?
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.