本文整理汇总了Golang中github.com/influxdb/telegraf/testutil.Accumulator.ValidateTaggedValue方法的典型用法代码示例。如果您正苦于以下问题:Golang Accumulator.ValidateTaggedValue方法的具体用法?Golang Accumulator.ValidateTaggedValue怎么用?Golang Accumulator.ValidateTaggedValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/influxdb/telegraf/testutil.Accumulator
的用法示例。
在下文中一共展示了Accumulator.ValidateTaggedValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestHaproxyGeneratesMetricsWithoutAuthentication
func TestHaproxyGeneratesMetricsWithoutAuthentication(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, csvOutputSample)
}))
defer ts.Close()
r := &haproxy{
Servers: []string{ts.URL},
}
var acc testutil.Accumulator
err := r.Gather(&acc)
require.NoError(t, err)
tags := map[string]string{
"proxy": "be_app",
"server": ts.Listener.Addr().String(),
"sv": "host0",
}
assert.NoError(t, acc.ValidateTaggedValue("stot", uint64(171014), tags))
assert.NoError(t, acc.ValidateTaggedValue("scur", uint64(1), tags))
assert.NoError(t, acc.ValidateTaggedValue("rate", uint64(3), tags))
assert.Equal(t, true, acc.CheckValue("bin", uint64(5557055817)))
}
示例2: TestHttpJson200
// Test that the proper values are ignored or collected
func TestHttpJson200(t *testing.T) {
httpjson := genMockHttpJson(validJSON, 200)
var acc testutil.Accumulator
err := httpjson.Gather(&acc)
require.NoError(t, err)
assert.Equal(t, 8, len(acc.Points))
for _, service := range httpjson.Services {
for _, srv := range service.Servers {
require.NoError(t,
acc.ValidateTaggedValue(
fmt.Sprintf("%s_parent_child", service.Name),
3.0,
map[string]string{"server": srv},
),
)
require.NoError(t,
acc.ValidateTaggedValue(
fmt.Sprintf("%s_integer", service.Name),
4.0,
map[string]string{"server": srv},
),
)
}
}
}
示例3: TestStateTag
func TestStateTag(t *testing.T) {
d := NewMongodbData(
&StatLine{
StorageEngine: "",
Time: time.Now(),
Insert: 0,
Query: 0,
NodeType: "PRI",
},
tags,
)
stats := []string{"inserts_per_sec", "queries_per_sec"}
stateTags := make(map[string]string)
stateTags["state"] = "PRI"
var acc testutil.Accumulator
d.AddDefaultStats(&acc)
for _, key := range stats {
err := acc.ValidateTaggedValue(key, int64(0), stateTags)
require.NoError(t, err)
}
}
示例4: TestNginxGeneratesMetrics
func TestNginxGeneratesMetrics(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var rsp string
if r.URL.Path == "/stub_status" {
rsp = sampleResponse
} else {
panic("Cannot handle request")
}
fmt.Fprintln(w, rsp)
}))
defer ts.Close()
n := &Nginx{
Urls: []string{fmt.Sprintf("%s/stub_status", ts.URL)},
}
var acc testutil.Accumulator
err := n.Gather(&acc)
require.NoError(t, err)
metrics := []struct {
name string
value uint64
}{
{"active", 585},
{"accepts", 85340},
{"handled", 85340},
{"requests", 35085},
{"reading", 4},
{"writing", 135},
{"waiting", 446},
}
addr, err := url.Parse(ts.URL)
if err != nil {
panic(err)
}
host, port, err := net.SplitHostPort(addr.Host)
if err != nil {
host = addr.Host
if addr.Scheme == "http" {
port = "80"
} else if addr.Scheme == "https" {
port = "443"
} else {
port = ""
}
}
tags := map[string]string{"server": host, "port": port}
for _, m := range metrics {
assert.NoError(t, acc.ValidateTaggedValue(m.name, m.value, tags))
}
}
示例5: TestReadAerospikeStatsNamespace
func TestReadAerospikeStatsNamespace(t *testing.T) {
var acc testutil.Accumulator
stats := map[string]string{
"stat_write_errs": "12345",
"stat_read_reqs": "12345",
}
readAerospikeStats(stats, &acc, "host1", "test")
tags := map[string]string{
"host": "host1",
"namespace": "test",
}
for k := range stats {
assert.True(t, acc.ValidateTaggedValue(k, int64(12345), tags) == nil)
}
}
示例6: TestPhpFpmGeneratesMetrics
func TestPhpFpmGeneratesMetrics(t *testing.T) {
//We create a fake server to return test data
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, outputSample)
}))
defer ts.Close()
//Now we tested again above server, with our authentication data
r := &phpfpm{
Urls: []string{ts.URL},
}
var acc testutil.Accumulator
err := r.Gather(&acc)
require.NoError(t, err)
tags := map[string]string{
"url": ts.Listener.Addr().String(),
"pool": "www",
}
assert.NoError(t, acc.ValidateTaggedValue("accepted_conn", int64(3), tags))
checkInt := []struct {
name string
value int64
}{
{"accepted_conn", 3},
{"listen_queue", 1},
{"max_listen_queue", 0},
{"listen_queue_len", 0},
{"idle_processes", 1},
{"active_processes", 1},
{"total_processes", 2},
{"max_active_processes", 1},
{"max_children_reached", 2},
{"slow_requests", 1},
}
for _, c := range checkInt {
assert.Equal(t, true, acc.CheckValue(c.name, c.value))
}
}
示例7: TestBadPingGather
// Test that Gather works on a ping with no transmitted packets, even though the
// command returns an error
func TestBadPingGather(t *testing.T) {
var acc testutil.Accumulator
p := Ping{
Urls: []string{"www.amazon.com"},
pingHost: mockErrorHostPinger,
}
p.Gather(&acc)
tags := map[string]string{"url": "www.amazon.com"}
assert.NoError(t, acc.ValidateTaggedValue("packets_transmitted", 2, tags))
assert.NoError(t, acc.ValidateTaggedValue("packets_received", 0, tags))
assert.NoError(t, acc.ValidateTaggedValue("percent_packet_loss", 100.0, tags))
assert.NoError(t, acc.ValidateTaggedValue("average_response_ms", 0.0, tags))
}
示例8: TestLossyPingGather
// Test that Gather works on a ping with lossy packets
func TestLossyPingGather(t *testing.T) {
var acc testutil.Accumulator
p := Ping{
Urls: []string{"www.google.com"},
pingHost: mockLossyHostPinger,
}
p.Gather(&acc)
tags := map[string]string{"url": "www.google.com"}
assert.NoError(t, acc.ValidateTaggedValue("packets_transmitted", 5, tags))
assert.NoError(t, acc.ValidateTaggedValue("packets_received", 3, tags))
assert.NoError(t, acc.ValidateTaggedValue("percent_packet_loss", 40.0, tags))
assert.NoError(t, acc.ValidateTaggedValue("average_response_ms", 44.033, tags))
}
示例9: TestHttpJson200Tags
// Test that the proper values are ignored or collected
func TestHttpJson200Tags(t *testing.T) {
httpjson := genMockHttpJson(validJSONTags, 200)
var acc testutil.Accumulator
err := httpjson.Gather(&acc)
require.NoError(t, err)
assert.Equal(t, 4, len(acc.Points))
for _, service := range httpjson.Services {
if service.Name == "other_webapp" {
for _, srv := range service.Servers {
require.NoError(t,
acc.ValidateTaggedValue(
fmt.Sprintf("%s_value", service.Name),
15.0,
map[string]string{"server": srv, "role": "master", "build": "123"},
),
)
}
}
}
}
示例10: TestElasticsearch
func TestElasticsearch(t *testing.T) {
es := NewElasticsearch()
es.Servers = []string{"http://example.com:9200"}
es.client.Transport = newTransportMock(http.StatusOK, statsResponse)
var acc testutil.Accumulator
if err := es.Gather(&acc); err != nil {
t.Fatal(err)
}
tags := map[string]string{
"cluster_name": "es-testcluster",
"node_attribute_master": "true",
"node_id": "SDFsfSDFsdfFSDSDfSFDSDF",
"node_name": "test.host.com",
"node_host": "test",
}
testTables := []map[string]float64{
indicesExpected,
osExpected,
processExpected,
jvmExpected,
threadPoolExpected,
networkExpected,
fsExpected,
transportExpected,
httpExpected,
breakersExpected,
}
for _, testTable := range testTables {
for k, v := range testTable {
assert.NoError(t, acc.ValidateTaggedValue(k, v, tags))
}
}
}
示例11: TestGather
func TestGather(t *testing.T) {
mockServer, err := mockTwemproxyServer()
if err != nil {
panic(err)
}
defer mockServer.Close()
twemproxy := &Twemproxy{
Instances: []TwemproxyInstance{
TwemproxyInstance{
Addr: sampleAddr,
Pools: []string{"demo"},
},
},
}
var acc testutil.Accumulator
err = twemproxy.Instances[0].Gather(&acc)
require.NoError(t, err)
var sourceData map[string]interface{}
if err := json.Unmarshal([]byte(sampleStats), &sourceData); err != nil {
panic(err)
}
metrics := []string{"total_connections", "curr_connections", "timestamp"}
tags := map[string]string{
"twemproxy": sampleAddr,
"source": sourceData["source"].(string),
}
for _, m := range metrics {
assert.NoError(t, acc.ValidateTaggedValue(m, sourceData[m].(float64), tags))
}
poolName := "demo"
poolMetrics := []string{
"client_connections", "forward_error", "client_err", "server_ejects",
"fragments", "client_eof",
}
tags["pool"] = poolName
poolData := sourceData[poolName].(map[string]interface{})
for _, m := range poolMetrics {
measurement := poolName + "_" + m
assert.NoError(t, acc.ValidateTaggedValue(measurement, poolData[m].(float64), tags))
}
poolServers := []string{"10.16.29.1:6379", "10.16.29.2:6379"}
for _, s := range poolServers {
tags["server"] = s
serverData := poolData[s].(map[string]interface{})
for k, v := range serverData {
measurement := poolName + "_" + k
assert.NoError(t, acc.ValidateTaggedValue(measurement, v, tags))
}
}
}
示例12: TestHaproxyGeneratesMetricsWithAuthentication
func TestHaproxyGeneratesMetricsWithAuthentication(t *testing.T) {
//We create a fake server to return test data
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
username, password, ok := r.BasicAuth()
if !ok {
w.WriteHeader(http.StatusNotFound)
fmt.Fprint(w, "Unauthorized")
return
}
if username == "user" && password == "password" {
fmt.Fprint(w, csvOutputSample)
} else {
w.WriteHeader(http.StatusNotFound)
fmt.Fprint(w, "Unauthorized")
}
}))
defer ts.Close()
//Now we tested again above server, with our authentication data
r := &haproxy{
Servers: []string{strings.Replace(ts.URL, "http://", "http://user:[email protected]", 1)},
}
var acc testutil.Accumulator
err := r.Gather(&acc)
require.NoError(t, err)
tags := map[string]string{
"server": ts.Listener.Addr().String(),
"proxy": "be_app",
"sv": "host0",
}
assert.NoError(t, acc.ValidateTaggedValue("stot", uint64(171014), tags))
checkInt := []struct {
name string
value uint64
}{
{"qmax", 81},
{"scur", 288},
{"smax", 713},
{"bin", 5557055817},
{"bout", 24096715169},
{"dreq", 1102},
{"dresp", 80},
{"ereq", 95740},
{"econ", 0},
{"eresp", 0},
{"wretr", 17},
{"wredis", 19},
{"active_servers", 1},
{"backup_servers", 0},
{"downtime", 0},
{"throttle", 13},
{"lbtot", 114},
{"rate", 18},
{"rate_max", 102},
{"check_duration", 1},
{"http_response.1xx", 0},
{"http_response.2xx", 1314093},
{"http_response.3xx", 537036},
{"http_response.4xx", 123452},
{"http_response.5xx", 11966},
{"req_rate", 35},
{"req_rate_max", 140},
{"req_tot", 1987928},
{"cli_abort", 0},
{"srv_abort", 0},
{"qtime", 0},
{"ctime", 2},
{"rtime", 23},
{"ttime", 545},
}
for _, c := range checkInt {
assert.Equal(t, true, acc.CheckValue(c.name, c.value))
}
//Here, we should get error because we don't pass authentication data
r = &haproxy{
Servers: []string{ts.URL},
}
err = r.Gather(&acc)
require.Error(t, err)
}
示例13: TestSystemStats_GenerateStats
//.........这里部分代码省略.........
assertContainsTaggedFloat(t, acc, "percentageIdle", 78.7699, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageNice", 1.2, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageIowait", 0.5, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageIrq", 1.1, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageSoftirq", 0.2, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageSteal", 0.0001, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageGuest", 4.8, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageGuestNice", 2.2, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageStolen", 0.23, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageBusy", 21.2301, 0.0005, cputags)
err = (&DiskStats{&mps}).Gather(&acc)
require.NoError(t, err)
tags := map[string]string{
"path": "/",
"fstype": "ext4",
}
assert.True(t, acc.CheckTaggedValue("total", uint64(128), tags))
assert.True(t, acc.CheckTaggedValue("used", uint64(105), tags))
assert.True(t, acc.CheckTaggedValue("free", uint64(23), tags))
assert.True(t, acc.CheckTaggedValue("inodes_total", uint64(1234), tags))
assert.True(t, acc.CheckTaggedValue("inodes_free", uint64(234), tags))
assert.True(t, acc.CheckTaggedValue("inodes_used", uint64(1000), tags))
err = (&NetIOStats{ps: &mps, skipChecks: true}).Gather(&acc)
require.NoError(t, err)
ntags := map[string]string{
"interface": "eth0",
}
assert.NoError(t, acc.ValidateTaggedValue("bytes_sent", uint64(1123), ntags))
assert.NoError(t, acc.ValidateTaggedValue("bytes_recv", uint64(8734422), ntags))
assert.NoError(t, acc.ValidateTaggedValue("packets_sent", uint64(781), ntags))
assert.NoError(t, acc.ValidateTaggedValue("packets_recv", uint64(23456), ntags))
assert.NoError(t, acc.ValidateTaggedValue("err_in", uint64(832), ntags))
assert.NoError(t, acc.ValidateTaggedValue("err_out", uint64(8), ntags))
assert.NoError(t, acc.ValidateTaggedValue("drop_in", uint64(7), ntags))
assert.NoError(t, acc.ValidateTaggedValue("drop_out", uint64(1), ntags))
err = (&DiskIOStats{&mps}).Gather(&acc)
require.NoError(t, err)
dtags := map[string]string{
"name": "sda1",
"serial": "ab-123-ad",
}
assert.True(t, acc.CheckTaggedValue("reads", uint64(888), dtags))
assert.True(t, acc.CheckTaggedValue("writes", uint64(5341), dtags))
assert.True(t, acc.CheckTaggedValue("read_bytes", uint64(100000), dtags))
assert.True(t, acc.CheckTaggedValue("write_bytes", uint64(200000), dtags))
assert.True(t, acc.CheckTaggedValue("read_time", uint64(7123), dtags))
assert.True(t, acc.CheckTaggedValue("write_time", uint64(9087), dtags))
assert.True(t, acc.CheckTaggedValue("io_time", uint64(123552), dtags))
err = (&MemStats{&mps}).Gather(&acc)
require.NoError(t, err)
vmtags := map[string]string(nil)
assert.True(t, acc.CheckTaggedValue("total", uint64(12400), vmtags))
assert.True(t, acc.CheckTaggedValue("available", uint64(7600), vmtags))
assert.True(t, acc.CheckTaggedValue("used", uint64(5000), vmtags))
示例14: TestSystemStats_GenerateStats
//.........这里部分代码省略.........
"path": "/home",
"fstype": "ext4",
}
assert.True(t, acc.CheckTaggedValue("total", uint64(128), tags1))
assert.True(t, acc.CheckTaggedValue("used", uint64(105), tags1))
assert.True(t, acc.CheckTaggedValue("free", uint64(23), tags1))
assert.True(t, acc.CheckTaggedValue("inodes_total", uint64(1234), tags1))
assert.True(t, acc.CheckTaggedValue("inodes_free", uint64(234), tags1))
assert.True(t, acc.CheckTaggedValue("inodes_used", uint64(1000), tags1))
assert.True(t, acc.CheckTaggedValue("total", uint64(256), tags2))
assert.True(t, acc.CheckTaggedValue("used", uint64(210), tags2))
assert.True(t, acc.CheckTaggedValue("free", uint64(46), tags2))
assert.True(t, acc.CheckTaggedValue("inodes_total", uint64(2468), tags2))
assert.True(t, acc.CheckTaggedValue("inodes_free", uint64(468), tags2))
assert.True(t, acc.CheckTaggedValue("inodes_used", uint64(2000), tags2))
// We expect 6 more DiskPoints to show up with an explicit match on "/"
// and /home not matching the /dev in Mountpoints
err = (&DiskStats{ps: &mps, Mountpoints: []string{"/", "/dev"}}).Gather(&acc)
assert.Equal(t, preDiskPoints+expectedAllDiskPoints+6, len(acc.Points))
// We should see all the diskpoints as Mountpoints includes both
// / and /home
err = (&DiskStats{ps: &mps, Mountpoints: []string{"/", "/home"}}).Gather(&acc)
assert.Equal(t, preDiskPoints+2*expectedAllDiskPoints+6, len(acc.Points))
err = (&NetIOStats{ps: &mps, skipChecks: true}).Gather(&acc)
require.NoError(t, err)
ntags := map[string]string{
"interface": "eth0",
}
assert.NoError(t, acc.ValidateTaggedValue("bytes_sent", uint64(1123), ntags))
assert.NoError(t, acc.ValidateTaggedValue("bytes_recv", uint64(8734422), ntags))
assert.NoError(t, acc.ValidateTaggedValue("packets_sent", uint64(781), ntags))
assert.NoError(t, acc.ValidateTaggedValue("packets_recv", uint64(23456), ntags))
assert.NoError(t, acc.ValidateTaggedValue("err_in", uint64(832), ntags))
assert.NoError(t, acc.ValidateTaggedValue("err_out", uint64(8), ntags))
assert.NoError(t, acc.ValidateTaggedValue("drop_in", uint64(7), ntags))
assert.NoError(t, acc.ValidateTaggedValue("drop_out", uint64(1), ntags))
err = (&DiskIOStats{&mps}).Gather(&acc)
require.NoError(t, err)
dtags := map[string]string{
"name": "sda1",
"serial": "ab-123-ad",
}
assert.True(t, acc.CheckTaggedValue("reads", uint64(888), dtags))
assert.True(t, acc.CheckTaggedValue("writes", uint64(5341), dtags))
assert.True(t, acc.CheckTaggedValue("read_bytes", uint64(100000), dtags))
assert.True(t, acc.CheckTaggedValue("write_bytes", uint64(200000), dtags))
assert.True(t, acc.CheckTaggedValue("read_time", uint64(7123), dtags))
assert.True(t, acc.CheckTaggedValue("write_time", uint64(9087), dtags))
assert.True(t, acc.CheckTaggedValue("io_time", uint64(123552), dtags))
err = (&MemStats{&mps}).Gather(&acc)
require.NoError(t, err)
vmtags := map[string]string(nil)
assert.True(t, acc.CheckTaggedValue("total", uint64(12400), vmtags))
assert.True(t, acc.CheckTaggedValue("available", uint64(7600), vmtags))
assert.True(t, acc.CheckTaggedValue("used", uint64(5000), vmtags))
assert.True(t, acc.CheckTaggedValue("available_percent",
float64(7600)/float64(12400)*100,
vmtags))
assert.True(t, acc.CheckTaggedValue("used_percent",
float64(5000)/float64(12400)*100,
vmtags))
assert.True(t, acc.CheckTaggedValue("free", uint64(1235), vmtags))
acc.Points = nil
err = (&SwapStats{&mps}).Gather(&acc)
require.NoError(t, err)
swaptags := map[string]string(nil)
assert.NoError(t, acc.ValidateTaggedValue("total", uint64(8123), swaptags))
assert.NoError(t, acc.ValidateTaggedValue("used", uint64(1232), swaptags))
assert.NoError(t, acc.ValidateTaggedValue("used_percent", float64(12.2), swaptags))
assert.NoError(t, acc.ValidateTaggedValue("free", uint64(6412), swaptags))
assert.NoError(t, acc.ValidateTaggedValue("in", uint64(7), swaptags))
assert.NoError(t, acc.ValidateTaggedValue("out", uint64(830), swaptags))
acc.Points = nil
err = (&NetStats{&mps}).Gather(&acc)
require.NoError(t, err)
netstattags := map[string]string(nil)
assert.NoError(t, acc.ValidateTaggedValue("tcp_established", 2, netstattags))
assert.NoError(t, acc.ValidateTaggedValue("tcp_close", 1, netstattags))
assert.NoError(t, acc.ValidateTaggedValue("udp_socket", 1, netstattags))
}
示例15: TestSystemStats_GenerateStats
//.........这里部分代码省略.........
assertContainsTaggedFloat(t, acc, "iowait", 0.7, 0, cputags)
assertContainsTaggedFloat(t, acc, "irq", 1.2, 0, cputags)
assertContainsTaggedFloat(t, acc, "softirq", 0.31, 0, cputags)
assertContainsTaggedFloat(t, acc, "steal", 0.0002, 0, cputags)
assertContainsTaggedFloat(t, acc, "guest", 12.9, 0, cputags)
assertContainsTaggedFloat(t, acc, "guestNice", 2.524, 0, cputags)
assertContainsTaggedFloat(t, acc, "stolen", 0.281, 0, cputags)
assertContainsTaggedFloat(t, acc, "busy", 42.7152, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageUser", 8.3, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageSystem", 2.7, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageIdle", 78.7699, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageNice", 1.2, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageIowait", 0.5, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageIrq", 1.1, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageSoftirq", 0.2, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageSteal", 0.0001, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageGuest", 4.8, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageGuestNice", 2.2, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageStolen", 0.23, 0.0005, cputags)
assertContainsTaggedFloat(t, acc, "percentageBusy", 21.2301, 0.0005, cputags)
err = (&DiskStats{&mps}).Gather(&acc)
require.NoError(t, err)
tags := map[string]string{
"path": "/",
"fstype": "ext4",
}
assert.True(t, acc.CheckTaggedValue("total", uint64(128), tags))
assert.True(t, acc.CheckTaggedValue("used", uint64(105), tags))
assert.True(t, acc.CheckTaggedValue("free", uint64(23), tags))
assert.True(t, acc.CheckTaggedValue("inodes_total", uint64(1234), tags))
assert.True(t, acc.CheckTaggedValue("inodes_free", uint64(234), tags))
assert.True(t, acc.CheckTaggedValue("inodes_used", uint64(1000), tags))
err = (&NetIOStats{ps: &mps, skipChecks: true}).Gather(&acc)
require.NoError(t, err)
ntags := map[string]string{
"interface": "eth0",
}
assert.NoError(t, acc.ValidateTaggedValue("bytes_sent", uint64(1123), ntags))
assert.NoError(t, acc.ValidateTaggedValue("bytes_recv", uint64(8734422), ntags))
assert.NoError(t, acc.ValidateTaggedValue("packets_sent", uint64(781), ntags))
assert.NoError(t, acc.ValidateTaggedValue("packets_recv", uint64(23456), ntags))
assert.NoError(t, acc.ValidateTaggedValue("err_in", uint64(832), ntags))
assert.NoError(t, acc.ValidateTaggedValue("err_out", uint64(8), ntags))
assert.NoError(t, acc.ValidateTaggedValue("drop_in", uint64(7), ntags))
assert.NoError(t, acc.ValidateTaggedValue("drop_out", uint64(1), ntags))
err = (&DiskIOStats{&mps}).Gather(&acc)
require.NoError(t, err)
dtags := map[string]string{
"name": "sda1",
"serial": "ab-123-ad",
}
assert.True(t, acc.CheckTaggedValue("reads", uint64(888), dtags))
assert.True(t, acc.CheckTaggedValue("writes", uint64(5341), dtags))
assert.True(t, acc.CheckTaggedValue("read_bytes", uint64(100000), dtags))
assert.True(t, acc.CheckTaggedValue("write_bytes", uint64(200000), dtags))
assert.True(t, acc.CheckTaggedValue("read_time", uint64(7123), dtags))
assert.True(t, acc.CheckTaggedValue("write_time", uint64(9087), dtags))
assert.True(t, acc.CheckTaggedValue("io_time", uint64(123552), dtags))
err = (&MemStats{&mps}).Gather(&acc)
require.NoError(t, err)
vmtags := map[string]string(nil)
assert.True(t, acc.CheckTaggedValue("total", uint64(12400), vmtags))
assert.True(t, acc.CheckTaggedValue("available", uint64(7600), vmtags))
assert.True(t, acc.CheckTaggedValue("used", uint64(5000), vmtags))
assert.True(t, acc.CheckTaggedValue("used_perc", float64(47.1), vmtags))
assert.True(t, acc.CheckTaggedValue("free", uint64(1235), vmtags))
assert.True(t, acc.CheckTaggedValue("active", uint64(8134), vmtags))
assert.True(t, acc.CheckTaggedValue("inactive", uint64(1124), vmtags))
assert.True(t, acc.CheckTaggedValue("buffers", uint64(771), vmtags))
assert.True(t, acc.CheckTaggedValue("cached", uint64(4312), vmtags))
assert.True(t, acc.CheckTaggedValue("wired", uint64(134), vmtags))
assert.True(t, acc.CheckTaggedValue("shared", uint64(2142), vmtags))
acc.Points = nil
err = (&SwapStats{&mps}).Gather(&acc)
require.NoError(t, err)
swaptags := map[string]string(nil)
assert.NoError(t, acc.ValidateTaggedValue("total", uint64(8123), swaptags))
assert.NoError(t, acc.ValidateTaggedValue("used", uint64(1232), swaptags))
assert.NoError(t, acc.ValidateTaggedValue("used_perc", float64(12.2), swaptags))
assert.NoError(t, acc.ValidateTaggedValue("free", uint64(6412), swaptags))
assert.NoError(t, acc.ValidateTaggedValue("in", uint64(7), swaptags))
assert.NoError(t, acc.ValidateTaggedValue("out", uint64(830), swaptags))
}