From 11126cf4aedddd6089fa01d09bb1d765a8813f63 Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Fri, 11 Sep 2015 16:21:43 -0700 Subject: [PATCH 1/2] Add a server name tag to the RabbitMQ server list Fixes #183 --- plugins/rabbitmq/rabbitmq.go | 9 +++++++-- plugins/system/ps/net/net_darwin.go | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/rabbitmq/rabbitmq.go b/plugins/rabbitmq/rabbitmq.go index 55b4b0a95..506e932ad 100644 --- a/plugins/rabbitmq/rabbitmq.go +++ b/plugins/rabbitmq/rabbitmq.go @@ -14,6 +14,7 @@ const DefaultURL = "http://localhost:15672" type Server struct { URL string + Name string Username string Password string Nodes []string @@ -70,6 +71,7 @@ type Node struct { var sampleConfig = ` # Specify servers via an array of tables [[rabbitmq.servers]] + # name = "rmq-server-1" # optional tag # url = "http://localhost:15672" # username = "guest" # password = "guest" @@ -117,7 +119,10 @@ func (r *RabbitMQ) gatherServer(serv *Server, acc plugins.Accumulator) error { return err } - tags := map[string]string{} + tags := map[string]string{"url": serv.URL} + if serv.Name != "" { + tags["name"] = serv.Name + } acc.Add("messages", overview.QueueTotals.Messages, tags) acc.Add("messages_ready", overview.QueueTotals.MessagesReady, tags) @@ -147,7 +152,7 @@ func (r *RabbitMQ) gatherServer(serv *Server, acc plugins.Accumulator) error { continue } - tags = map[string]string{"node": node.Name} + tags["node"] = node.Name acc.Add("disk_free", node.DiskFree, tags) acc.Add("disk_free_limit", node.DiskFreeLimit, tags) diff --git a/plugins/system/ps/net/net_darwin.go b/plugins/system/ps/net/net_darwin.go index 7fb21713c..0c518a736 100644 --- a/plugins/system/ps/net/net_darwin.go +++ b/plugins/system/ps/net/net_darwin.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/common" + "github.com/influxdb/telegraf/plugins/system/ps/common" ) func NetIOCounters(pernic bool) ([]NetIOCountersStat, error) { @@ -26,7 +26,7 @@ func NetIOCounters(pernic bool) ([]NetIOCountersStat, error) { // skip first line continue } - if common.StringsHas(exists, values[0]) { + if common.StringContains(exists, values[0]) { // skip if already get continue } From 6d6158ff08ce4c4aa597d09d98f6e34911b09d67 Mon Sep 17 00:00:00 2001 From: mced Date: Sat, 12 Sep 2015 19:11:40 +0200 Subject: [PATCH 2/2] [fix] mem_used_perc returns percentage of used mem Closes #189 --- CHANGELOG.md | 1 + plugins/system/ps/mem/mem_linux.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cfaefda5..3519407dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ will still be backwards compatible if only `url` is specified. - [#178](https://github.com/influxdb/telegraf/issues/178): redis plugin, multiple server thread hang bug - Fix net plugin on darwin - [#84](https://github.com/influxdb/telegraf/issues/84): Fix docker plugin on CentOS. Thanks @neezgee! +- [#189](https://github.com/influxdb/telegraf/pull/189): Fix mem_used_perc. Thanks @mced! ## v0.1.8 [2015-09-04] diff --git a/plugins/system/ps/mem/mem_linux.go b/plugins/system/ps/mem/mem_linux.go index 42a49a2b6..b2519ddd5 100644 --- a/plugins/system/ps/mem/mem_linux.go +++ b/plugins/system/ps/mem/mem_linux.go @@ -45,7 +45,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) { } ret.Available = ret.Free + ret.Buffers + ret.Cached ret.Used = ret.Total - ret.Free - ret.UsedPercent = float64(ret.Total-ret.Available) / float64(ret.Total) * 100.0 + ret.UsedPercent = float64(ret.Used) / float64(ret.Total) * 100.0 return ret, nil }