@cryptotaxi247 / netdata / commits / 7f5702ce8

improve(go.d/ddsnmp): add composite metrics for CPU & Load Average in std-ucd-mib (#20964)

Ilya Mashchenko committed Sep 12, 2025 at 14:23 UTC 7f5702ce841a01a31d68205a81848bbaa338a583
7 files changed +110 -112
src/go/plugin/go.d/collector/snmp/charts.go
+2 -1
@@ -318,6 +318,7 @@ func (c *Collector) addProfileScalarMetricChart(m ddsnmp.Metric) {
318 chart := &module.Chart{
319 ID: fmt.Sprintf("snmp_device_prof_%s", cleanMetricName.Replace(m.Name)),
320 Title: m.Description,
321 + Type: module.ChartType(m.ChartType),
322 Units: m.Unit,
323 Fam: m.Family,
324 Ctx: fmt.Sprintf("snmp.device_prof_%s", cleanMetricName.Replace(m.Name)),
@@ -352,7 +353,7 @@ func (c *Collector) addProfileScalarMetricChart(m ddsnmp.Metric) {
353 if !seen[k] {
354 seen[k] = true
355 id := fmt.Sprintf("snmp_device_prof_%s_%s", m.Name, k)
355 - chart.Dims = append(chart.Dims, &module.Dim{ID: id, Name: k, Algo: module.Absolute})
356 + chart.Dims = append(chart.Dims, &module.Dim{ID: id, Name: k, Algo: dimAlgoFromDdSnmpType(m)})
357 }
358 }
359 } else {
src/go/plugin/go.d/collector/snmp/ddsnmp/ddprofiledefinition/metrics.go
+1
@@ -92,6 +92,7 @@ type ChartMeta struct {
92 Description string `yaml:"description,omitempty" json:"description,omitempty"`
93 Family string `yaml:"family,omitempty" json:"family,omitempty"`
94 Unit string `yaml:"unit,omitempty" json:"unit,omitempty"`
95 + Type string `yaml:"type,omitempty" json:"type,omitempty"`
96 }
97
98 // Clone creates a duplicate of this SymbolConfig
src/go/plugin/go.d/collector/snmp/ddsnmp/ddsnmpcollector/collector.go
+2
@@ -104,6 +104,8 @@ func (c *Collector) Collect() ([]*ddsnmp.ProfileMetrics, error) {
104 for i := range vmetrics {
105 vmetrics[i].Profile = pm
106 }
107 +
108 + pm.Metrics = slices.DeleteFunc(pm.Metrics, func(m ddsnmp.Metric) bool { return strings.HasPrefix(m.Name, "_") })
109 pm.Metrics = append(pm.Metrics, vmetrics...)
110 }
111 }
src/go/plugin/go.d/collector/snmp/ddsnmp/ddsnmpcollector/collector_vmetrics.go
+1
@@ -121,6 +121,7 @@ func (p *vmetricsCollector) Collect(profDef *ddprofiledefinition.ProfileDefiniti
121 Description: agg.config.ChartMeta.Description,
122 Family: agg.config.ChartMeta.Family,
123 Unit: agg.config.ChartMeta.Unit,
124 + ChartType: agg.config.ChartMeta.Type,
125 MetricType: agg.metricType,
126 }
127
src/go/plugin/go.d/collector/snmp/ddsnmp/ddsnmpcollector/metric_builder.go
+1
@@ -52,6 +52,7 @@ func (mb *metricBuilder) fromSymbol(sym ddprofiledefinition.SymbolConfig, pdu go
52 mb.metric.Unit = sym.ChartMeta.Unit
53 mb.metric.Description = sym.ChartMeta.Description
54 mb.metric.Family = sym.ChartMeta.Family
55 + mb.metric.ChartType = sym.ChartMeta.Type
56 mb.metric.MetricType = ternary(sym.MetricType != "", sym.MetricType, getMetricTypeFromPDUType(pdu))
57 mb.metric.MultiValue = buildMultiValue(mb.metric.Value, sym.Mapping)
58 return mb
src/go/plugin/go.d/collector/snmp/ddsnmp/metric.go
+1
@@ -17,6 +17,7 @@ type Metric struct {
17 Description string
18 Family string
19 Unit string
20 + ChartType string
21 MetricType ddprofiledefinition.ProfileMetricType
22 StaticTags map[string]string
23 Tags map[string]string
src/go/plugin/go.d/config/go.d/snmp.profiles/default/_std-ucd-mib.yaml
+102 -111
@@ -6,33 +6,6 @@
6 # https://github.com/DanielleHuisman/observium-community-edition/blob/main/mibs/net-snmp/UCD-DISKIO-MIB
7
8 metrics:
9 - - MIB: UCD-SNMP-MIB
10 - symbol:
11 - name: ucd.cpuLoad1m
12 - OID: 1.3.6.1.4.1.2021.10.1.5.1
13 - chart_meta:
14 - family: 'System/LoadAverage/1Min'
15 - description: 1 minute load average
16 - unit: "{load_average}"
17 - scale_factor: 0.01
18 - - MIB: UCD-SNMP-MIB
19 - symbol:
20 - name: ucd.cpuLoad5m
21 - OID: 1.3.6.1.4.1.2021.10.1.5.2
22 - chart_meta:
23 - family: 'System/LoadAverage/5Min'
24 - description: 5 minute load average
25 - unit: "{load_average}"
26 - scale_factor: 0.01
27 - - MIB: UCD-SNMP-MIB
28 - symbol:
29 - name: ucd.cpuLoad15m
30 - OID: 1.3.6.1.4.1.2021.10.1.5.3
31 - chart_meta:
32 - family: 'System/LoadAverage/15Min'
33 - description: 15 minute load average
34 - unit: "{load_average}"
35 - scale_factor: 0.01
9 - MIB: UCD-SNMP-MIB
10 symbol:
11 name: ucd.memoryTotal
@@ -283,87 +256,105 @@ metrics:
256 unit: "By/s"
257 scale_factor: 512
258
286 -## TODO: These metrics (e.g., ucd.ssCpuUser, ucd.ssCpuSystem, etc.) represent CPU usage breakdowns (user, system, idle, etc.).
287 -## Typically more useful when visualized together in a single composite CPU usage chart, rather than as separate metrics/charts.
288 -## Displaying them separately can be confusing and less informative for users.
289 -## Next steps: Consider combining these metrics into a single composite CPU usage chart.
290 -# - MIB: UCD-SNMP-MIB
291 -# symbol:
292 -# name: ucd.ssCpuUser
293 -# OID: 1.3.6.1.4.1.2021.11.9.0
294 -# chart_meta:
295 -# family: 'System/CPU/Usage/User'
296 -# description: The percentage of CPU time spent processing user-level code, calculated over the last minute
297 -# unit: "%"
298 -# - MIB: UCD-SNMP-MIB
299 -# symbol:
300 -# name: ucd.ssCpuSystem
301 -# OID: 1.3.6.1.4.1.2021.11.10.0
302 -# chart_meta:
303 -# family: 'System/CPU/Usage/System'
304 -# description: The percentage of CPU time spent processing system-level code, calculated over the last minute
305 -# unit: "%"
306 -# - MIB: UCD-SNMP-MIB
307 -# symbol:
308 -# name: ucd.ssCpuIdle
309 -# OID: 1.3.6.1.4.1.2021.11.11.0
310 -# chart_meta:
311 -# family: 'System/CPU/Usage/Idle'
312 -# description: The percentage of processor time spent idle, calculated over the last minute
313 -# unit: "%"
314 -# - MIB: UCD-SNMP-MIB
315 -# symbol:
316 -# name: ucd.ssCpuRawUser
317 -# OID: 1.3.6.1.4.1.2021.11.50.0
318 -# chart_meta:
319 -# family: 'System/CPU/Time/User'
320 -# description: The number of ticks spent processing user-level code
321 -# unit: "{tick}/s"
322 -# - MIB: UCD-SNMP-MIB
323 -# symbol:
324 -# name: ucd.ssCpuRawNice
325 -# OID: 1.3.6.1.4.1.2021.11.51.0
326 -# chart_meta:
327 -# family: 'System/CPU/Time/Nice'
328 -# description: The number of ticks spent processing reduced-priority code
329 -# unit: "{tick}/s"
330 -# - MIB: UCD-SNMP-MIB
331 -# symbol:
332 -# name: ucd.ssCpuRawSystem
333 -# OID: 1.3.6.1.4.1.2021.11.52.0
334 -# chart_meta:
335 -# family: 'System/CPU/Time/System'
336 -# description: The number of ticks spent processing system-level code
337 -# unit: "{tick}/s"
338 -# - MIB: UCD-SNMP-MIB
339 -# symbol:
340 -# name: ucd.ssCpuRawIdle
341 -# OID: 1.3.6.1.4.1.2021.11.53.0
342 -# chart_meta:
343 -# family: 'System/CPU/Time/Idle'
344 -# description: The number of ticks spent idle
345 -# unit: "{tick}/s"
346 -# - MIB: UCD-SNMP-MIB
347 -# symbol:
348 -# name: ucd.ssCpuRawWait
349 -# OID: 1.3.6.1.4.1.2021.11.54.0
350 -# chart_meta:
351 -# family: 'System/CPU/Time/IOWait'
352 -# description: The number of ticks spent waiting for IO
353 -# unit: "{tick}/s"
354 -# - MIB: UCD-SNMP-MIB
355 -# symbol:
356 -# name: ucd.ssCpuRawKernel
357 -# OID: 1.3.6.1.4.1.2021.11.55.0
358 -# chart_meta:
359 -# family: 'System/CPU/Time/Kernel'
360 -# description: The number of ticks spent processing kernel-level code
361 -# unit: "{tick}/s"
362 -# - MIB: UCD-SNMP-MIB
363 -# symbol:
364 -# name: ucd.ssCpuRawInterrupt
365 -# OID: 1.3.6.1.4.1.2021.11.56.0
366 -# chart_meta:
367 -# family: 'System/CPU/Time/Interrupt'
368 -# description: The number of ticks spent processing hardware interrupts
369 -# unit: "{tick}/s"
259 + - MIB: UCD-SNMP-MIB
260 + symbol:
261 + name: _ucd.cpuLoad1m
262 + OID: 1.3.6.1.4.1.2021.10.1.5.1
263 + scale_factor: 0.01
264 + - MIB: UCD-SNMP-MIB
265 + symbol:
266 + name: _ucd.cpuLoad5m
267 + OID: 1.3.6.1.4.1.2021.10.1.5.2
268 + scale_factor: 0.01
269 + - MIB: UCD-SNMP-MIB
270 + symbol:
271 + name: _ucd.cpuLoad15m
272 + OID: 1.3.6.1.4.1.2021.10.1.5.3
273 + scale_factor: 0.01
274 +
275 + - MIB: UCD-SNMP-MIB
276 + symbol:
277 + name: _ucd.ssCpuRawUser
278 + OID: 1.3.6.1.4.1.2021.11.50.0
279 + - MIB: UCD-SNMP-MIB
280 + symbol:
281 + name: _ucd.ssCpuRawNice
282 + OID: 1.3.6.1.4.1.2021.11.51.0
283 + - MIB: UCD-SNMP-MIB
284 + symbol:
285 + name: _ucd.ssCpuRawSystem
286 + OID: 1.3.6.1.4.1.2021.11.52.0
287 + - MIB: UCD-SNMP-MIB
288 + symbol:
289 + name: _ucd.ssCpuRawIdle
290 + OID: 1.3.6.1.4.1.2021.11.53.0
291 + - MIB: UCD-SNMP-MIB
292 + symbol:
293 + name: _ucd.ssCpuRawWait
294 + OID: 1.3.6.1.4.1.2021.11.54.0
295 + - MIB: UCD-SNMP-MIB
296 + symbol:
297 + name: _ucd.ssCpuRawKernel
298 + OID: 1.3.6.1.4.1.2021.11.55.0
299 + - MIB: UCD-SNMP-MIB
300 + symbol:
301 + name: _ucd.ssCpuRawInterrupt
302 + OID: 1.3.6.1.4.1.2021.11.56.0
303 + - MIB: UCD-SNMP-MIB
304 + symbol:
305 + name: _ucd.ssCpuRawSoftIRQ
306 + OID: 1.3.6.1.4.1.2021.11.61.0
307 + - MIB: UCD-SNMP-MIB
308 + symbol:
309 + name: _ucd.ssCpuRawSteal
310 + OID: 1.3.6.1.4.1.2021.11.64.0
311 + - MIB: UCD-SNMP-MIB
312 + symbol:
313 + name: _ucd.ssCpuRawGuest
314 + OID: 1.3.6.1.4.1.2021.11.65.0
315 + - MIB: UCD-SNMP-MIB
316 + symbol:
317 + name: _ucd.ssCpuRawGuestNice
318 + OID: 1.3.6.1.4.1.2021.11.66.0
319 +
320 +virtual_metrics:
321 + - name: ucd.cpu_usage
322 + chart_meta:
323 + description: CPU usage breakdown
324 + family: "System/CPU/Usage"
325 + unit: "%"
326 + type: stacked
327 + sources:
328 + - metric: _ucd.ssCpuRawUser
329 + as: user
330 + - metric: _ucd.ssCpuRawNice
331 + as: nice
332 + - metric: _ucd.ssCpuRawSystem
333 + as: system
334 + - metric: _ucd.ssCpuRawKernel
335 + as: kernel
336 + - metric: _ucd.ssCpuRawWait
337 + as: iowait
338 + - metric: _ucd.ssCpuRawInterrupt
339 + as: irq
340 + - metric: _ucd.ssCpuRawSoftIRQ
341 + as: softirq
342 + - metric: _ucd.ssCpuRawSteal
343 + as: steal
344 + - metric: _ucd.ssCpuRawGuest
345 + as: guest
346 + - metric: _ucd.ssCpuRawGuestNice
347 + as: guest_nice
348 +
349 + - name: ucd.cpuLoad
350 + chart_meta:
351 + description: Load average
352 + family: "System/LoadAverage"
353 + unit: "{load_average}"
354 + sources:
355 + - metric: _ucd.cpuLoad1m
356 + as: "1m"
357 + - metric: _ucd.cpuLoad5m
358 + as: "5m"
359 + - metric: _ucd.cpuLoad15m
360 + as: "15m"