Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exec output plugin #4776

Closed
wants to merge 9 commits into from

Conversation

Jaeyo
Copy link
Contributor

@Jaeyo Jaeyo commented Sep 30, 2018

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

Inherit #1999
Close #544
Relates to #1717

@Jaeyo Jaeyo changed the title [WIP] Add exec output plugin Add exec output plugin Sep 30, 2018
Copy link
Contributor

@glinton glinton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

# Timeout for each command to complete.
timeout = "30s"

# Data format to consume.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/consume/output/

plugins/outputs/exec/exec.go Outdated Show resolved Hide resolved
@glinton glinton added this to the 1.9.0 milestone Oct 4, 2018
[[outputs.exec]]
# Shell/commands array
# Full command line to executable with parameters, or a glob pattern to run all matching files.
commands = ["/usr/local/bin/telegraf-output --config /etc/telegraf-output.conf"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should only support a single command, having more than one in a single plugin will be problematic with the way metrics are buffered for outputs and it doesn't seem like something that needs done very frequently.

Also breaking from the way the exec input was done we should take the arguments for the single command as an array, to avoid issues with quoting and escaping which is problematic across platforms.

@russorat russorat modified the milestones: 1.9.0, 1.10 Oct 29, 2018
@glinton
Copy link
Contributor

glinton commented Oct 29, 2018

@Jaeyo can you address that last bit, to just allow a single command instead of a list. thanks!

@russorat russorat modified the milestones: 1.10.0, 1.11.0 Jan 14, 2019
@Jaeyo
Copy link
Contributor Author

Jaeyo commented Feb 2, 2019

@glinton @danielnelson sorry for late! support only a single command applied.

@lahsivjar
Copy link

@glinton @danielnelson : Are there any blockers for merging this PR?

@@ -0,0 +1,35 @@
package errchan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used anymore, I think we can remove this file.

`

type Exec struct {
Command string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think this should be an array:

command = ["echo", "howdy"]

This should be less problematic than using shellquote.Split, especially for those on Windows.

if err := internal.RunTimeout(cmd, e.Timeout.Duration); err != nil {
s := stderr.String()
if s != "" {
log.Printf("D! Command error: %q\n", s)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we should return an generic error, potentially with the exit code. Maybe internal.ExitStatus(err) will be useful.

return nil
}

func (e *Exec) ProcessCommand(command string, buffer bytes.Buffer) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where this is called, can it be removed?

@danielnelson danielnelson modified the milestones: 1.11.0, 1.12.0 May 24, 2019
@danielnelson danielnelson modified the milestones: 1.12.0, 1.13.0 Aug 12, 2019
@glinton
Copy link
Contributor

glinton commented Aug 14, 2019

@Jaeyo how likely is it you could address the feedback this week?

@glinton glinton mentioned this pull request Aug 15, 2019
@glinton
Copy link
Contributor

glinton commented Aug 15, 2019

We'll pick this up and push it through as there is internal desire for this to make it into the 1.12 release. Thanks for the great start Jaeyo!

@Jaeyo
Copy link
Contributor Author

Jaeyo commented Aug 20, 2019

@glinton sorry for checking late and didn't finishing it. i was busy for other stuff. just feel free to pick this PR.

@danielnelson
Copy link
Contributor

Continued on #6267

@russorat russorat removed this from the 1.13.0 milestone Aug 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add exec plugin as output
5 participants