Skip to content
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

handle platforms that don't support show system buffers command #239

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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