From 6990a314f52c59139d1b33075365175bd5961516 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 22 Aug 2021 21:15:30 -0700 Subject: [PATCH] hostinfo: set DeviceModel from Linux devicetree model Signed-off-by: Brad Fitzpatrick --- hostinfo/hostinfo_linux.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hostinfo/hostinfo_linux.go b/hostinfo/hostinfo_linux.go index 45b368780..cb8ee2aed 100644 --- a/hostinfo/hostinfo_linux.go +++ b/hostinfo/hostinfo_linux.go @@ -11,6 +11,7 @@ import ( "bytes" "fmt" "io/ioutil" + "os" "strings" "syscall" @@ -20,6 +21,12 @@ import ( func init() { osVersion = osVersionLinux + + if v, _ := os.ReadFile("/sys/firmware/devicetree/base/model"); len(v) > 0 { + // Look up "Raspberry Pi 4 Model B Rev 1.2", + // etc. Usually set on ARM SBCs. + SetDeviceModel(strings.Trim(string(v), "\x00\r\n\t ")) + } } func osVersionLinux() string {