From cd7468f3be4c8031d8ab62c069194985fa8aa57f Mon Sep 17 00:00:00 2001 From: Nick Jones Date: Mon, 28 Sep 2015 13:22:24 +0100 Subject: [PATCH 1/5] Fix conditional test against useradd so it's compatible with Dash The test to see which version of `useradd` is installed uses 'bashisms' that fail on Ubuntu due to the fact that `/bin/sh` is symlinked to Dash, causing the telegraf account to be created without the `--system` option ever being passed. This change amends the syntax so that it's POSIX-compatible and more portable as a result. --- scripts/package.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/package.sh b/scripts/package.sh index ace553e57..e88e52f9e 100755 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -149,7 +149,7 @@ ln -sfn $INSTALL_ROOT_DIR/versions/$version/telegraf $INSTALL_ROOT_DIR/telegraf if ! id telegraf >/dev/null 2>&1; then useradd --help 2>&1| grep -- --system > /dev/null 2>&1 old_useradd=\$? - if [[ \$old_useradd == 0 ]] + if [ \$old_useradd -eq 0 ] then useradd --system -U -M telegraf else From f6f45881da4a529dc773950c1b2ebd9ed30f359a Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Mon, 28 Sep 2015 13:08:28 -0700 Subject: [PATCH 2/5] Add more logging to telegraf --- agent.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/agent.go b/agent.go index d6674f885..abf1341b8 100644 --- a/agent.go +++ b/agent.go @@ -177,12 +177,15 @@ func (a *Agent) crankParallel() error { var wg sync.WaitGroup + start := time.Now() + counter := 0 for _, plugin := range a.plugins { if plugin.config.Interval != 0 { continue } wg.Add(1) + counter++ go func(plugin *runningPlugin) { defer wg.Done() @@ -216,6 +219,9 @@ func (a *Agent) crankParallel() error { bp.Points = append(bp.Points, sub.Points...) } + elapsed := time.Since(start) + log.Printf("Cranking default interval, gathered %d metrics from %d plugins in %s\n", + len(bp.Points), counter, elapsed) return a.flush(&bp) } @@ -252,6 +258,7 @@ func (a *Agent) crankSeparate(shutdown chan struct{}, plugin *runningPlugin) err for { var bp BatchPoints var outerr error + start := time.Now() bp.Debug = a.Debug @@ -270,6 +277,9 @@ func (a *Agent) crankSeparate(shutdown chan struct{}, plugin *runningPlugin) err bp.Time = bp.Time.UTC() } + elapsed := time.Since(start) + log.Printf("Cranking separate interval, gathered %d metrics from %s in %s\n", + len(bp.Points), plugin.name, elapsed) if err := a.flush(&bp); err != nil { outerr = errors.New("Error encountered processing plugins & outputs") } From f5d1aaf7d973e5d815e507f5e2614882cb4338d0 Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Mon, 28 Sep 2015 17:05:42 -0700 Subject: [PATCH 3/5] Memory plugin: re-add cached and buffered to memory plugin --- plugins/system/memory.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/system/memory.go b/plugins/system/memory.go index 93cf7dc21..11e7afbb1 100644 --- a/plugins/system/memory.go +++ b/plugins/system/memory.go @@ -28,6 +28,8 @@ func (s *MemStats) Gather(acc plugins.Accumulator) error { acc.Add("available", vm.Available, vmtags) acc.Add("used", vm.Used, vmtags) acc.Add("free", vm.Free, vmtags) + acc.Add("cached", vm.Cached, vmtags) + acc.Add("buffered", vm.Buffers, vmtags) acc.Add("used_percent", 100*float64(vm.Used)/float64(vm.Total), vmtags) acc.Add("available_percent", 100*float64(vm.Available)/float64(vm.Total), From b01c28ebc6236369485bec1129e33a222c02200c Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Tue, 29 Sep 2015 14:06:49 -0700 Subject: [PATCH 4/5] Clean up additional logging and always print basic agent config --- agent.go | 8 ++++---- cmd/telegraf/telegraf.go | 9 +++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/agent.go b/agent.go index abf1341b8..c1c9fcf14 100644 --- a/agent.go +++ b/agent.go @@ -220,8 +220,8 @@ func (a *Agent) crankParallel() error { } elapsed := time.Since(start) - log.Printf("Cranking default interval, gathered %d metrics from %d plugins in %s\n", - len(bp.Points), counter, elapsed) + log.Printf("Cranking default (%s) interval, gathered %d metrics from %d plugins in %s\n", + a.Interval, len(bp.Points), counter, elapsed) return a.flush(&bp) } @@ -278,8 +278,8 @@ func (a *Agent) crankSeparate(shutdown chan struct{}, plugin *runningPlugin) err } elapsed := time.Since(start) - log.Printf("Cranking separate interval, gathered %d metrics from %s in %s\n", - len(bp.Points), plugin.name, elapsed) + log.Printf("Cranking separate (%s) interval, gathered %d metrics from %s in %s\n", + plugin.config.Interval, len(bp.Points), plugin.name, elapsed) if err := a.flush(&bp); err != nil { outerr = errors.New("Error encountered processing plugins & outputs") } diff --git a/cmd/telegraf/telegraf.go b/cmd/telegraf/telegraf.go index bb1e0121d..bf53d45b2 100644 --- a/cmd/telegraf/telegraf.go +++ b/cmd/telegraf/telegraf.go @@ -132,12 +132,9 @@ func main() { log.Printf("Starting Telegraf (version %s)\n", Version) log.Printf("Loaded outputs: %s", strings.Join(outputs, " ")) log.Printf("Loaded plugins: %s", strings.Join(plugins, " ")) - if ag.Debug { - log.Printf("Debug: enabled") - log.Printf("Agent Config: Interval:%s, Debug:%#v, Hostname:%#v, "+ - "Precision:%#v, UTC: %#v\n", - ag.Interval, ag.Debug, ag.Hostname, ag.Precision, ag.UTC) - } + log.Printf("Agent Config: Interval:%s, Debug:%#v, Hostname:%#v, "+ + "Precision:%#v, UTC: %#v\n", + ag.Interval, ag.Debug, ag.Hostname, ag.Precision, ag.UTC) log.Printf("Tags enabled: %s", config.ListTags()) if *fPidfile != "" { From 64a3a718e6cac559b8d2ab459ab1780fca9c9e22 Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Tue, 29 Sep 2015 14:15:23 -0700 Subject: [PATCH 5/5] CHANGELOG feature updates --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3aca132f8..728479937 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,9 +9,13 @@ - [#90](https://github.com/influxdb/telegraf/issues/90): Add Docker labels to tags in docker plugin - [#223](https://github.com/influxdb/telegraf/pull/223): Add port tag to nginx plugin. Thanks @neezgee! - [#227](https://github.com/influxdb/telegraf/pull/227): Add command intervals to exec plugin. Thanks @jpalay! +- Memory plugin: cached and buffered measurements re-added +- Logging: additional logging for each collection interval, track the number +of metrics collected and from how many plugins. ### Bugfixes - [#228](https://github.com/influxdb/telegraf/pull/228): New version of package will replace old one. Thanks @ekini! +- [#232](https://github.com/influxdb/telegraf/pull/232): Fix bashism run during deb package installation. Thanks @yankcrime! ## v0.1.9 [2015-09-22]