@cryptotaxi247 / netdata-1 / commits / 785c97f3f

chore(go.d/snmp): add ifTypeGroup mapping for interface type categorization (#21605)

Ilya Mashchenko committed Jan 22, 2026 at 01:37 UTC 785c97f3f57f2a22cbd7a8eaff325cf789ada4a2
5 files changed +424 -2
src/go/plugin/go.d/collector/snmp/ddsnmp/profile.go
+4 -1
@@ -310,8 +310,11 @@ func enrichProfiles(profiles []*Profile) {
310 continue
311 }
312
313 - if tagCfg.MappingRef == "ifType" {
313 + switch tagCfg.MappingRef {
314 + case "ifType":
315 tagCfg.Mapping = sharedMappings.ifType
316 + case "ifTypeGroup":
317 + tagCfg.Mapping = sharedMappings.ifTypeGroup
318 }
319 }
320 }
src/go/plugin/go.d/collector/snmp/ddsnmp/shared.go
+340 -1
@@ -3,7 +3,8 @@
3 package ddsnmp
4
5 var sharedMappings = struct {
6 - ifType map[string]string
6 + ifType map[string]string
7 + ifTypeGroup map[string]string
8 }{
9 ifType: map[string]string{
10 "1": "other",
@@ -306,4 +307,342 @@ var sharedMappings = struct {
307 "302": "roe",
308 "303": "p2pOverLan",
309 },
310 + ifTypeGroup: map[string]string{
311 + // Virtual / logical (includes tunnels, VLANs, bridges)
312 + "24": "virtual", // softwareLoopback
313 + "25": "virtual", // eon
314 + "31": "virtual", // sip (SMDS Interface Protocol)
315 + "53": "virtual", // propVirtual
316 + "78": "virtual", // ipSwitch
317 + "109": "virtual", // ipOverCdlc
318 + "110": "virtual", // ipOverClaw
319 + "112": "virtual", // virtualIpAddress
320 + "126": "virtual", // ip
321 + "131": "virtual", // tunnel
322 + "135": "virtual", // l2vlan
323 + "136": "virtual", // l3ipvlan
324 + "137": "virtual", // l3ipxvlan
325 + "142": "virtual", // ipForward
326 + "150": "virtual", // mplsTunnel
327 + "202": "virtual", // virtualTg
328 + "209": "virtual", // bridge
329 + "215": "virtual", // sixToFour
330 + "222": "virtual", // ciscoISLvlan
331 + "246": "virtual", // ifPwType
332 + "258": "virtual", // vmwareVirtualNic
333 + "262": "virtual", // ifVfiType
334 + "272": "virtual", // vmwareNicTeam
335 +
336 + // Aggregation / bonding
337 + "82": "aggregation", // ds0Bundle
338 + "108": "aggregation", // pppMultilinkBundle
339 + "155": "aggregation", // compositeLink
340 + "161": "aggregation", // ieee8023adLag
341 + "163": "aggregation", // frf16MfrBundle
342 + "210": "aggregation", // linegroup
343 + "297": "aggregation", // ieee8021axDrni
344 +
345 + // Ethernet
346 + "6": "ethernet", // ethernetCsmacd
347 + "7": "ethernet", // iso88023Csmacd
348 + "55": "ethernet", // ieee80212
349 + "62": "ethernet", // fastEther
350 + "69": "ethernet", // fastEtherFX
351 + "117": "ethernet", // gigabitEthernet
352 + "233": "ethernet", // aviciOpticalEther
353 + "303": "ethernet", // p2pOverLan
354 +
355 + // Wireless (WiFi, WiMAX, cellular, point-to-point, microwave)
356 + "71": "wireless", // ieee80211
357 + "157": "wireless", // propWirelessP2P
358 + "183": "wireless", // hiperlan2
359 + "188": "wireless", // radioMAC
360 + "216": "wireless", // gtp (GPRS Tunneling Protocol - mobile/cellular)
361 + "237": "wireless", // ieee80216WMAN
362 + "243": "wireless", // wwanPP
363 + "244": "wireless", // wwanPP2
364 + "252": "wireless", // capwapDot11Profile
365 + "253": "wireless", // capwapDot11Bss
366 + "254": "wireless", // capwapWtpVirtualRadio
367 + "281": "wireless", // xboxWireless
368 + "295": "wireless", // microwaveCarrierTermination
369 + "296": "wireless", // microwaveRadioLinkTerminal
370 + "299": "wireless", // ieee19061nanocom
371 + "300": "wireless", // cpri (Common Public Radio Interface - mobile fronthaul)
372 +
373 + // Optical transport (SONET, DWDM, OTN, metro rings)
374 + "39": "optical", // sonet
375 + "50": "optical", // sonetPath
376 + "51": "optical", // sonetVT
377 + "151": "optical", // srp (Spatial Reuse Protocol - SONET rings)
378 + "171": "optical", // pos
379 + "185": "optical", // sonetOverheadChannel
380 + "186": "optical", // digitalWrapperOverheadChannel
381 + "195": "optical", // opticalChannel
382 + "196": "optical", // opticalTransport
383 + "219": "optical", // opticalChannelGroup
384 + "221": "optical", // gfp
385 + "225": "optical", // rpr (Resilient Packet Ring)
386 + "260": "optical", // otnOdu
387 + "261": "optical", // otnOtu
388 + "291": "optical", // otnOtsi
389 + "292": "optical", // otnOtuc
390 + "293": "optical", // otnOduc
391 + "294": "optical", // otnOtsig
392 +
393 + // DSL
394 + "94": "dsl", // adsl
395 + "95": "dsl", // radsl
396 + "96": "dsl", // sdsl
397 + "97": "dsl", // vdsl
398 + "143": "dsl", // msdsl
399 + "154": "dsl", // idsl
400 + "168": "dsl", // hdsl2
401 + "169": "dsl", // shdsl
402 + "192": "dsl", // reachDSL
403 + "230": "dsl", // adsl2
404 + "238": "dsl", // adsl2plus
405 + "251": "dsl", // vdsl2
406 + "263": "dsl", // g9981
407 + "264": "dsl", // g9982
408 + "265": "dsl", // g9983
409 + "279": "dsl", // gfast
410 + "282": "dsl", // fastdsl
411 +
412 + // Cable / DOCSIS / MoCA
413 + "127": "cable", // docsCableMaclayer
414 + "128": "cable", // docsCableDownstream
415 + "129": "cable", // docsCableUpstream
416 + "180": "cable", // propDocsWirelessMaclayer
417 + "181": "cable", // propDocsWirelessDownstream
418 + "182": "cable", // propDocsWirelessUpstream
419 + "205": "cable", // docsCableUpstreamChannel
420 + "228": "cable", // cblVectaStar
421 + "229": "cable", // docsCableMCmtsDownstream
422 + "236": "cable", // mocaVersion1
423 + "256": "cable", // docsCableUpstreamRfPort
424 + "257": "cable", // cableDownstreamRfPort
425 + "277": "cable", // docsOfdmDownstream
426 + "278": "cable", // docsOfdmaUpstream
427 + "283": "cable", // docsCableScte55d1FwdOob
428 + "284": "cable", // docsCableScte55d1RetOob
429 + "285": "cable", // docsCableScte55d2DsOob
430 + "286": "cable", // docsCableScte55d2UsOob
431 + "287": "cable", // docsCableNdf
432 + "288": "cable", // docsCableNdr
433 +
434 + // PON / fiber access
435 + "207": "pon", // pon155
436 + "208": "pon", // pon622
437 + "250": "pon", // gpon
438 + "266": "pon", // aluEpon
439 + "267": "pon", // aluEponOnu
440 + "268": "pon", // aluEponPhysicalUni
441 + "269": "pon", // aluEponLogicalLink
442 + "270": "pon", // aluGponOnu
443 + "271": "pon", // aluGponPhysicalUni
444 +
445 + // MPLS (label switching, traffic engineering)
446 + "166": "mpls", // mpls
447 + "200": "mpls", // teLink (Traffic Engineering)
448 + "227": "mpls", // lmp (Link Management Protocol - GMPLS)
449 +
450 + // Datacenter fabrics (Fibre Channel, InfiniBand)
451 + "56": "datacenter", // fibreChannel
452 + "199": "datacenter", // infiniband
453 + "224": "datacenter", // fcipLink
454 +
455 + // Serial / PPP / HDLC / modem
456 + "16": "serial", // lapb
457 + "17": "serial", // sdlc
458 + "22": "serial", // propPointToPointSerial
459 + "23": "serial", // ppp
460 + "28": "serial", // slip
461 + "33": "serial", // rs232
462 + "45": "serial", // v35
463 + "46": "serial", // hssi
464 + "48": "serial", // modem
465 + "64": "serial", // v11
466 + "65": "serial", // v36
467 + "77": "serial", // lapd
468 + "84": "serial", // async
469 + "88": "serial", // arap
470 + "118": "serial", // hdlc
471 + "119": "serial", // lapf
472 + "120": "serial", // v37
473 + "123": "serial", // transpHdlc
474 + "125": "serial", // fast
475 + "298": "serial", // ax25
476 +
477 + // TDM / voice / telephony
478 + "18": "tdm_voice", // ds1
479 + "19": "tdm_voice", // e1
480 + "20": "tdm_voice", // basicISDN
481 + "21": "tdm_voice", // primaryISDN
482 + "30": "tdm_voice", // ds3
483 + "63": "tdm_voice", // isdn
484 + "66": "tdm_voice", // g703at64k
485 + "67": "tdm_voice", // g703at2mb
486 + "75": "tdm_voice", // isdns
487 + "76": "tdm_voice", // isdnu
488 + "81": "tdm_voice", // ds0
489 + "100": "tdm_voice", // voiceEM
490 + "101": "tdm_voice", // voiceFXO
491 + "102": "tdm_voice", // voiceFXS
492 + "103": "tdm_voice", // voiceEncap
493 + "104": "tdm_voice", // voiceOverIp
494 + "133": "tdm_voice", // ces
495 + "156": "tdm_voice", // ss7SigLink
496 + "164": "tdm_voice", // h323Gatekeeper
497 + "165": "tdm_voice", // h323Proxy
498 + "167": "tdm_voice", // mfSigLink
499 + "170": "tdm_voice", // ds1FDL
500 + "175": "tdm_voice", // nfas
501 + "176": "tdm_voice", // tr008
502 + "177": "tdm_voice", // gr303RDT
503 + "178": "tdm_voice", // gr303IDT
504 + "179": "tdm_voice", // isup
505 + "198": "tdm_voice", // voiceOverCable
506 + "201": "tdm_voice", // q2931
507 + "203": "tdm_voice", // sipTg
508 + "204": "tdm_voice", // sipSig
509 + "211": "tdm_voice", // voiceEMFGD
510 + "212": "tdm_voice", // voiceFGDEANA
511 + "213": "tdm_voice", // voiceDID
512 + "235": "tdm_voice", // voiceFGDOS
513 + "245": "tdm_voice", // voiceEBS
514 +
515 + // ATM
516 + "37": "atm", // atm
517 + "49": "atm", // aal5
518 + "80": "atm", // atmLogical
519 + "105": "atm", // atmDxi
520 + "106": "atm", // atmFuni
521 + "107": "atm", // atmIma
522 + "114": "atm", // ipOverAtm
523 + "134": "atm", // atmSubInterface
524 + "149": "atm", // atmVirtual
525 + "152": "atm", // voiceOverAtm
526 + "159": "atm", // rfc1483
527 + "187": "atm", // aal2
528 + "189": "atm", // atmRadio
529 + "194": "atm", // atmVciEndPt
530 + "197": "atm", // propAtm
531 + "234": "atm", // atmbond
532 +
533 + // Frame Relay
534 + "32": "frame_relay", // frameRelay
535 + "44": "frame_relay", // frameRelayService
536 + "58": "frame_relay", // frameRelayInterconnect
537 + "92": "frame_relay", // frameRelayMPI
538 + "153": "frame_relay", // voiceOverFrameRelay
539 + "158": "frame_relay", // frForward
540 + "193": "frame_relay", // frDlciEndPt
541 +
542 + // WAN (legacy X.25, etc.)
543 + "4": "wan", // ddnX25
544 + "5": "wan", // rfc877x25
545 + "27": "wan", // nsip
546 + "38": "wan", // miox25
547 + "40": "wan", // x25ple
548 + "68": "wan", // qllc
549 + "121": "wan", // x25mlp
550 + "122": "wan", // x25huntGroup
551 +
552 + // Legacy/obsolete (includes mainframe, protocol translation)
553 + "2": "legacy", // regular1822
554 + "3": "legacy", // hdh1822
555 + "8": "legacy", // iso88024TokenBus
556 + "9": "legacy", // iso88025TokenRing
557 + "10": "legacy", // iso88026Man
558 + "11": "legacy", // starLan
559 + "12": "legacy", // proteon10Mbit
560 + "13": "legacy", // proteon80Mbit
561 + "14": "legacy", // hyperchannel
562 + "15": "legacy", // fddi
563 + "26": "legacy", // ethernet3Mbit
564 + "29": "legacy", // ultra
565 + "35": "legacy", // arcnet
566 + "36": "legacy", // arcnetPlus
567 + "41": "legacy", // iso88022llc
568 + "42": "legacy", // localTalk
569 + "43": "legacy", // smdsDxi
570 + "52": "legacy", // smdsIcip
571 + "70": "legacy", // channel (mainframe)
572 + "72": "legacy", // ibm370parChan (mainframe)
573 + "73": "legacy", // escon (mainframe)
574 + "74": "legacy", // dlsw (protocol translation)
575 + "79": "legacy", // rsrb (protocol translation)
576 + "98": "legacy", // iso88025CRFPInt
577 + "99": "legacy", // myrinet
578 + "111": "legacy", // stackToStack (protocol translation)
579 + "141": "legacy", // dcn (protocol translation)
580 + "206": "legacy", // econet
581 + "249": "legacy", // aluELP
582 +
583 + // Broadcast / media (satellite, DVB, MPEG)
584 + "139": "broadcast_media", // mediaMailOverIp
585 + "140": "broadcast_media", // dtm
586 + "146": "broadcast_media", // dvbRccMacLayer
587 + "147": "broadcast_media", // dvbRccDownstream
588 + "148": "broadcast_media", // dvbRccUpstream
589 + "172": "broadcast_media", // dvbAsiIn
590 + "173": "broadcast_media", // dvbAsiOut
591 + "214": "broadcast_media", // mpegTransport
592 + "239": "broadcast_media", // dvbRcsMacLayer
593 + "240": "broadcast_media", // dvbTdm
594 + "241": "broadcast_media", // dvbRcsTdma
595 +
596 + // Home networking (powerline, G.hn, ZigBee)
597 + "138": "home_network", // digitalPowerline
598 + "174": "home_network", // plc
599 + "220": "home_network", // homepna
600 + "259": "home_network", // ieee802154
601 + "290": "home_network", // ghn
602 +
603 + // Other/miscellaneous
604 + "1": "other", // other
605 + "34": "other", // para
606 + "47": "other", // hippi
607 + "54": "other", // propMultiplexor
608 + "57": "other", // hippiInterface
609 + "59": "other", // aflane8023
610 + "60": "other", // aflane8025
611 + "61": "other", // cctEmul
612 + "83": "other", // bsc
613 + "85": "other", // cnr
614 + "86": "other", // iso88025Dtr
615 + "87": "other", // eplrs
616 + "89": "other", // propCnls
617 + "90": "other", // hostPad
618 + "91": "other", // termPad
619 + "93": "other", // x213
620 + "113": "other", // mpc
621 + "115": "other", // iso88025Fiber
622 + "116": "other", // tdlc
623 + "124": "other", // interleave
624 + "130": "other", // a12MppSwitch
625 + "132": "other", // coffee
626 + "144": "other", // ieee1394
627 + "145": "other", // if-gsn
628 + "160": "other", // usb
629 + "162": "other", // bgppolicyaccounting
630 + "184": "other", // propBWAp2Mp
631 + "190": "other", // imt
632 + "191": "other", // mvl
633 + "217": "other", // pdnEtherLoop1
634 + "218": "other", // pdnEtherLoop2
635 + "223": "other", // actelisMetaLOOP
636 + "226": "other", // qam
637 + "231": "other", // macSecControlledIF
638 + "232": "other", // macSecUncontrolledIF
639 + "242": "other", // x86Laps
640 + "247": "other", // ilan
641 + "248": "other", // pip
642 + "255": "other", // bits
643 + "280": "other", // sdci
644 + "289": "other", // ptm
645 + "301": "other", // omni
646 + "302": "other", // roe
647 + },
648 }
src/go/plugin/go.d/collector/snmp/ddsnmp/shared_test.go new
+60
@@ -0,0 +1,60 @@
1 +// SPDX-License-Identifier: GPL-3.0-or-later
2 +
3 +package ddsnmp
4 +
5 +import (
6 + "fmt"
7 + "sort"
8 + "testing"
9 +
10 + "github.com/stretchr/testify/assert"
11 +)
12 +
13 +func TestSharedMappingsCompleteness(t *testing.T) {
14 + // Verify all ifType entries have a corresponding group
15 + missingGroups := []string{}
16 +
17 + for ifTypeID := range sharedMappings.ifType {
18 + if _, exists := sharedMappings.ifTypeGroup[ifTypeID]; !exists {
19 + missingGroups = append(missingGroups, fmt.Sprintf("%s (%s)", ifTypeID, sharedMappings.ifType[ifTypeID]))
20 + }
21 + }
22 +
23 + assert.Empty(t, missingGroups, "All interface types should have groups")
24 + if len(missingGroups) == 0 {
25 + t.Logf("✓ All %d interface types have groups", len(sharedMappings.ifType))
26 + }
27 +}
28 +
29 +func TestSharedMappingsCount(t *testing.T) {
30 + t.Logf("ifType entries: %d", len(sharedMappings.ifType))
31 + t.Logf("ifTypeGroup entries: %d", len(sharedMappings.ifTypeGroup))
32 +
33 + // Count items per group
34 + groups := make(map[string]int)
35 + for _, group := range sharedMappings.ifTypeGroup {
36 + groups[group]++
37 + }
38 +
39 + // Sort by count descending
40 + type groupCount struct {
41 + name string
42 + count int
43 + }
44 + var sorted []groupCount
45 + for name, count := range groups {
46 + sorted = append(sorted, groupCount{name, count})
47 + }
48 + sort.Slice(sorted, func(i, j int) bool {
49 + return sorted[i].count > sorted[j].count
50 + })
51 +
52 + t.Logf("\nGroup distribution (%d groups):", len(groups))
53 + for _, gc := range sorted {
54 + t.Logf(" %3d %s", gc.count, gc.name)
55 + }
56 +
57 + // Verify group count doesn't exceed ifType count
58 + assert.LessOrEqual(t, len(sharedMappings.ifTypeGroup), len(sharedMappings.ifType),
59 + "ifTypeGroup should not have more entries than ifType")
60 +}
src/go/plugin/go.d/config/go.d/snmp.profiles/default/_std-if-mib.yaml
+11
@@ -70,6 +70,11 @@ metrics:
70 OID: 1.3.6.1.2.1.2.2.1.3
71 name: ifType
72 mapping_ref: ifType
73 + - tag: _if_type_group
74 + symbol:
75 + OID: 1.3.6.1.2.1.2.2.1.3
76 + name: ifType
77 + mapping_ref: ifTypeGroup
78
79 # =========================
80 # IF-MIB::ifXTable (64-bit + extras)
@@ -111,6 +116,12 @@ metrics:
116 OID: 1.3.6.1.2.1.2.2.1.3
117 name: ifType
118 mapping_ref: ifType
119 + - tag: _if_type_group
120 + table: ifTable
121 + symbol:
122 + OID: 1.3.6.1.2.1.2.2.1.3
123 + name: ifType
124 + mapping_ref: ifTypeGroup
125
126 virtual_metrics:
127 # ======================
src/go/plugin/go.d/config/go.d/snmp.profiles/default/_std-ip-mib.yaml
+9
@@ -404,3 +404,12 @@ metrics:
404 index_transform:
405 - start: 1
406 end: 1
407 + - tag: _if_type_group
408 + table: ifTable
409 + symbol:
410 + OID: 1.3.6.1.2.1.2.2.1.3
411 + name: ifType
412 + mapping_ref: ifTypeGroup
413 + index_transform:
414 + - start: 1
415 + end: 1