From 3e2383534e63c28612875caa6aa06269ca6b66cb Mon Sep 17 00:00:00 2001 From: Julien Mathevet Date: Thu, 5 Jul 2018 12:42:51 +0200 Subject: [PATCH] #4375 - fix docker tests memory usage --- Gopkg.lock | 213 ++++++++++++++++++++++++- plugins/inputs/docker/docker.go | 2 +- plugins/inputs/docker/stats_helpers.go | 4 +- 3 files changed, 215 insertions(+), 4 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 194bb61e64678..eee91ae29d2c4 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -413,6 +413,217 @@ ] revision = "c43482518d410361b6c383d7aebce33d0471d7bc" +[[projects]] + branch = "master" + name = "github.com/influxdata/telegraf" + packages = [ + ".", + "agent", + "filter", + "internal", + "internal/buffer", + "internal/config", + "internal/config/aws", + "internal/globpath", + "internal/limiter", + "internal/models", + "internal/templating", + "internal/tls", + "logger", + "metric", + "plugins/aggregators", + "plugins/aggregators/all", + "plugins/aggregators/basicstats", + "plugins/aggregators/histogram", + "plugins/aggregators/minmax", + "plugins/aggregators/valuecounter", + "plugins/inputs", + "plugins/inputs/aerospike", + "plugins/inputs/all", + "plugins/inputs/amqp_consumer", + "plugins/inputs/apache", + "plugins/inputs/aurora", + "plugins/inputs/bcache", + "plugins/inputs/bond", + "plugins/inputs/burrow", + "plugins/inputs/cassandra", + "plugins/inputs/ceph", + "plugins/inputs/cgroup", + "plugins/inputs/chrony", + "plugins/inputs/cloudwatch", + "plugins/inputs/conntrack", + "plugins/inputs/consul", + "plugins/inputs/couchbase", + "plugins/inputs/couchdb", + "plugins/inputs/dcos", + "plugins/inputs/disque", + "plugins/inputs/dmcache", + "plugins/inputs/dns_query", + "plugins/inputs/docker", + "plugins/inputs/dovecot", + "plugins/inputs/elasticsearch", + "plugins/inputs/exec", + "plugins/inputs/fail2ban", + "plugins/inputs/fibaro", + "plugins/inputs/filestat", + "plugins/inputs/fluentd", + "plugins/inputs/graylog", + "plugins/inputs/haproxy", + "plugins/inputs/hddtemp", + "plugins/inputs/hddtemp/go-hddtemp", + "plugins/inputs/http", + "plugins/inputs/http_listener", + "plugins/inputs/http_response", + "plugins/inputs/httpjson", + "plugins/inputs/influxdb", + "plugins/inputs/internal", + "plugins/inputs/interrupts", + "plugins/inputs/ipmi_sensor", + "plugins/inputs/ipset", + "plugins/inputs/iptables", + "plugins/inputs/jolokia", + "plugins/inputs/jolokia2", + "plugins/inputs/jti_openconfig_telemetry", + "plugins/inputs/jti_openconfig_telemetry/auth", + "plugins/inputs/jti_openconfig_telemetry/oc", + "plugins/inputs/kafka_consumer", + "plugins/inputs/kafka_consumer_legacy", + "plugins/inputs/kapacitor", + "plugins/inputs/kubernetes", + "plugins/inputs/leofs", + "plugins/inputs/logparser", + "plugins/inputs/logparser/grok", + "plugins/inputs/lustre2", + "plugins/inputs/mailchimp", + "plugins/inputs/mcrouter", + "plugins/inputs/memcached", + "plugins/inputs/mesos", + "plugins/inputs/minecraft", + "plugins/inputs/minecraft/internal/rcon", + "plugins/inputs/mongodb", + "plugins/inputs/mqtt_consumer", + "plugins/inputs/mysql", + "plugins/inputs/mysql/v1", + "plugins/inputs/nats", + "plugins/inputs/nats_consumer", + "plugins/inputs/net_response", + "plugins/inputs/nginx", + "plugins/inputs/nginx_plus", + "plugins/inputs/nsq", + "plugins/inputs/nsq_consumer", + "plugins/inputs/nstat", + "plugins/inputs/ntpq", + "plugins/inputs/nvidia_smi", + "plugins/inputs/openldap", + "plugins/inputs/opensmtpd", + "plugins/inputs/passenger", + "plugins/inputs/pf", + "plugins/inputs/phpfpm", + "plugins/inputs/ping", + "plugins/inputs/postfix", + "plugins/inputs/postgresql", + "plugins/inputs/postgresql_extensible", + "plugins/inputs/powerdns", + "plugins/inputs/procstat", + "plugins/inputs/prometheus", + "plugins/inputs/puppetagent", + "plugins/inputs/rabbitmq", + "plugins/inputs/raindrops", + "plugins/inputs/redis", + "plugins/inputs/rethinkdb", + "plugins/inputs/riak", + "plugins/inputs/salesforce", + "plugins/inputs/sensors", + "plugins/inputs/smart", + "plugins/inputs/snmp", + "plugins/inputs/snmp_legacy", + "plugins/inputs/socket_listener", + "plugins/inputs/solr", + "plugins/inputs/sqlserver", + "plugins/inputs/statsd", + "plugins/inputs/syslog", + "plugins/inputs/sysstat", + "plugins/inputs/system", + "plugins/inputs/tail", + "plugins/inputs/tcp_listener", + "plugins/inputs/teamspeak", + "plugins/inputs/tengine", + "plugins/inputs/tomcat", + "plugins/inputs/trig", + "plugins/inputs/twemproxy", + "plugins/inputs/udp_listener", + "plugins/inputs/unbound", + "plugins/inputs/varnish", + "plugins/inputs/webhooks", + "plugins/inputs/webhooks/filestack", + "plugins/inputs/webhooks/github", + "plugins/inputs/webhooks/mandrill", + "plugins/inputs/webhooks/papertrail", + "plugins/inputs/webhooks/particle", + "plugins/inputs/webhooks/rollbar", + "plugins/inputs/win_perf_counters", + "plugins/inputs/win_services", + "plugins/inputs/zfs", + "plugins/inputs/zipkin", + "plugins/inputs/zipkin/codec", + "plugins/inputs/zipkin/codec/jsonV1", + "plugins/inputs/zipkin/codec/thrift", + "plugins/inputs/zipkin/trace", + "plugins/inputs/zookeeper", + "plugins/outputs", + "plugins/outputs/all", + "plugins/outputs/amon", + "plugins/outputs/amqp", + "plugins/outputs/application_insights", + "plugins/outputs/application_insights/mocks", + "plugins/outputs/cloudwatch", + "plugins/outputs/cratedb", + "plugins/outputs/datadog", + "plugins/outputs/discard", + "plugins/outputs/elasticsearch", + "plugins/outputs/file", + "plugins/outputs/graphite", + "plugins/outputs/graylog", + "plugins/outputs/http", + "plugins/outputs/influxdb", + "plugins/outputs/instrumental", + "plugins/outputs/kafka", + "plugins/outputs/kinesis", + "plugins/outputs/librato", + "plugins/outputs/mqtt", + "plugins/outputs/nats", + "plugins/outputs/nsq", + "plugins/outputs/opentsdb", + "plugins/outputs/prometheus_client", + "plugins/outputs/riemann", + "plugins/outputs/riemann_legacy", + "plugins/outputs/socket_writer", + "plugins/outputs/wavefront", + "plugins/parsers", + "plugins/parsers/collectd", + "plugins/parsers/dropwizard", + "plugins/parsers/graphite", + "plugins/parsers/influx", + "plugins/parsers/json", + "plugins/parsers/nagios", + "plugins/parsers/value", + "plugins/processors", + "plugins/processors/all", + "plugins/processors/converter", + "plugins/processors/enum", + "plugins/processors/override", + "plugins/processors/printer", + "plugins/processors/regex", + "plugins/processors/topk", + "plugins/serializers", + "plugins/serializers/graphite", + "plugins/serializers/influx", + "plugins/serializers/json", + "selfstat", + "testutil" + ] + revision = "bf076dab7362d6db74245210781e26b8205bc1a5" + [[projects]] branch = "master" name = "github.com/influxdata/toml" @@ -968,6 +1179,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "024194b983d91b9500fe97e0aa0ddb5fe725030cb51ddfb034e386cae1098370" + inputs-digest = "eaae5982e6c8ec3e645c77e111f59644c5fcb020a5f932bf41462e82ece35249" solver-name = "gps-cdcl" solver-version = 1 diff --git a/plugins/inputs/docker/docker.go b/plugins/inputs/docker/docker.go index 7635e20cb6598..d1d6fced336d3 100644 --- a/plugins/inputs/docker/docker.go +++ b/plugins/inputs/docker/docker.go @@ -532,7 +532,7 @@ func gatherContainerStats( mem := calculateMemUsageUnixNoCache(stat.MemoryStats) memLimit := float64(stat.MemoryStats.Limit) memfields["usage"] = mem - memfields["usage_percent"] = calculateMemPercentUnixNoCache(memLimit, mem) + memfields["usage_percent"] = calculateMemPercentUnixNoCache(memLimit, float64(mem)) } else { memfields["commit_bytes"] = stat.MemoryStats.Commit memfields["commit_peak_bytes"] = stat.MemoryStats.CommitPeak diff --git a/plugins/inputs/docker/stats_helpers.go b/plugins/inputs/docker/stats_helpers.go index b4c91e2fc9069..8f900b1af585d 100644 --- a/plugins/inputs/docker/stats_helpers.go +++ b/plugins/inputs/docker/stats_helpers.go @@ -41,8 +41,8 @@ func calculateCPUPercentWindows(v *types.StatsJSON) float64 { // calculateMemUsageUnixNoCache calculate memory usage of the container. // Page cache is intentionally excluded to avoid misinterpretation of the output. -func calculateMemUsageUnixNoCache(mem types.MemoryStats) float64 { - return float64(mem.Usage - mem.Stats["cache"]) +func calculateMemUsageUnixNoCache(mem types.MemoryStats) uint64 { + return mem.Usage - mem.Stats["cache"] } func calculateMemPercentUnixNoCache(limit float64, usedNoCache float64) float64 {