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


Golang Accumulator.HasIntField方法代碼示例

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


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

示例1: TestAddNonReplStats

func TestAddNonReplStats(t *testing.T) {
    d := NewMongodbData(
        &StatLine{
            StorageEngine:  "",
            Time:           time.Now(),
            Insert:         0,
            Query:          0,
            Update:         0,
            Delete:         0,
            GetMore:        0,
            Command:        0,
            Flushes:        0,
            Virtual:        0,
            Resident:       0,
            QueuedReaders:  0,
            QueuedWriters:  0,
            ActiveReaders:  0,
            ActiveWriters:  0,
            NetIn:          0,
            NetOut:         0,
            NumConnections: 0,
        },
        tags,
    )
    var acc testutil.Accumulator

    d.AddDefaultStats()
    d.flush(&acc)

    for key, _ := range DefaultStats {
        assert.True(t, acc.HasIntField("mongodb", key))
    }
}
開發者ID:ronaldslc,項目名稱:telegraf,代碼行數:33,代碼來源:mongodb_data_test.go

示例2: 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", "uptime", "curr_items", "total_items",
        "curr_connections", "total_connections", "connection_structures", "cmd_get",
        "cmd_set", "delete_hits", "delete_misses", "incr_hits", "incr_misses",
        "decr_hits", "decr_misses", "cas_hits", "cas_misses", "evictions",
        "bytes_read", "bytes_written", "threads", "conn_yields"}

    for _, metric := range intMetrics {
        assert.True(t, acc.HasIntField("memcached", metric), metric)
    }
}
開發者ID:ronaldslc,項目名稱:telegraf,代碼行數:25,代碼來源:memcached_test.go

示例3: TestZookeeperGeneratesMetrics

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

    z := &Zookeeper{
        Servers: []string{testutil.GetLocalHost() + ":2181"},
    }

    var acc testutil.Accumulator

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

    intMetrics := []string{
        "avg_latency",
        "max_latency",
        "min_latency",
        "packets_received",
        "packets_sent",
        "outstanding_requests",
        "znode_count",
        "watch_count",
        "ephemerals_count",
        "approximate_data_size",
        "open_file_descriptor_count",
        "max_file_descriptor_count",
    }

    for _, metric := range intMetrics {
        assert.True(t, acc.HasIntField("zookeeper", metric), metric)
    }
}
開發者ID:ronaldslc,項目名稱:telegraf,代碼行數:33,代碼來源:zookeeper_test.go

示例4: 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.HasIntField("rethinkdb", metric))
    }
}
開發者ID:ronaldslc,項目名稱:telegraf,代碼行數:30,代碼來源:rethinkdb_data_test.go

示例5: TestAerospikeStatistics

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

    a := &Aerospike{
        Servers: []string{testutil.GetLocalHost() + ":3000"},
    }

    var acc testutil.Accumulator

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

    // Only use a few of the metrics
    asMetrics := []string{
        "transactions",
        "stat_write_errs",
        "stat_read_reqs",
        "stat_write_reqs",
    }

    for _, metric := range asMetrics {
        assert.True(t, acc.HasIntField("aerospike", metric), metric)
    }

}
開發者ID:ronaldslc,項目名稱:telegraf,代碼行數:27,代碼來源:aerospike_test.go

示例6: TestAddReplStats

func TestAddReplStats(t *testing.T) {
    d := NewMongodbData(
        &StatLine{
            StorageEngine: "mmapv1",
            Mapped:        0,
            NonMapped:     0,
            Faults:        0,
        },
        tags,
    )

    var acc testutil.Accumulator

    d.AddDefaultStats()
    d.flush(&acc)

    for key, _ := range MmapStats {
        assert.True(t, acc.HasIntField("mongodb", key))
    }
}
開發者ID:ronaldslc,項目名稱:telegraf,代碼行數:20,代碼來源:mongodb_data_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.HasIntField("rethinkdb", metric))
    }
}
開發者ID:ronaldslc,項目名稱: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

        switch r.URL.Path {
        case "/api/overview":
            rsp = sampleOverviewResponse
        case "/api/nodes":
            rsp = sampleNodesResponse
        case "/api/queues":
            rsp = sampleQueuesResponse
        default:
            panic("Cannot handle request")
        }

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

    r := &RabbitMQ{
        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.HasIntField("rabbitmq_overview", 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.HasIntField("rabbitmq_node", metric))
    }

    assert.True(t, acc.HasMeasurement("rabbitmq_queue"))
}
開發者ID:ronaldslc,項目名稱:telegraf,代碼行數:68,代碼來源:rabbitmq_test.go

示例9: TestPostgresqlGeneratesMetrics

func TestPostgresqlGeneratesMetrics(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)

    availableColumns := make(map[string]bool)
    for _, col := range p.OrderedColumns {
        availableColumns[col] = true
    }

    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",
        "numbackends",
    }

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

    metricsCounted := 0

    for _, metric := range intMetrics {
        _, ok := availableColumns[metric]
        if ok {
            assert.True(t, acc.HasIntField("postgresql", metric))
            metricsCounted++
        }
    }

    for _, metric := range floatMetrics {
        _, ok := availableColumns[metric]
        if ok {
            assert.True(t, acc.HasFloatField("postgresql", metric))
            metricsCounted++
        }
    }

    assert.True(t, metricsCounted > 0)
    assert.Equal(t, len(availableColumns)-len(p.IgnoredColumns()), metricsCounted)
}
開發者ID:ronaldslc,項目名稱:telegraf,代碼行數:64,代碼來源:postgresql_test.go


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