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

scanner-status: Support both old & new scanner metrics #4683

Merged
merged 3 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
58 changes: 32 additions & 26 deletions cmd/admin-scanner-status.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,37 +305,43 @@ func (m *scannerMetricsUI) View() string {

title := metricsTitle
ui := metricsUint64
const wantCycles = 16
addRow("")
if len(sc.CyclesCompletedAt) < 2 {
addRow("Last full scan time: Unknown (not enough data)")

if sc.CurrentCycle == 0 && sc.CurrentStarted.IsZero() && sc.CyclesCompletedAt == nil {
addRowF(" "+title("Scanning:")+" %d bucket(s)", sc.OngoingBuckets)
} else {
addRow("Overall Statistics")
addRow("------------------")
sort.Slice(sc.CyclesCompletedAt, func(i, j int) bool {
return sc.CyclesCompletedAt[i].After(sc.CyclesCompletedAt[j])
})
if len(sc.CyclesCompletedAt) >= wantCycles {
sinceLast := sc.CyclesCompletedAt[0].Sub(sc.CyclesCompletedAt[wantCycles-1])
perMonth := float64(30*24*time.Hour) / float64(sinceLast)
cycleTime := console.Colorize("metrics-number", fmt.Sprintf("%dd%dh%dm", int(sinceLast.Hours()/24), int(sinceLast.Hours())%24, int(sinceLast.Minutes())%60))
perms := console.Colorize("metrics-number", fmt.Sprintf("%.02f", perMonth))
addRowF(title("Last full scan time:")+" %s; Estimated %s/month", cycleTime, perms)
const wantCycles = 16
if len(sc.CyclesCompletedAt) < 2 {
addRow("Last full scan time: Unknown (not enough data)")
} else {
sinceLast := sc.CyclesCompletedAt[0].Sub(sc.CyclesCompletedAt[1]) * time.Duration(wantCycles)
perMonth := float64(30*24*time.Hour) / float64(sinceLast)
cycleTime := console.Colorize("metrics-number", fmt.Sprintf("%dd%dh%dm", int(sinceLast.Hours()/24), int(sinceLast.Hours())%24, int(sinceLast.Minutes())%60))
perms := console.Colorize("metrics-number", fmt.Sprintf("%.02f", perMonth))
addRowF(title("Est. full scan time:")+" %s; Estimated %s/month", cycleTime, perms)
addRow("Overall Statistics")
addRow("------------------")
sort.Slice(sc.CyclesCompletedAt, func(i, j int) bool {
return sc.CyclesCompletedAt[i].After(sc.CyclesCompletedAt[j])
})
if len(sc.CyclesCompletedAt) >= wantCycles {
sinceLast := sc.CyclesCompletedAt[0].Sub(sc.CyclesCompletedAt[wantCycles-1])
perMonth := float64(30*24*time.Hour) / float64(sinceLast)
cycleTime := console.Colorize("metrics-number", fmt.Sprintf("%dd%dh%dm", int(sinceLast.Hours()/24), int(sinceLast.Hours())%24, int(sinceLast.Minutes())%60))
perms := console.Colorize("metrics-number", fmt.Sprintf("%.02f", perMonth))
addRowF(title("Last full scan time:")+" %s; Estimated %s/month", cycleTime, perms)
} else {
sinceLast := sc.CyclesCompletedAt[0].Sub(sc.CyclesCompletedAt[1]) * time.Duration(wantCycles)
perMonth := float64(30*24*time.Hour) / float64(sinceLast)
cycleTime := console.Colorize("metrics-number", fmt.Sprintf("%dd%dh%dm", int(sinceLast.Hours()/24), int(sinceLast.Hours())%24, int(sinceLast.Minutes())%60))
perms := console.Colorize("metrics-number", fmt.Sprintf("%.02f", perMonth))
addRowF(title("Est. full scan time:")+" %s; Estimated %s/month", cycleTime, perms)
}
}
if sc.CurrentCycle > 0 {
addRowF(title("Current cycle:")+" %s; Started: %v", ui(sc.CurrentCycle), console.Colorize("metrics-date", sc.CurrentStarted))
} else {
addRowF(title("Current cycle:") + " (between cycles)")
}
}
if sc.CurrentCycle > 0 {
addRowF(title("Current cycle:")+" %s; Started: %v", ui(sc.CurrentCycle), console.Colorize("metrics-date", sc.CurrentStarted))
addRowF(title("Active drives:")+" %s", ui(uint64(len(sc.ActivePaths))))
} else {
addRowF(title("Current cycle:") + " (between cycles)")
addRowF(title("Active drives:")+" %s", ui(uint64(len(sc.ActivePaths))))
}

addRowF(title("Active drives:")+" %s", ui(uint64(len(sc.ActivePaths))))

getRate := func(x madmin.TimedAction) string {
if x.AccTime > 0 {
return fmt.Sprintf("; Rate: %v/day", ui(uint64(float64(24*time.Hour)/(float64(time.Minute)/float64(x.Count)))))
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/minio/cli v1.24.2
github.com/minio/colorjson v1.0.8
github.com/minio/filepath v1.0.0
github.com/minio/madmin-go/v3 v3.0.64
github.com/minio/madmin-go/v3 v3.0.65
github.com/minio/minio-go/v7 v7.0.76
github.com/minio/pkg/v3 v3.0.13
github.com/minio/selfupdate v0.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ github.com/minio/colorjson v1.0.8 h1:AS6gEQ1dTRYHmC4xuoodPDRILHP/9Wz5wYUGDQfPLpg
github.com/minio/colorjson v1.0.8/go.mod h1:wrs39G/4kqNlGjwqHvPlAnXuc2tlPszo6JKdSBCLN8w=
github.com/minio/filepath v1.0.0 h1:fvkJu1+6X+ECRA6G3+JJETj4QeAYO9sV43I79H8ubDY=
github.com/minio/filepath v1.0.0/go.mod h1:/nRZA2ldl5z6jT9/KQuvZcQlxZIMQoFFQPvEXx9T/Bw=
github.com/minio/madmin-go/v3 v3.0.64 h1:Btwgs3CrgSciVaCWv/3clOxuDdUzylo/oTQp0M8GkwE=
github.com/minio/madmin-go/v3 v3.0.64/go.mod h1:IFAwr0XMrdsLovxAdCcuq/eoL4nRuMVQQv0iubJANQw=
github.com/minio/madmin-go/v3 v3.0.65 h1:5Vp04vyI39xLe+aAAvMm8XGjNvHWIFWTl1isFdCZcoE=
github.com/minio/madmin-go/v3 v3.0.65/go.mod h1:IFAwr0XMrdsLovxAdCcuq/eoL4nRuMVQQv0iubJANQw=
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
github.com/minio/minio-go/v7 v7.0.76 h1:9nxHH2XDai61cT/EFhyIw/wW4vJfpPNvl7lSFpRt+Ng=
Expand Down
Loading