Skip to content

Commit

Permalink
limit 'cpu.machine' to linux. make it fingerprint 'uname -m'
Browse files Browse the repository at this point in the history
  • Loading branch information
shantanugadgil committed Jun 1, 2022
1 parent 6461cca commit 23f2d3a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions client/fingerprint/arch.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package fingerprint

import (
"os/exec"
"runtime"
"strings"

log "github.com/hashicorp/go-hclog"
)
Expand All @@ -21,12 +23,16 @@ func NewArchFingerprint(logger log.Logger) Fingerprint {
func (f *ArchFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
resp.AddAttribute("cpu.arch", runtime.GOARCH)

if runtime.GOARCH == "amd64" {
resp.AddAttribute("cpu.arch_classic", "x86_64")
} else if runtime.GOARCH == "386" {
resp.AddAttribute("cpu.arch_classic", "i386")
} else if runtime.GOARCH == "arm64" {
resp.AddAttribute("cpu.arch_classic", "aarch64")
if runtime.GOOS == "linux" {
unameOutput, err := exec.Command("uname", "-m").Output()

if err != nil {
f.logger.Warn("error calling 'uname -m'")
resp.AddAttribute("cpu.machine", "undefined")
} else {
output := strings.TrimSpace(string(unameOutput))
resp.AddAttribute("cpu.machine", output)
}
}

resp.Detected = true
Expand Down

0 comments on commit 23f2d3a

Please sign in to comment.