diff options
Diffstat (limited to '')
-rw-r--r-- | src/go/plugin/go.d/modules/postfix/exec.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/go/plugin/go.d/modules/postfix/exec.go b/src/go/plugin/go.d/modules/postfix/exec.go new file mode 100644 index 000000000..1ca29331a --- /dev/null +++ b/src/go/plugin/go.d/modules/postfix/exec.go @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +package postfix + +import ( + "context" + "fmt" + "os/exec" + "time" + + "github.com/netdata/netdata/go/plugins/logger" +) + +func newPostqueueExec(binPath string, timeout time.Duration) *postqueueExec { + return &postqueueExec{ + binPath: binPath, + timeout: timeout, + } +} + +type postqueueExec struct { + *logger.Logger + + binPath string + timeout time.Duration +} + +func (p *postqueueExec) list() ([]byte, error) { + ctx, cancel := context.WithTimeout(context.Background(), p.timeout) + defer cancel() + + cmd := exec.CommandContext(ctx, p.binPath, "-p") + p.Debugf("executing '%s'", cmd) + + bs, err := cmd.Output() + if err != nil { + return nil, fmt.Errorf("error on '%s': %v", cmd, err) + } + + return bs, nil +} |