mirror of
https://github.com/netbirdio/libdetectcloud.git
synced 2026-05-22 17:09:55 -07:00
hypervisor discovery
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
module github.com/yeticloud/libdetectcloud
|
||||
|
||||
go 1.14
|
||||
|
||||
require github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e h1:vUmf0yezR0y7jJ5pceLHthLaYf4bA5T14B6q39S4q2Q=
|
||||
github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e/go.mod h1:YTIHhz/QFSYnu/EhlF2SpU2Uk+32abacUYA5ZPljz1A=
|
||||
@@ -0,0 +1,38 @@
|
||||
package libdetectcloud
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/digitalocean/go-smbios/smbios"
|
||||
)
|
||||
|
||||
// BIOS type
|
||||
type BIOS struct {
|
||||
Manufacturer string
|
||||
ProductName string
|
||||
SerialNumber string
|
||||
IsVM bool
|
||||
Hypervisor string
|
||||
}
|
||||
|
||||
//BIOSInfo function gets information from the SMBIOS
|
||||
func BIOSInfo() {
|
||||
rc, _, 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)
|
||||
}
|
||||
for _, s := range ss {
|
||||
fmt.Println(s)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user