Fix exec plugin panic with single binary

fixes #1330
This commit is contained in:
Cameron Sparr
2016-06-10 11:20:50 +01:00
parent 75e6cb9064
commit 008ed17a79
2 changed files with 15 additions and 3 deletions

View File

@@ -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]}, " "))
}
}
}
}