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

updates to s3260m5 for fwver 4.2(xx) #18

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
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
35 changes: 27 additions & 8 deletions cisco/s3260m5/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"go.uber.org/zap"

"github.com/hashicorp/go-retryablehttp"
"github.com/hashicorp/go-version"
"github.com/prometheus/client_golang/prometheus"
)

Expand Down Expand Up @@ -139,17 +140,17 @@ func NewExporter(ctx context.Context, target, uri string) (*Exporter, error) {
mgr = mgrEndpoints.Links.ServerManager[0].URL
}

// chassis BIOS version
biosVer, err := getBIOSVersion(fqdn.String()+mgr, target, retryClient)
// BMC Firmware major.minor
bmcFwTrim, err := version.NewVersion(mgrEndpoints.FirmwareVersion[:strings.Index(mgrEndpoints.FirmwareVersion, "(")])
if err != nil {
log.Error("error when getting BIOS version from "+S3260M5, zap.Error(err), zap.Any("trace_id", ctx.Value("traceID")))
log.Error("error when trimming BMC FW version from "+S3260M5, zap.Error(err), zap.Any("trace_id", ctx.Value("traceID")))
return nil, err
}

// chassis serial number
chassisSN, err := getChassisSerialNumber(fqdn.String()+uri+"/Chassis/CMC", target, retryClient)
// chassis BIOS version
biosVer, err := getBIOSVersion(fqdn.String()+mgr, target, retryClient)
if err != nil {
log.Error("error when getting chassis serial number from "+S3260M5, zap.Error(err), zap.Any("trace_id", ctx.Value("traceID")))
log.Error("error when getting BIOS version from "+S3260M5, zap.Error(err), zap.Any("trace_id", ctx.Value("traceID")))
return nil, err
}

Expand All @@ -167,6 +168,13 @@ func NewExporter(ctx context.Context, target, uri string) (*Exporter, error) {
return nil, err
}

// chassis serial number
chassisSN, err := getChassisSerialNumber(fqdn.String()+chass.Members[0].URL, target, retryClient)
if err != nil {
log.Error("error when getting chassis serial number from "+S3260M5, zap.Error(err), zap.Any("trace_id", ctx.Value("traceID")))
return nil, err
}

serial := path.Base(mgr)

tasks = append(tasks,
Expand All @@ -175,8 +183,17 @@ func NewExporter(ctx context.Context, target, uri string) (*Exporter, error) {
for _, ch := range chass.Members {
tasks = append(tasks,
pool.NewTask(common.Fetch(fqdn.String()+ch.URL+"/Thermal", THERMAL, target, retryClient)),
pool.NewTask(common.Fetch(fqdn.String()+ch.URL+"/Power", POWER, target, retryClient)),
)
constraints, _ := version.NewConstraint(">= 4.2")
if constraints.Check(bmcFwTrim) && !strings.Contains(ch.URL, "Server1") {
tasks = append(tasks,
pool.NewTask(common.Fetch(fqdn.String()+ch.URL+"/Power", POWER, target, retryClient)),
)
} else if !constraints.Check(bmcFwTrim) {
tasks = append(tasks,
pool.NewTask(common.Fetch(fqdn.String()+ch.URL+"/Power", POWER, target, retryClient)),
)
}
}

tasks = append(tasks,
Expand Down Expand Up @@ -442,7 +459,9 @@ func (e *Exporter) exportMemoryMetrics(body []byte) error {
}

if mm.Status.State != "" {
if mm.Status.State == "Enabled" && mm.Status.Health == "OK" {
if mm.Status.State == "Absent" {
return nil
} else if mm.Status.State == "Enabled" && mm.Status.Health == "OK" {
state = OK
} else {
state = BAD
Expand Down
2 changes: 1 addition & 1 deletion cisco/s3260m5/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func NewDeviceMetrics() *map[string]*metrics {
}

DeviceMetrics = &metrics{
"deviceInfo": newServerMetric("device_info", "Current snapshot of device firmware information", nil, []string{"name", "chassisSerialNumber", "firmwareVersion", "biosVersion", "model"}),
"deviceInfo": newServerMetric("device_info", "Current snapshot of device firmware information", nil, []string{"description", "chassisSerialNumber", "firmwareVersion", "biosVersion", "model"}),
}

Metrics = &map[string]*metrics{
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0
github.com/hashicorp/go-retryablehttp v0.7.2
github.com/hashicorp/go-version v1.6.0
github.com/hashicorp/vault/api v1.9.0
github.com/hashicorp/vault/api/auth/approle v0.4.0
github.com/prometheus/client_golang v1.14.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 h1:kes8mmyCpxJsI7FTwtzRqEy9
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2/go.mod h1:Gou2R9+il93BqX25LAKCLuM+y9U2T4hlwvT1yprcna4=
github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc=
github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A=
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/vault/api v1.9.0 h1:ab7dI6W8DuCY7yCU8blo0UCYl2oHre/dloCmzMWg9w8=
Expand Down
45 changes: 45 additions & 0 deletions vendor/github.com/hashicorp/go-version/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading