From 5df7b0eb48a84091b3d8ab37ce053ac043f0e0e9 Mon Sep 17 00:00:00 2001 From: Holger Obermaier <40787752+ho-ob@users.noreply.github.com> Date: Wed, 4 Feb 2026 14:39:44 +0100 Subject: [PATCH] Fix Error return value of is not checked (errcheck) --- collectors/customCmdMetric.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/collectors/customCmdMetric.go b/collectors/customCmdMetric.go index 8e250bc..a46852c 100644 --- a/collectors/customCmdMetric.go +++ b/collectors/customCmdMetric.go @@ -52,8 +52,11 @@ func (m *CustomCmdCollector) Init(config json.RawMessage) error { m.setup() for _, c := range m.config.Commands { cmdfields := strings.Fields(c) - command := exec.Command(cmdfields[0], strings.Join(cmdfields[1:], " ")) - command.Wait() + command := exec.Command(cmdfields[0], cmdfields[1:]...) + if err := command.Wait(); err != nil { + log.Print(err) + continue + } _, err = command.Output() if err == nil { m.commands = append(m.commands, c) @@ -88,8 +91,11 @@ func (m *CustomCmdCollector) Read(interval time.Duration, output chan lp.CCMessa } for _, cmd := range m.commands { cmdfields := strings.Fields(cmd) - command := exec.Command(cmdfields[0], strings.Join(cmdfields[1:], " ")) - command.Wait() + command := exec.Command(cmdfields[0], cmdfields[1:]...) + if err := command.Wait(); err != nil { + log.Print(err) + continue + } stdout, err := command.Output() if err != nil { log.Print(err)