Only build the docker plugin on linux
This commit is contained in:
parent
5b78b1e548
commit
ff2de0c715
|
@ -30,16 +30,16 @@ func TestAgent_LoadPlugin(t *testing.T) {
|
||||||
assert.Equal(t, 2, len(pluginsEnabled))
|
assert.Equal(t, 2, len(pluginsEnabled))
|
||||||
|
|
||||||
pluginsEnabled, _ = a.LoadPlugins("")
|
pluginsEnabled, _ = a.LoadPlugins("")
|
||||||
assert.Equal(t, 24, len(pluginsEnabled))
|
assert.Equal(t, 23, len(pluginsEnabled))
|
||||||
|
|
||||||
pluginsEnabled, _ = a.LoadPlugins(" ")
|
pluginsEnabled, _ = a.LoadPlugins(" ")
|
||||||
assert.Equal(t, 24, len(pluginsEnabled))
|
assert.Equal(t, 23, len(pluginsEnabled))
|
||||||
|
|
||||||
pluginsEnabled, _ = a.LoadPlugins(" ")
|
pluginsEnabled, _ = a.LoadPlugins(" ")
|
||||||
assert.Equal(t, 24, len(pluginsEnabled))
|
assert.Equal(t, 23, len(pluginsEnabled))
|
||||||
|
|
||||||
pluginsEnabled, _ = a.LoadPlugins("\n\t")
|
pluginsEnabled, _ = a.LoadPlugins("\n\t")
|
||||||
assert.Equal(t, 24, len(pluginsEnabled))
|
assert.Equal(t, 23, len(pluginsEnabled))
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// +build linux
|
||||||
|
|
||||||
package system
|
package system
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
// +build linux
|
||||||
|
|
||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/influxdb/telegraf/plugins/system/ps/cpu"
|
||||||
|
"github.com/influxdb/telegraf/plugins/system/ps/docker"
|
||||||
|
"github.com/influxdb/telegraf/testutil"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestDockerStats_GenerateStats(t *testing.T) {
|
||||||
|
var mps MockPS
|
||||||
|
var acc testutil.Accumulator
|
||||||
|
|
||||||
|
ds := &DockerContainerStat{
|
||||||
|
Name: "blah",
|
||||||
|
CPU: &cpu.CPUTimesStat{
|
||||||
|
CPU: "all",
|
||||||
|
User: 3.1,
|
||||||
|
System: 8.2,
|
||||||
|
Idle: 80.1,
|
||||||
|
Nice: 1.3,
|
||||||
|
Iowait: 0.2,
|
||||||
|
Irq: 0.1,
|
||||||
|
Softirq: 0.11,
|
||||||
|
Steal: 0.0001,
|
||||||
|
Guest: 8.1,
|
||||||
|
GuestNice: 0.324,
|
||||||
|
Stolen: 0.051,
|
||||||
|
},
|
||||||
|
Mem: &docker.CgroupMemStat{
|
||||||
|
ContainerID: "blah",
|
||||||
|
Cache: 1,
|
||||||
|
RSS: 2,
|
||||||
|
RSSHuge: 3,
|
||||||
|
MappedFile: 4,
|
||||||
|
Pgpgin: 5,
|
||||||
|
Pgpgout: 6,
|
||||||
|
Pgfault: 7,
|
||||||
|
Pgmajfault: 8,
|
||||||
|
InactiveAnon: 9,
|
||||||
|
ActiveAnon: 10,
|
||||||
|
InactiveFile: 11,
|
||||||
|
ActiveFile: 12,
|
||||||
|
Unevictable: 13,
|
||||||
|
HierarchicalMemoryLimit: 14,
|
||||||
|
TotalCache: 15,
|
||||||
|
TotalRSS: 16,
|
||||||
|
TotalRSSHuge: 17,
|
||||||
|
TotalMappedFile: 18,
|
||||||
|
TotalPgpgIn: 19,
|
||||||
|
TotalPgpgOut: 20,
|
||||||
|
TotalPgFault: 21,
|
||||||
|
TotalPgMajFault: 22,
|
||||||
|
TotalInactiveAnon: 23,
|
||||||
|
TotalActiveAnon: 24,
|
||||||
|
TotalInactiveFile: 25,
|
||||||
|
TotalActiveFile: 26,
|
||||||
|
TotalUnevictable: 27,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
mps.On("DockerStat").Return([]*DockerContainerStat{ds}, nil)
|
||||||
|
|
||||||
|
err := (&DockerStats{&mps}).Gather(&acc)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
dockertags := map[string]string{
|
||||||
|
"name": "blah",
|
||||||
|
"id": "",
|
||||||
|
"command": "",
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.True(t, acc.CheckTaggedValue("user", 3.1, dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("system", 8.2, dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("idle", 80.1, dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("nice", 1.3, dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("iowait", 0.2, dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("irq", 0.1, dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("softirq", 0.11, dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("steal", 0.0001, dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("guest", 8.1, dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("guestNice", 0.324, dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("stolen", 0.051, dockertags))
|
||||||
|
|
||||||
|
assert.True(t, acc.CheckTaggedValue("cache", uint64(1), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("rss", uint64(2), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("rss_huge", uint64(3), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("mapped_file", uint64(4), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("swap_in", uint64(5), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("swap_out", uint64(6), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("page_fault", uint64(7), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("page_major_fault", uint64(8), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("inactive_anon", uint64(9), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("active_anon", uint64(10), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("inactive_file", uint64(11), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("active_file", uint64(12), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("unevictable", uint64(13), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("memory_limit", uint64(14), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("total_cache", uint64(15), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("total_rss", uint64(16), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("total_rss_huge", uint64(17), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("total_mapped_file", uint64(18), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("total_swap_in", uint64(19), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("total_swap_out", uint64(20), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("total_page_fault", uint64(21), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("total_page_major_fault", uint64(22), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("total_inactive_anon", uint64(23), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("total_active_anon", uint64(24), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("total_inactive_file", uint64(25), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("total_active_file", uint64(26), dockertags))
|
||||||
|
assert.True(t, acc.CheckTaggedValue("total_unevictable", uint64(27), dockertags))
|
||||||
|
}
|
|
@ -7,7 +7,6 @@ import (
|
||||||
|
|
||||||
"github.com/influxdb/telegraf/plugins/system/ps/cpu"
|
"github.com/influxdb/telegraf/plugins/system/ps/cpu"
|
||||||
"github.com/influxdb/telegraf/plugins/system/ps/disk"
|
"github.com/influxdb/telegraf/plugins/system/ps/disk"
|
||||||
"github.com/influxdb/telegraf/plugins/system/ps/docker"
|
|
||||||
"github.com/influxdb/telegraf/plugins/system/ps/load"
|
"github.com/influxdb/telegraf/plugins/system/ps/load"
|
||||||
"github.com/influxdb/telegraf/plugins/system/ps/mem"
|
"github.com/influxdb/telegraf/plugins/system/ps/mem"
|
||||||
"github.com/influxdb/telegraf/plugins/system/ps/net"
|
"github.com/influxdb/telegraf/plugins/system/ps/net"
|
||||||
|
@ -129,56 +128,6 @@ func TestSystemStats_GenerateStats(t *testing.T) {
|
||||||
|
|
||||||
mps.On("SwapStat").Return(sms, nil)
|
mps.On("SwapStat").Return(sms, nil)
|
||||||
|
|
||||||
ds := &DockerContainerStat{
|
|
||||||
Name: "blah",
|
|
||||||
CPU: &cpu.CPUTimesStat{
|
|
||||||
CPU: "all",
|
|
||||||
User: 3.1,
|
|
||||||
System: 8.2,
|
|
||||||
Idle: 80.1,
|
|
||||||
Nice: 1.3,
|
|
||||||
Iowait: 0.2,
|
|
||||||
Irq: 0.1,
|
|
||||||
Softirq: 0.11,
|
|
||||||
Steal: 0.0001,
|
|
||||||
Guest: 8.1,
|
|
||||||
GuestNice: 0.324,
|
|
||||||
Stolen: 0.051,
|
|
||||||
},
|
|
||||||
Mem: &docker.CgroupMemStat{
|
|
||||||
ContainerID: "blah",
|
|
||||||
Cache: 1,
|
|
||||||
RSS: 2,
|
|
||||||
RSSHuge: 3,
|
|
||||||
MappedFile: 4,
|
|
||||||
Pgpgin: 5,
|
|
||||||
Pgpgout: 6,
|
|
||||||
Pgfault: 7,
|
|
||||||
Pgmajfault: 8,
|
|
||||||
InactiveAnon: 9,
|
|
||||||
ActiveAnon: 10,
|
|
||||||
InactiveFile: 11,
|
|
||||||
ActiveFile: 12,
|
|
||||||
Unevictable: 13,
|
|
||||||
HierarchicalMemoryLimit: 14,
|
|
||||||
TotalCache: 15,
|
|
||||||
TotalRSS: 16,
|
|
||||||
TotalRSSHuge: 17,
|
|
||||||
TotalMappedFile: 18,
|
|
||||||
TotalPgpgIn: 19,
|
|
||||||
TotalPgpgOut: 20,
|
|
||||||
TotalPgFault: 21,
|
|
||||||
TotalPgMajFault: 22,
|
|
||||||
TotalInactiveAnon: 23,
|
|
||||||
TotalActiveAnon: 24,
|
|
||||||
TotalInactiveFile: 25,
|
|
||||||
TotalActiveFile: 26,
|
|
||||||
TotalUnevictable: 27,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
mps.On("DockerStat").Return([]*DockerContainerStat{ds}, nil)
|
|
||||||
|
|
||||||
ss := &SystemStats{ps: &mps}
|
ss := &SystemStats{ps: &mps}
|
||||||
|
|
||||||
err := ss.Gather(&acc)
|
err := ss.Gather(&acc)
|
||||||
|
@ -332,55 +281,6 @@ func TestSystemStats_GenerateStats(t *testing.T) {
|
||||||
assert.NoError(t, acc.ValidateTaggedValue("free", uint64(6412), swaptags))
|
assert.NoError(t, acc.ValidateTaggedValue("free", uint64(6412), swaptags))
|
||||||
assert.NoError(t, acc.ValidateTaggedValue("in", uint64(7), swaptags))
|
assert.NoError(t, acc.ValidateTaggedValue("in", uint64(7), swaptags))
|
||||||
assert.NoError(t, acc.ValidateTaggedValue("out", uint64(830), swaptags))
|
assert.NoError(t, acc.ValidateTaggedValue("out", uint64(830), swaptags))
|
||||||
|
|
||||||
err = (&DockerStats{&mps}).Gather(&acc)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
dockertags := map[string]string{
|
|
||||||
"name": "blah",
|
|
||||||
"id": "",
|
|
||||||
"command": "",
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.True(t, acc.CheckTaggedValue("user", 3.1, dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("system", 8.2, dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("idle", 80.1, dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("nice", 1.3, dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("iowait", 0.2, dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("irq", 0.1, dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("softirq", 0.11, dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("steal", 0.0001, dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("guest", 8.1, dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("guestNice", 0.324, dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("stolen", 0.051, dockertags))
|
|
||||||
|
|
||||||
assert.True(t, acc.CheckTaggedValue("cache", uint64(1), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("rss", uint64(2), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("rss_huge", uint64(3), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("mapped_file", uint64(4), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("swap_in", uint64(5), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("swap_out", uint64(6), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("page_fault", uint64(7), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("page_major_fault", uint64(8), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("inactive_anon", uint64(9), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("active_anon", uint64(10), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("inactive_file", uint64(11), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("active_file", uint64(12), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("unevictable", uint64(13), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("memory_limit", uint64(14), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("total_cache", uint64(15), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("total_rss", uint64(16), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("total_rss_huge", uint64(17), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("total_mapped_file", uint64(18), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("total_swap_in", uint64(19), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("total_swap_out", uint64(20), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("total_page_fault", uint64(21), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("total_page_major_fault", uint64(22), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("total_inactive_anon", uint64(23), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("total_active_anon", uint64(24), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("total_inactive_file", uint64(25), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("total_active_file", uint64(26), dockertags))
|
|
||||||
assert.True(t, acc.CheckTaggedValue("total_unevictable", uint64(27), dockertags))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asserts that a given accumulator contains a measurment of type float64 with
|
// Asserts that a given accumulator contains a measurment of type float64 with
|
||||||
|
|
|
@ -74,10 +74,6 @@ percpu = false
|
||||||
# If no servers are specified, then localhost is used as the host.
|
# If no servers are specified, then localhost is used as the host.
|
||||||
servers = ["localhost"]
|
servers = ["localhost"]
|
||||||
|
|
||||||
# Read metrics about docker containers
|
|
||||||
[docker]
|
|
||||||
# no configuration
|
|
||||||
|
|
||||||
# Read stats from one or more Elasticsearch servers or clusters
|
# Read stats from one or more Elasticsearch servers or clusters
|
||||||
[elasticsearch]
|
[elasticsearch]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue