From c97e7973607c7c8cd31e37f9c8da6f34afddf664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller=20Aguilar?= Date: Thu, 11 Jul 2024 16:06:22 +0000 Subject: [PATCH] Add l2vpn metric --- pkg/features/l2vpn/collector.go | 12 ++++++------ pkg/features/l2vpn/rpc.go | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/features/l2vpn/collector.go b/pkg/features/l2vpn/collector.go index f09c0980..3174f337 100644 --- a/pkg/features/l2vpn/collector.go +++ b/pkg/features/l2vpn/collector.go @@ -42,7 +42,7 @@ var ( "SC": 26, "LM": 27, "RM": 28, - "IL": 39, + "IL": 29, "MI": 30, "ST": 31, "PB": 32, @@ -55,8 +55,8 @@ var ( func init() { l2vpnPrefix := "junos_l2vpn_" - lcount := []string{"target", "instance"} - lstate := []string{"target", "instance", "connection_id", "remote_pe", "last_change", "up_transitions", "local_interface_name"} + lcount := []string{"target", "routing_instance"} + lstate := []string{"target", "routing_instance", "connection_id", "remote_pe", "last_change", "up_transitions", "local_interface_name"} l2StateDescription := "A l2vpn can have one of the following state-mappings EI: 0, EM: 1, VC-Dn: 2, CM: 3, CN: 4, OR: 5, OL: 6, LD: 7, RD: 8, LN: 9, RN: 10, XX: 11, MM: 12, BK: 13, PF: 14, RS: 15, LB: 16, VM: 17, NC: 18, WE: 19, NP: 20, ->: 21, <-: 22, Up: 23, Dn: 24, CF: 25, SC: 26, LM: 27, RM: 28, IL: 39, MI: 30, ST: 31, PB: 32, SN: 33, RB: 34, HS: 35" l2vpnConnectionsDesc = prometheus.NewDesc(l2vpnPrefix+"connection_count", "Number of l2vpn connections", lcount, nil) l2vpnConnectionStateDesc = prometheus.NewDesc(l2vpnPrefix+"connection_status", l2StateDescription, lstate, nil) @@ -94,14 +94,14 @@ func (c *l2vpnCollector) collectl2vpnMetrics(client collector.Client, ch chan<- return err } - instances := x.Information.Instances + instances := x.Information.RoutingInstances for i := 0; i < len(instances); i++ { connCount := 0 for s := 0; s < len(instances[i].ReferenceSite); s++ { connCount += +len(instances[i].ReferenceSite[s].Connections) } - l := append(labelValues, instances[i].InstanceName) + l := append(labelValues, instances[i].RoutingInstanceName) ch <- prometheus.MustNewConstMetric(l2vpnConnectionsDesc, prometheus.GaugeValue, float64(connCount), l...) } @@ -110,7 +110,7 @@ func (c *l2vpnCollector) collectl2vpnMetrics(client collector.Client, ch chan<- for _, site := range a.ReferenceSite { // l = append(l, site.ID) for _, conn := range site.Connections { - l := append(labelValues, a.InstanceName) + l := append(labelValues, a.RoutingInstanceName) // l = append(l, site.ID) c.collectForConnection(ch, conn, l) } diff --git a/pkg/features/l2vpn/rpc.go b/pkg/features/l2vpn/rpc.go index 3b438ce3..621a1457 100644 --- a/pkg/features/l2vpn/rpc.go +++ b/pkg/features/l2vpn/rpc.go @@ -5,12 +5,12 @@ type l2vpnRpc struct { } type l2vpnInformation struct { - Instances []l2vpnInstance `xml:"instance"` + RoutingInstances []l2vpnRoutingInstance `xml:"instance"` } -type l2vpnInstance struct { - InstanceName string `xml:"instance-name"` - ReferenceSite []l2vpnReferenceSite `xml:"reference-site"` +type l2vpnRoutingInstance struct { + RoutingInstanceName string `xml:"instance-name"` + ReferenceSite []l2vpnReferenceSite `xml:"reference-site"` } type l2vpnReferenceSite struct {