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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
59 changes: 32 additions & 27 deletions cmd/admin-scanner-status.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,37 +259,42 @@ 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 {
addRow(fmt.Sprintf("Scanning: %d bucket(s)", sc.BucketsScanInfo.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
addRow("")
if len(sc.CyclesCompletedAt) < 2 {
addRow("Last full scan time: Unknown (not enough data)")
} 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)
} 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))
addRowF(title("Active drives:")+" %s", ui(uint64(len(sc.ActivePaths))))
} 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)
addRowF(title("Current cycle:") + " (between cycles)")
addRowF(title("Active drives:")+" %s", ui(uint64(len(sc.ActivePaths))))
}
}
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))))
}
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
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ require (
github.com/kr/pretty v0.3.1 // indirect
github.com/minio/mux v1.9.0 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/safchain/ethtool v0.3.0 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb // indirect
Expand Down Expand Up @@ -130,3 +129,5 @@ require (
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
)

replace github.com/minio/madmin-go/v3 => ../madmin-go
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ github.com/minio/colorjson v1.0.6 h1:m7TUvpvt0u7FBmVIEQNIa0T4NBQlxrcMBp4wJKsg2Ik
github.com/minio/colorjson v1.0.6/go.mod h1:LUXwS5ZGNb6Eh9f+t+3uJiowD3XsIWtsvTriUBeqgYs=
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.29 h1:3bNLArtxIFud5wyb5/DnF5DGLBvcSJyzCA44EclX1Ow=
github.com/minio/madmin-go/v3 v3.0.29/go.mod h1:4QN2NftLSV7MdlT50dkrenOMmNVHluxTvlqJou3hte8=
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.63 h1:GbZ2oCvaUdgT5640WJOpyDhhDxvknAJU2/T3yurwcbQ=
Expand Down Expand Up @@ -212,8 +210,6 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/safchain/ethtool v0.3.0 h1:gimQJpsI6sc1yIqP/y8GYgiXn/NjgvpM0RNoWLVVmP0=
github.com/safchain/ethtool v0.3.0/go.mod h1:SA9BwrgyAqNo7M+uaL6IYbxpm5wk3L7Mm6ocLW+CJUs=
github.com/secure-io/sio-go v0.3.1 h1:dNvY9awjabXTYGsTF1PiCySl9Ltofk9GA3VdWlo7rRc=
github.com/secure-io/sio-go v0.3.1/go.mod h1:+xbkjDzPjwh4Axd07pRKSNriS9SCiYksWnZqdnfpQxs=
github.com/shirou/gopsutil/v3 v3.23.8 h1:xnATPiybo6GgdRoC4YoGnxXZFRc3dqQTGi73oLvvBrE=
Expand Down Expand Up @@ -249,6 +245,8 @@ github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFA
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
github.com/vadmeste/madmin-go/v3 v3.0.0-20230919003258-5eabada517d6 h1:DycujiwCbyVfar13inhIYCsE4++ly2oIfNd9RtONnMk=
github.com/vadmeste/madmin-go/v3 v3.0.0-20230919003258-5eabada517d6/go.mod h1:B2EgtEGrfWx+AkXv+OAcS6IHwoIJcd1p75QfDPSPd6Q=
github.com/vbauerster/mpb/v8 v8.6.2 h1:9EhnJGQRtvgDVCychJgR96EDCOqgg2NsMuk5JUcX4DA=
github.com/vbauerster/mpb/v8 v8.6.2/go.mod h1:oVJ7T+dib99kZ/VBjoBaC8aPXiSAihnzuKmotuihyFo=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down