| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | package snmptopology |
| 4 | |
| 5 | import "github.com/netdata/netdata/go/plugins/plugin/framework/collectorapi" |
| 6 | |
| 7 | var ( |
| 8 | topologyDevicesChart = collectorapi.Chart{ |
| 9 | ID: "topology_devices", |
| 10 | Title: "Topology devices", |
| 11 | Units: "devices", |
| 12 | Fam: "Topology", |
| 13 | Ctx: "snmp_topology.devices", |
| 14 | Priority: 39200, |
| 15 | Dims: collectorapi.Dims{ |
| 16 | {ID: "snmp_topology_devices_total", Name: "total"}, |
| 17 | {ID: "snmp_topology_devices_discovered", Name: "discovered"}, |
| 18 | }, |
| 19 | } |
| 20 | topologyLinksChart = collectorapi.Chart{ |
| 21 | ID: "topology_links", |
| 22 | Title: "Topology links", |
| 23 | Units: "links", |
| 24 | Fam: "Topology", |
| 25 | Ctx: "snmp_topology.links", |
| 26 | Priority: 39201, |
| 27 | Dims: collectorapi.Dims{ |
| 28 | {ID: "snmp_topology_links_total", Name: "total"}, |
| 29 | {ID: "snmp_topology_links_lldp", Name: "lldp"}, |
| 30 | {ID: "snmp_topology_links_cdp", Name: "cdp"}, |
| 31 | {ID: "snmp_topology_links_stp", Name: "stp"}, |
| 32 | }, |
| 33 | } |
| 34 | topologyCharts = collectorapi.Charts{ |
| 35 | topologyDevicesChart.Copy(), |
| 36 | topologyLinksChart.Copy(), |
| 37 | } |
| 38 | ) |
| 39 | |
| 40 | func (c *Collector) addTopologyCharts() { |
| 41 | charts := topologyCharts.Copy() |
| 42 | if err := c.Charts().Add(*charts...); err != nil { |
| 43 | c.Warningf("failed to add topology charts: %v", err) |
| 44 | } |
| 45 | } |