Extend the system informations

This commit is contained in:
Zoltán Papp
2024-01-17 09:03:41 +01:00
parent 9fa0fbda0d
commit ef4a2ccbca
9 changed files with 286 additions and 12 deletions

View File

@@ -13,6 +13,7 @@ import (
"time"
log "github.com/sirupsen/logrus"
"github.com/zcalusic/sysinfo"
"github.com/netbirdio/netbird/version"
)
@@ -26,7 +27,7 @@ func GetInfo(ctx context.Context) *Info {
}
releaseInfo := _getReleaseInfo()
for strings.Contains(info, "broken pipe") {
for strings.Contains(releaseInfo, "broken pipe") {
releaseInfo = _getReleaseInfo()
time.Sleep(500 * time.Millisecond)
}
@@ -50,15 +51,51 @@ func GetInfo(ctx context.Context) *Info {
if osName == "" {
osName = osInfo[3]
}
gio := &Info{Kernel: osInfo[0], Core: osInfo[1], Platform: osInfo[2], OS: osName, OSVersion: osVer, GoOS: runtime.GOOS, CPUs: runtime.NumCPU()}
systemHostname, _ := os.Hostname()
gio.Hostname = extractDeviceName(ctx, systemHostname)
gio.WiretrusteeVersion = version.NetbirdVersion()
gio.UIVersion = extractUserAgent(ctx)
sysinfo := extendedInfo()
localAddr, macAddr := localAddresses()
gio := &Info{
Kernel: osInfo[0],
Core: osInfo[1],
Platform: osInfo[2],
OS: osName,
OSVersion: osVer,
GoOS: runtime.GOOS,
CPUs: runtime.NumCPU(),
Hostname: extractDeviceName(ctx, systemHostname),
WiretrusteeVersion: version.NetbirdVersion(),
UIVersion: extractUserAgent(ctx),
BiosManufacturer: sysinfo.BIOS.Vendor,
BiosVersion: sysinfo.BIOS.Version,
ChassisType: sysinfo.Chassis.Type,
ChassisTypeDesc: chassisTypeDesc(sysinfo.Chassis.Type), // make no sense to send the string to the server
/*
ConnectionIp: "", // "10.145.236.123",
ConnectionMacAddress: "", // 52-54-00-1a-31-05"
CPUSignature: "", // "198339"
*/
LastReboot: lastReboot(),
LocalIp: localAddr,
MacAddress: macAddr,
/*
OSBuild: string // 22621
OSProductName: string // "Windows 11 Home"
ProductTypeDesc: string // "Workstation"
SerialNumber: string // "MP1PKC2C""
SystemProductName: string // "81ND", # how to get this?
*/
SystemManufacturer: sysinfo.Product.Vendor, // todo validate
}
return gio
}
func extendedInfo() sysinfo.SysInfo {
var si sysinfo.SysInfo
si.GetSysInfo()
return si
}
func _getInfo() string {
cmd := exec.Command("uname", "-srio")
cmd.Stdin = strings.NewReader("some")