From 008ed17a79576edc85ab864ce409705968638131 Mon Sep 17 00:00:00 2001
From: Cameron Sparr <cameronsparr@gmail.com>
Date: Fri, 10 Jun 2016 11:20:50 +0100
Subject: [PATCH] Fix exec plugin panic with single binary

fixes #1330
---
 CHANGELOG.md                | 10 +++++++++-
 plugins/inputs/exec/exec.go |  8 ++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index c3e829a9..9ed2d412 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,12 @@
+## v1.0 beta 2 [unreleased]
+
+### Features
+
+### Bugfixes
+
+- [#1330](https://github.com/influxdata/telegraf/issues/1330): Fix exec plugin panic when using single binary
+- [#1336](https://github.com/influxdata/telegraf/issues/1336): Fixed incorrect prometheus metrics source selection
+
 ## v1.0 beta 1 [2016-06-07]
 
 ### Release Notes
@@ -50,7 +59,6 @@ time before a new metric is included by the plugin.
 - [#1316](https://github.com/influxdata/telegraf/pull/1316): Removed leaked "database" tag on redis metrics. Thanks @PierreF!
 - [#1323](https://github.com/influxdata/telegraf/issues/1323): Processes plugin: fix potential error with /proc/net/stat directory.
 - [#1322](https://github.com/influxdata/telegraf/issues/1322): Fix rare RHEL 5.2 panic in gopsutil diskio gathering function.
-- [#1336](https://github.com/influxdata/telegraf/issues/1336): Fixed incorrect prometheus metrics source selection
 
 ## v0.13.1 [2016-05-24]
 
diff --git a/plugins/inputs/exec/exec.go b/plugins/inputs/exec/exec.go
index 41583196..c8d4cee5 100644
--- a/plugins/inputs/exec/exec.go
+++ b/plugins/inputs/exec/exec.go
@@ -177,8 +177,12 @@ func (e *Exec) Gather(acc telegraf.Accumulator) error {
 			// There were matches, so we'll append each match together with
 			// the arguments to the commands slice
 			for _, match := range matches {
-				commands = append(
-					commands, strings.Join([]string{match, cmdAndArgs[1]}, " "))
+				if len(cmdAndArgs) == 1 {
+					commands = append(commands, match)
+				} else {
+					commands = append(commands,
+						strings.Join([]string{match, cmdAndArgs[1]}, " "))
+				}
 			}
 		}
 	}
-- 
GitLab