-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add exec output plugin #4776
Conversation
There was a problem hiding this 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. |
There was a problem hiding this comment.
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/README.md
Outdated
[[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"] |
There was a problem hiding this comment.
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.
@Jaeyo can you address that last bit, to just allow a single command instead of a list. thanks! |
@glinton @danielnelson sorry for late! |
@glinton @danielnelson : Are there any blockers for merging this PR? |
@@ -0,0 +1,35 @@ | |||
package errchan |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
@Jaeyo how likely is it you could address the feedback this week? |
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! |
@glinton sorry for checking late and didn't finishing it. i was busy for other stuff. just feel free to pick this PR. |
Continued on #6267 |
Required for all PRs:
Inherit #1999
Close #544
Relates to #1717