Skip to content

Commit

Permalink
fix: Add -i flag to ignore not known sysctl properties on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
zaremba-tomasz committed Aug 25, 2022
1 parent 5e40f04 commit 06a956e
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ import (
)

const (
sysctlCmd = "sysctl"
cpuModelNameKey = "machdep.cpu.brand_string"
cpuCoreKey = "hw.physicalcpu"
cpusKey = "hw.logicalcpu"
cpuFreqKey = "hw.cpufrequency"
threadTypeKey = "hw.cputhreadtype"
kernelVersionKey = "kern.osrelease"
sysctlCmd = "sysctl"
sysctlCmdIgnoreUnknownFlag = "-i"
cpuModelNameKey = "machdep.cpu.brand_string"
cpuCoreKey = "hw.physicalcpu"
cpusKey = "hw.logicalcpu"
cpuFreqKey = "hw.cpufrequency"
threadTypeKey = "hw.cputhreadtype"
kernelVersionKey = "kern.osrelease"
)

// cmdExecutor decouples exec.Command for easy testability
Expand All @@ -50,7 +51,7 @@ func collectPlatformDependentInstanceData(context context.T) (appData []model.In
var output []byte
var err error
cmd := sysctlCmd
args := []string{cpuModelNameKey, cpuCoreKey, cpusKey, cpuFreqKey, threadTypeKey}
args := []string{sysctlCmdIgnoreUnknownFlag, cpuModelNameKey, cpuCoreKey, cpusKey, cpuFreqKey, threadTypeKey}

log.Infof("Executing command: %v", cmd)
if output, err = cmdExecutor(cmd, args...); err != nil {
Expand Down

0 comments on commit 06a956e

Please sign in to comment.