| 1 | package metricsscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ |
| 2 | |
| 3 | import ( |
| 4 | "github.com/czerwonk/bird_exporter/clientscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/client`/" |
| 5 | "github.com/czerwonk/bird_exporter/protocolscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/protocol`/" |
| 6 | "github.com/prometheus/client_golang/prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/" |
| 7 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/ "github.com/sirupsen/logrusscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/" |
| 8 | ) |
| 9 | |
| 10 | type ospfDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc# struct { |
| 11 | runningDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc#runningDesc. *prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.Descscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/Desc# |
| 12 | interfaceCountDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc#interfaceCountDesc. *prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.Descscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/Desc# |
| 13 | neighborCountDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc#neighborCountDesc. *prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.Descscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/Desc# |
| 14 | neighborAdjacentCountDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc#neighborAdjacentCountDesc. *prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.Descscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/Desc# |
| 15 | } |
| 16 | |
| 17 | type ospfMetricExporterscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfMetricExporter# struct { |
| 18 | descriptionsscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfMetricExporter#descriptions. map[string]*ospfDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc# |
| 19 | clientscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfMetricExporter#client. clientscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/client`/.Clientscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/client`/Client# |
| 20 | } |
| 21 | |
| 22 | // NewOSPFExporter creates a new MetricExporter for OSPF metrics |
| 23 | func NewOSPFExporterscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/NewOSPFExporter().(prefix string, client clientscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/client`/.Clientscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/client`/Client#) MetricExporterscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/MetricExporter# { |
| 24 | d := make(map[string]*ospfDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc#) |
| 25 | d["4"] = getDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/getDesc().(prefix + "ospf") |
| 26 | d["6"] = getDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/getDesc().(prefix + "ospfv3") |
| 27 | |
| 28 | return &ospfMetricExporterscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfMetricExporter#{descriptionsscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfMetricExporter#descriptions.: d, clientscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfMetricExporter#client.: client} |
| 29 | } |
| 30 | |
| 31 | func getDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/getDesc().(prefix string) *ospfDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc# { |
| 32 | labels := []string{"name"} |
| 33 | |
| 34 | d := &ospfDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc#{} |
| 35 | d.runningDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc#runningDesc. = prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.NewDescscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/NewDesc().(prefix+"_running", "State of OSPF: 0 = Alone, 1 = Running (Neighbor-Adjacencies established)", labels, nil) |
| 36 | |
| 37 | labels = append(labels, "area") |
| 38 | d.interfaceCountDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc#interfaceCountDesc. = prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.NewDescscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/NewDesc().(prefix+"_interface_count", "Number of interfaces in the area", labels, nil) |
| 39 | d.neighborCountDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc#neighborCountDesc. = prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.NewDescscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/NewDesc().(prefix+"_neighbor_count", "Number of neighbors in the area", labels, nil) |
| 40 | d.neighborAdjacentCountDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc#neighborAdjacentCountDesc. = prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.NewDescscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/NewDesc().(prefix+"_neighbor_adjacent_count", "Number of adjacent neighbors in the area", labels, nil) |
| 41 | |
| 42 | return d |
| 43 | } |
| 44 | |
| 45 | func (m *ospfMetricExporterscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfMetricExporter#) Describescip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfMetricExporter#Describe().(ch chan<- *prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.Descscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/Desc#) { |
| 46 | m.describescip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfMetricExporter#describe().("4", ch) |
| 47 | m.describescip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfMetricExporter#describe().("6", ch) |
| 48 | } |
| 49 | |
| 50 | func (m *ospfMetricExporterscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfMetricExporter#) describescip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfMetricExporter#describe().(ipVersion string, ch chan<- *prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.Descscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/Desc#) { |
| 51 | d := m.descriptionsscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfMetricExporter#descriptions.[ipVersion] |
| 52 | ch <- d.runningDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc#runningDesc. |
| 53 | ch <- d.interfaceCountDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc#interfaceCountDesc. |
| 54 | ch <- d.neighborCountDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc#neighborCountDesc. |
| 55 | ch <- d.neighborAdjacentCountDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc#neighborAdjacentCountDesc. |
| 56 | } |
| 57 | |
| 58 | func (m *ospfMetricExporterscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfMetricExporter#) Exportscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfMetricExporter#Export().(p *protocolscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/protocol`/.Protocolscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/protocol`/Protocol#, ch chan<- prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.Metricscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/Metric#, newFormat bool) { |
| 59 | d := m.descriptionsscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfMetricExporter#descriptions.[p.IPVersionscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/protocol`/Protocol#IPVersion.] |
| 60 | |
| 61 | var running float64 |
| 62 | if p.Statescip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/protocol`/Protocol#State. == "Running" { |
| 63 | running = 1 |
| 64 | } |
| 65 | |
| 66 | ch <- prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.MustNewConstMetricscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/MustNewConstMetric().(d.runningDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc#runningDesc., prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.GaugeValuescip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/GaugeValue., running, p.Namescip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/protocol`/Protocol#Name.) |
| 67 | |
| 68 | areas, err := m.clientscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfMetricExporter#client..GetOSPFAreasscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/client`/Client#GetOSPFAreas.(p) |
| 69 | if err != nil { |
| 70 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Errorlnscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Errorln().(err) |
| 71 | return |
| 72 | } |
| 73 | |
| 74 | for _, area := range areas { |
| 75 | l := []string{p.Namescip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/protocol`/Protocol#Name., area.Namescip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/protocol`/OSPFArea#Name.} |
| 76 | ch <- prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.MustNewConstMetricscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/MustNewConstMetric().(d.interfaceCountDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc#interfaceCountDesc., prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.GaugeValuescip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/GaugeValue., float64(area.InterfaceCountscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/protocol`/OSPFArea#InterfaceCount.), l...) |
| 77 | ch <- prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.MustNewConstMetricscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/MustNewConstMetric().(d.neighborCountDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc#neighborCountDesc., prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.GaugeValuescip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/GaugeValue., float64(area.NeighborCountscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/protocol`/OSPFArea#NeighborCount.), l...) |
| 78 | ch <- prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.MustNewConstMetricscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/MustNewConstMetric().(d.neighborAdjacentCountDescscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/metrics`/ospfDesc#neighborAdjacentCountDesc., prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.GaugeValuescip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/GaugeValue., float64(area.NeighborAdjacentCountscip-go gomod github.com/czerwonk/bird_exporter . `github.com/czerwonk/bird_exporter/protocol`/OSPFArea#NeighborAdjacentCount.), l...) |
| 79 | } |
| 80 | } |