当前位置: 首页>>代码示例>>Golang>>正文


Golang Accumulator.HasIntValue方法代码示例

本文整理汇总了Golang中github.com/toorop/telegraf/testutil.Accumulator.HasIntValue方法的典型用法代码示例。如果您正苦于以下问题:Golang Accumulator.HasIntValue方法的具体用法?Golang Accumulator.HasIntValue怎么用?Golang Accumulator.HasIntValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/toorop/telegraf/testutil.Accumulator的用法示例。


在下文中一共展示了Accumulator.HasIntValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestAddTableStats

func TestAddTableStats(t *testing.T) {
	var acc testutil.Accumulator

	err := server.addTableStats(&acc)
	require.NoError(t, err)

	for _, metric := range TableTracking {
		assert.True(t, acc.HasIntValue(metric))
	}

	keys := []string{
		"cache_bytes_in_use",
		"disk_read_bytes_per_sec",
		"disk_read_bytes_total",
		"disk_written_bytes_per_sec",
		"disk_written_bytes_total",
		"disk_usage_data_bytes",
		"disk_usage_garbage_bytes",
		"disk_usage_metadata_bytes",
		"disk_usage_preallocated_bytes",
	}

	for _, metric := range keys {
		assert.True(t, acc.HasIntValue(metric))
	}
}
开发者ID:toorop,项目名称:telegraf,代码行数:26,代码来源:rethinkdb_server_test.go

示例2: TestAddEngineStatsPartial

func TestAddEngineStatsPartial(t *testing.T) {
	engine := &Engine{
		ClientConns:   0,
		ClientActive:  0,
		QueriesPerSec: 0,
		ReadsPerSec:   0,
		WritesPerSec:  0,
	}

	var acc testutil.Accumulator

	keys := []string{
		"active_clients",
		"clients",
		"queries_per_sec",
		"read_docs_per_sec",
		"written_docs_per_sec",
	}

	missing_keys := []string{
		"total_queries",
		"total_reads",
		"total_writes",
	}
	engine.AddEngineStats(keys, &acc, tags)

	for _, metric := range missing_keys {
		assert.False(t, acc.HasIntValue(metric))
	}
}
开发者ID:toorop,项目名称:telegraf,代码行数:30,代码来源:rethinkdb_data_test.go

示例3: TestAddMemberStats

func TestAddMemberStats(t *testing.T) {
	var acc testutil.Accumulator

	err := server.addMemberStats(&acc)
	require.NoError(t, err)

	for _, metric := range MemberTracking {
		assert.True(t, acc.HasIntValue(metric))
	}
}
开发者ID:toorop,项目名称:telegraf,代码行数:10,代码来源:rethinkdb_server_test.go

示例4: TestMysqlGeneratesMetrics

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

	m := &Mysql{
		Servers: []string{fmt.Sprintf("[email protected](%s:3306)/", testutil.GetLocalHost())},
	}

	var acc testutil.Accumulator

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

	prefixes := []struct {
		prefix string
		count  int
	}{
		{"commands", 141},
		{"handler", 18},
		{"bytes", 2},
		{"innodb", 51},
		{"threads", 4},
		{"aborted", 2},
		{"created", 3},
		{"key", 7},
		{"open", 7},
		{"opened", 3},
		{"qcache", 8},
		{"table", 5},
	}

	intMetrics := []string{
		"queries",
		"slow_queries",
	}

	for _, prefix := range prefixes {
		var count int

		for _, p := range acc.Points {
			if strings.HasPrefix(p.Measurement, prefix.prefix) {
				count++
			}
		}

		assert.Equal(t, prefix.count, count)
	}

	for _, metric := range intMetrics {
		assert.True(t, acc.HasIntValue(metric))
	}
}
开发者ID:toorop,项目名称:telegraf,代码行数:53,代码来源:mysql_test.go

