avoid calling 'admin info' for disk, cpu, net metrics collection (#19762)

resource metrics collection was incorrectly making fan-out
liveness peer calls where it's not needed.
This commit is contained in:
Harshavardhana 2024-05-17 08:15:13 -07:00 committed by GitHub
parent 08d74819b6
commit e432e79324
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -280,14 +280,8 @@ func collectDriveMetrics(m madmin.RealtimeMetrics) {
func collectLocalResourceMetrics() {
var types madmin.MetricType = madmin.MetricsDisk | madmin.MetricNet | madmin.MetricsMem | madmin.MetricsCPU
m := collectLocalMetrics(types, collectMetricsOpts{
hosts: map[string]struct{}{
globalLocalNodeName: {},
},
})
for host, hm := range m.ByHost {
if len(host) > 0 {
m := collectLocalMetrics(types, collectMetricsOpts{})
for _, hm := range m.ByHost {
if hm.Net != nil && len(hm.Net.NetStats.Name) > 0 {
stats := hm.Net.NetStats
labels := map[string]string{"interface": stats.Name}
@ -344,18 +338,12 @@ func collectLocalResourceMetrics() {
}
break // only one host expected
}
}
collectDriveMetrics(m)
}
func initLatestValues() {
m := collectLocalMetrics(madmin.MetricsDisk, collectMetricsOpts{
hosts: map[string]struct{}{
globalLocalNodeName: {},
},
})
m := collectLocalMetrics(madmin.MetricsDisk, collectMetricsOpts{})
latestDriveStatsMu.Lock()
latestDriveStats = map[string]madmin.DiskIOStats{}
for d, dm := range m.ByDisk {