fear: Implement 'mc support top net' (#17598)

This commit is contained in:
jiuker
2023-07-14 02:41:19 +08:00
committed by GitHub
parent fc6d873758
commit 183428db03
6 changed files with 85 additions and 3 deletions

View File

@@ -23,6 +23,7 @@ import (
"github.com/minio/madmin-go/v3"
"github.com/minio/minio/internal/disk"
"github.com/minio/minio/internal/net"
)
type collectMetricsOpts struct {
@@ -69,6 +70,18 @@ func collectLocalMetrics(types madmin.MetricType, opts collectMetricsOpts) (m ma
if types.Contains(madmin.MetricsSiteResync) {
m.Aggregated.SiteResync = globalSiteResyncMetrics.report(opts.depID)
}
if types.Contains(madmin.MetricNet) {
m.Aggregated.Net = &madmin.NetMetrics{
CollectedAt: UTCNow(),
InterfaceName: globalInternodeInterface,
}
netStats, err := net.GetInterfaceNetStats(globalInternodeInterface)
if err != nil {
m.Errors = append(m.Errors, err.Error())
} else {
m.Aggregated.Net.NetStats = netStats
}
}
// Add types...
// ByHost is a shallow reference, so careful about sharing.