From 12ebb4d1ab86acf0830b98aa3070c2e534ea34f2 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Thu, 27 Aug 2015 17:37:37 -0700 Subject: [PATCH] Change 'os' to 'kernel.name'; add 'kernel.version' for *nix* --- client/fingerprint/host.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/client/fingerprint/host.go b/client/fingerprint/host.go index 9acad1d54..5cbfee755 100644 --- a/client/fingerprint/host.go +++ b/client/fingerprint/host.go @@ -1,7 +1,10 @@ package fingerprint import ( + "fmt" "log" + "os/exec" + "runtime" "github.com/hashicorp/nomad/client/config" "github.com/hashicorp/nomad/nomad/structs" @@ -28,8 +31,19 @@ func (f *HostFingerprint) Fingerprint(cfg *config.Config, node *structs.Node) (b node.Attributes["os.name"] = hostInfo.Platform node.Attributes["os.version"] = hostInfo.PlatformVersion + + node.Attributes["kernel.name"] = runtime.GOOS + node.Attributes["kernel.version"] = "" + + if runtime.GOOS != "windows" { + out, err := exec.Command("uname", "-r").Output() + if err != nil { + return false, fmt.Errorf("Failed to run uname: %s", err) + } + node.Attributes["kernel.version"] = string(out) + } + node.Attributes["hostname"] = hostInfo.Hostname - node.Attributes["kernel.name"] = hostInfo.OS return true, nil }