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

misc fixes #12

Merged
merged 2 commits into from
Aug 5, 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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ $ make image-build
## Query metrics

When running (by privileged user) along-side active SMB server, `smbmetrics`
exports a set of gauge metrics over HTTP via port `8080`. Most metrics become
exports a set of gauge metrics over HTTP via port `9922`. Most metrics become
visible only when active SMB connections exists. Execute the folowing `curl`
command on the same machine where you run `smbmetrics` instance:

```console
$ curl --request GET "http://localhost:8080/metrics"
$ curl --request GET "http://localhost:9922/metrics"
```

## Exported metrics
Expand All @@ -45,7 +45,7 @@ The following example is from a setup with 2 shares and 2 users connected and
performing SMB file-system operations from 4 different machines:

```console
$ curl --request GET "http://localhost:8080/metrics"
$ curl --request GET "http://localhost:9922/metrics"

# HELP smb_metrics_status Current metrics-collector status versions
# TYPE smb_metrics_status gauge
Expand Down
20 changes: 6 additions & 14 deletions internal/metrics/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package metrics

import (
"context"
"errors"
)

var (
Expand All @@ -26,26 +27,17 @@ func UpdateDefaultVersions(version, commitid string) {

// ResolveVersions is a best-effort to resolve current pod's versions info
func ResolveVersions(clnt *kclient) (Versions, error) {
var err error
var imgErr, smbVersErr, ctdbVersErr error
vers := Versions{
Version: defaultVersions.Version,
CommitID: defaultVersions.CommitID,
}
if clnt != nil {
vers.SambaImage, err = resolveSambaImage(clnt)
if err != nil {
return vers, err
}
}
vers.SambaVersion, err = resolveSambaVersion()
if err != nil {
return vers, err
}
vers.CtdbVersion, err = resolveCtdbVersion()
if err != nil {
return vers, err
vers.SambaImage, imgErr = resolveSambaImage(clnt)
}
return vers, nil
vers.SambaVersion, smbVersErr = resolveSambaVersion()
vers.CtdbVersion, ctdbVersErr = resolveCtdbVersion()
return vers, errors.Join(imgErr, smbVersErr, ctdbVersErr)
}

func resolveSambaImage(clnt *kclient) (string, error) {
Expand Down
Loading