hypervisor discovery

This commit is contained in:
Pete Fraedrich
2020-04-24 12:24:17 -04:00
parent 215c660eec
commit f184eb78af
3 changed files with 42 additions and 0 deletions
+2
View File
@@ -1,3 +1,5 @@
module github.com/yeticloud/libdetectcloud
go 1.14
require github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e
+2
View File
@@ -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=
+38
View File
@@ -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)
}
}