From f21b24f293bbdc318a93b3b58d09616cfc2a8eb1 Mon Sep 17 00:00:00 2001 From: Matej Vadnjal Date: Wed, 17 Jan 2024 08:01:28 +0100 Subject: [PATCH] handle platforms that don't support show system buffers command --- pkg/features/system/collector.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/features/system/collector.go b/pkg/features/system/collector.go index 3cc5f0fe..02d29e58 100644 --- a/pkg/features/system/collector.go +++ b/pkg/features/system/collector.go @@ -3,7 +3,9 @@ package system import ( + "encoding/xml" "fmt" + log "github.com/sirupsen/logrus" "regexp" "strconv" "strings" @@ -187,7 +189,16 @@ func (c *systemCollector) CollectSystem(client collector.Client, ch chan<- prome func (c *systemCollector) collectBuffers(client collector.Client, ch chan<- prometheus.Metric, labelValues []string) error { r := &buffers{} - err := client.RunCommandAndParse("show system buffers", r) + + err := client.RunCommandAndParseWithParser("show system buffers", func(b []byte) error { + if string(b[:]) == "\nerror: syntax error, expecting : buffers\n" { + log.Debugf("system doesn't support system buffers command") + return nil + } + + return xml.Unmarshal(b, &r) + }) + if err != nil { return err }