Skip to content

Commit

Permalink
Merge pull request #239 from matejv/system-fix
Browse files Browse the repository at this point in the history
handle platforms that don't support show system buffers command
  • Loading branch information
czerwonk authored Jan 17, 2024
2 parents 8fe983e + f21b24f commit 143e797
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/features/system/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
package system

import (
"encoding/xml"
"fmt"
log "github.com/sirupsen/logrus"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -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 <command>: buffers\n" {
log.Debugf("system doesn't support system buffers command")
return nil
}

return xml.Unmarshal(b, &r)
})

if err != nil {
return err
}
Expand Down

0 comments on commit 143e797

Please sign in to comment.