mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
Add CPU info in the check update user-agent (#16447)
This commit is contained in:
parent
31b0decd46
commit
f37a5b6dae
@ -41,6 +41,7 @@ import (
|
||||
"github.com/minio/pkg/env"
|
||||
xnet "github.com/minio/pkg/net"
|
||||
"github.com/minio/selfupdate"
|
||||
gopsutilcpu "github.com/shirou/gopsutil/v3/cpu"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -277,6 +278,18 @@ func getUserAgent(mode string) string {
|
||||
}
|
||||
}
|
||||
|
||||
if cpus, err := gopsutilcpu.Info(); err == nil && len(cpus) > 0 {
|
||||
cpuMap := make(map[string]struct{}, len(cpus))
|
||||
coreMap := make(map[string]struct{}, len(cpus))
|
||||
for i := range cpus {
|
||||
cpuMap[cpus[i].PhysicalID] = struct{}{}
|
||||
coreMap[cpus[i].CoreID] = struct{}{}
|
||||
}
|
||||
cpu := cpus[0]
|
||||
uaAppend(" CPU ", fmt.Sprintf("(total_cpus:%d, total_cores:%d; vendor:%s; family:%s; model:%s; stepping:%d; model_name:%s)",
|
||||
len(cpuMap), len(coreMap), cpu.VendorID, cpu.Family, cpu.Model, cpu.Stepping, cpu.ModelName))
|
||||
}
|
||||
|
||||
return strings.Join(userAgentParts, "")
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ func TestUserAgent(t *testing.T) {
|
||||
if IsDocker() {
|
||||
expectedStr = strings.ReplaceAll(expectedStr, "; source", "; docker; source")
|
||||
}
|
||||
if str != expectedStr {
|
||||
if !strings.Contains(str, expectedStr) {
|
||||
t.Errorf("Test %d: expected: %s, got: %s", i+1, expectedStr, str)
|
||||
}
|
||||
globalIsCICD = sci
|
||||
|
Loading…
Reference in New Issue
Block a user