當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Accumulator.Get方法代碼示例

本文整理匯總了Golang中github.com/influxdata/telegraf/testutil.Accumulator.Get方法的典型用法代碼示例。如果您正苦於以下問題:Golang Accumulator.Get方法的具體用法?Golang Accumulator.Get怎麽用?Golang Accumulator.Get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/influxdata/telegraf/testutil.Accumulator的用法示例。


在下文中一共展示了Accumulator.Get方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestMetricContainsServerAndDomainAndRecordTypeTags

func TestMetricContainsServerAndDomainAndRecordTypeTags(t *testing.T) {
	if testing.Short() {
		t.Skip("Skipping network-dependent test in short mode.")
	}
	var dnsConfig = DnsQuery{
		Servers: servers,
		Domains: domains,
	}
	var acc testutil.Accumulator
	tags := map[string]string{
		"server":      "8.8.8.8",
		"domain":      "google.com",
		"record_type": "NS",
	}
	fields := map[string]interface{}{}

	err := dnsConfig.Gather(&acc)
	assert.NoError(t, err)
	metric, ok := acc.Get("dns_query")
	require.True(t, ok)
	queryTime, _ := metric.Fields["query_time_ms"].(float64)

	fields["query_time_ms"] = queryTime
	acc.AssertContainsTaggedFields(t, "dns_query", fields, tags)
}
開發者ID:li-ang,項目名稱:telegraf,代碼行數:25,代碼來源:dns_query_test.go

示例2: TestGathering

func TestGathering(t *testing.T) {
	var dnsConfig = DnsQuery{
		Servers: servers,
		Domains: domains,
	}
	var acc testutil.Accumulator

	err := dnsConfig.Gather(&acc)
	assert.NoError(t, err)
	metric, ok := acc.Get("dns_query")
	require.True(t, ok)
	queryTime, _ := metric.Fields["query_time_ms"].(float64)

	assert.NotEqual(t, 0, queryTime)
}
開發者ID:cwegener,項目名稱:telegraf,代碼行數:15,代碼來源:dns_query_test.go

示例3: TestProcesses

func TestProcesses(t *testing.T) {
	processes := &Processes{
		execPS:       execPS,
		readProcFile: readProcFile,
	}
	var acc testutil.Accumulator

	err := processes.Gather(&acc)
	require.NoError(t, err)

	assert.True(t, acc.HasIntField("processes", "running"))
	assert.True(t, acc.HasIntField("processes", "sleeping"))
	assert.True(t, acc.HasIntField("processes", "stopped"))
	assert.True(t, acc.HasIntField("processes", "total"))
	total, ok := acc.Get("processes")
	require.True(t, ok)
	assert.True(t, total.Fields["total"].(int64) > 0)
}
開發者ID:cwegener,項目名稱:telegraf,代碼行數:18,代碼來源:processes_test.go

示例4: TestGatheringMxRecord

func TestGatheringMxRecord(t *testing.T) {
	if testing.Short() {
		t.Skip("Skipping network-dependent test in short mode.")
	}
	var dnsConfig = DnsQuery{
		Servers: servers,
		Domains: domains,
	}
	var acc testutil.Accumulator
	dnsConfig.RecordType = "MX"

	err := dnsConfig.Gather(&acc)
	assert.NoError(t, err)
	metric, ok := acc.Get("dns_query")
	require.True(t, ok)
	queryTime, _ := metric.Fields["query_time_ms"].(float64)

	assert.NotEqual(t, 0, queryTime)
}
開發者ID:li-ang,項目名稱:telegraf,代碼行數:19,代碼來源:dns_query_test.go

示例5: TestPostgresqlTagsMetricsWithDatabaseName

func TestPostgresqlTagsMetricsWithDatabaseName(t *testing.T) {
	if testing.Short() {
		t.Skip("Skipping integration test in short mode")
	}

	p := &Postgresql{
		Address: fmt.Sprintf("host=%s user=postgres sslmode=disable",
			testutil.GetLocalHost()),
		Databases: []string{"postgres"},
	}

	var acc testutil.Accumulator

	err := p.Gather(&acc)
	require.NoError(t, err)

	point, ok := acc.Get("postgresql")
	require.True(t, ok)

	assert.Equal(t, "postgres", point.Tags["db"])
}
開發者ID:zooplus,項目名稱:telegraf,代碼行數:21,代碼來源:postgresql_test.go

示例6: TestGatheringRootDomain

func TestGatheringRootDomain(t *testing.T) {
	var dnsConfig = DnsQuery{
		Servers:    servers,
		Domains:    []string{"."},
		RecordType: "MX",
	}
	var acc testutil.Accumulator
	tags := map[string]string{
		"server":      "8.8.8.8",
		"domain":      ".",
		"record_type": "MX",
	}
	fields := map[string]interface{}{}

	err := dnsConfig.Gather(&acc)
	assert.NoError(t, err)
	metric, ok := acc.Get("dns_query")
	require.True(t, ok)
	queryTime, _ := metric.Fields["query_time_ms"].(float64)

	fields["query_time_ms"] = queryTime
	acc.AssertContainsTaggedFields(t, "dns_query", fields, tags)
}
開發者ID:cwegener,項目名稱:telegraf,代碼行數:23,代碼來源:dns_query_test.go


注:本文中的github.com/influxdata/telegraf/testutil.Accumulator.Get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。