diff --git a/hostinfo/info.go b/hostinfo/info.go index e25b5a5..e6a2302 100644 --- a/hostinfo/info.go +++ b/hostinfo/info.go @@ -8,6 +8,7 @@ import ( type HostInfo struct { CpuCount uint HostId string + HostName string ExternalOrganization string SocketCount string Product []string @@ -58,6 +59,7 @@ func (hi *HostInfo) String() string { []string{ "HostInfo:", fmt.Sprintf("| CpuCount: %d", hi.CpuCount), + fmt.Sprintf("| HostName: %s", hi.HostName), fmt.Sprintf("| HostId: %s", hi.HostId), fmt.Sprintf("| ExternalOrganization: %s", hi.ExternalOrganization), fmt.Sprintf("| SocketCount: %s", hi.SocketCount), diff --git a/hostinfo/info_test.go b/hostinfo/info_test.go index 158b165..233df27 100644 --- a/hostinfo/info_test.go +++ b/hostinfo/info_test.go @@ -22,6 +22,7 @@ func TestHostInfo(t *testing.T) { // Define the expected defaults. expectedString := "HostInfo:\n" + "| CpuCount: 64\n" + + "| HostName: host.mock.test\n" + "| HostId: 01234567-89ab-cdef-0123-456789abcdef\n" + "| ExternalOrganization: 12345678\n" + "| SocketCount: 3\n" + diff --git a/hostinfo/subscription.go b/hostinfo/subscription.go index 3e477bf..0fa9c4c 100644 --- a/hostinfo/subscription.go +++ b/hostinfo/subscription.go @@ -13,6 +13,7 @@ import ( func LoadSubManInformation(hi *HostInfo) { identity := GetSubManIdentity() hi.HostId, _ = GetHostId(identity) + hi.HostName, _ = GetHostName(identity) hi.ExternalOrganization, _ = GetExternalOrganization(identity) hi.Usage, _ = GetUsage() @@ -34,6 +35,10 @@ func GetHostId(identity SubManValues) (string, error) { return identity.get("system identity") } +func GetHostName(identity SubManValues) (string, error) { + return identity.get("name") +} + func GetExternalOrganization(identity SubManValues) (string, error) { return identity.get("org ID") } diff --git a/hostinfo/subscription_test.go b/hostinfo/subscription_test.go index 7e11a25..a2499b4 100644 --- a/hostinfo/subscription_test.go +++ b/hostinfo/subscription_test.go @@ -9,6 +9,7 @@ func TestLoadSubManInformation(t *testing.T) { // Define the expected general host info. expected := &HostInfo{ HostId: "01234567-89ab-cdef-0123-456789abcdef", + HostName: "host.mock.test", ExternalOrganization: "12345678", SocketCount: "3", Product: []string{"394", "69"}, diff --git a/mocks/subscription-manager b/mocks/subscription-manager index 3b6eb0e..4046f82 100755 --- a/mocks/subscription-manager +++ b/mocks/subscription-manager @@ -4,7 +4,7 @@ IDENTITY=\ "system identity: 01234567-89ab-cdef-0123-456789abcdef -name: hostname +name: host.mock.test org name: 12345678 org ID: 12345678" diff --git a/notify/prometheus.go b/notify/prometheus.go index 3f1b6b1..d976824 100644 --- a/notify/prometheus.go +++ b/notify/prometheus.go @@ -183,6 +183,10 @@ func hostInfo2WriteRequest(hostinfo *hostinfo.HostInfo, samples []prompb.Sample) Name: "conversions_success", Value: hostinfo.ConversionsSuccess, }, + { + Name: "display_name", + Value: hostinfo.HostName, + }, { Name: "external_organization", Value: hostinfo.ExternalOrganization, diff --git a/notify/prometheus_test.go b/notify/prometheus_test.go index 306da13..4d830f8 100644 --- a/notify/prometheus_test.go +++ b/notify/prometheus_test.go @@ -293,6 +293,7 @@ func TestLabels(t *testing.T) { "billing_marketplace_instance_id", "billing_model", "conversions_success", + "display_name", "external_organization", "product", "socket_count", @@ -490,6 +491,7 @@ func createHostInfo() *hostinfo.HostInfo { return &hostinfo.HostInfo{ CpuCount: 1, HostId: "test", + HostName: testHostname, SocketCount: "1", Product: []string{"123", "456"}, Support: "test support",