示例5: TestPostgresqlGeneratesMetrics

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

	p := &Postgresql{
		Servers: []*Server{
			{
				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)

	intMetrics := []string{
		"xact_commit",
		"xact_rollback",
		"blks_read",
		"blks_hit",
		"tup_returned",
		"tup_fetched",
		"tup_inserted",
		"tup_updated",
		"tup_deleted",
		"conflicts",
		"temp_files",
		"temp_bytes",
		"deadlocks",
	}

	floatMetrics := []string{
		"blk_read_time",
		"blk_write_time",
	}

	for _, metric := range intMetrics {
		assert.True(t, acc.HasIntValue(metric))
	}

	for _, metric := range floatMetrics {
		assert.True(t, acc.HasFloatValue(metric))
	}
}
开发者ID:toorop,项目名称:telegraf,代码行数:49,代码来源:postgresql_test.go

示例6: TestMemcachedGeneratesMetrics

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

	m := &Memcached{
		Servers: []string{testutil.GetLocalHost()},
	}

	var acc testutil.Accumulator

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

	intMetrics := []string{"get_hits", "get_misses", "evictions", "limit_maxbytes", "bytes"}

	for _, metric := range intMetrics {
		assert.True(t, acc.HasIntValue(metric), metric)
	}
}
开发者ID:toorop,项目名称:telegraf,代码行数:20,代码来源:memcached_test.go

示例7: TestAddStorageStats

func TestAddStorageStats(t *testing.T) {
	storage := &Storage{
		Cache: Cache{
			BytesInUse: 0,
		},
		Disk: Disk{
			ReadBytesPerSec:  0,
			ReadBytesTotal:   0,
			WriteBytesPerSec: 0,
			WriteBytesTotal:  0,
			SpaceUsage: SpaceUsage{
				Data:     0,
				Garbage:  0,
				Metadata: 0,
				Prealloc: 0,
			},
		},
	}

	var acc testutil.Accumulator

	keys := []string{
		"cache_bytes_in_use",
		"disk_read_bytes_per_sec",
		"disk_read_bytes_total",
		"disk_written_bytes_per_sec",
		"disk_written_bytes_total",
		"disk_usage_data_bytes",
		"disk_usage_garbage_bytes",
		"disk_usage_metadata_bytes",
		"disk_usage_preallocated_bytes",
	}

	storage.AddStats(&acc, tags)

	for _, metric := range keys {
		assert.True(t, acc.HasIntValue(metric))
	}
}
开发者ID:toorop,项目名称:telegraf,代码行数:39,代码来源:rethinkdb_data_test.go

示例8: TestRabbitMQGeneratesMetrics

func TestRabbitMQGeneratesMetrics(t *testing.T) {
	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		var rsp string

		if r.URL.Path == "/api/overview" {
			rsp = sampleOverviewResponse
		} else if r.URL.Path == "/api/nodes" {
			rsp = sampleNodesResponse
		} else {
			panic("Cannot handle request")
		}

		fmt.Fprintln(w, rsp)
	}))
	defer ts.Close()

	r := &RabbitMQ{
		Servers: []*Server{
			{
				URL: ts.URL,
			},
		},
	}

	var acc testutil.Accumulator

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

	intMetrics := []string{
		"messages",
		"messages_ready",
		"messages_unacked",

		"messages_acked",
		"messages_delivered",
		"messages_published",

		"channels",
		"connections",
		"consumers",
		"exchanges",
		"queues",
	}

	for _, metric := range intMetrics {
		assert.True(t, acc.HasIntValue(metric))
	}

	nodeIntMetrics := []string{
		"disk_free",
		"disk_free_limit",
		"fd_total",
		"fd_used",
		"mem_limit",
		"mem_used",
		"proc_total",
		"proc_used",
		"run_queue",
		"sockets_total",
		"sockets_used",
	}

	for _, metric := range nodeIntMetrics {
		assert.True(t, acc.HasIntValue(metric))
	}
}
开发者ID:toorop,项目名称:telegraf,代码行数:67,代码来源:rabbitmq_test.go


注:本文中的github.com/toorop/telegraf/testutil.Accumulator.HasIntValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。