Skip to content

Commit

Permalink
Merge branch 'add_l2vpn_metric' into 'anx-prod'
Browse files Browse the repository at this point in the history
Add l2vpn metric

See merge request neteng/junos_exporter!7
  • Loading branch information
Jakob Gastinger committed Jul 11, 2024
2 parents 1ccbe10 + c97e797 commit 266cc56
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions pkg/features/l2vpn/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var (
"SC": 26,
"LM": 27,
"RM": 28,
"IL": 39,
"IL": 29,
"MI": 30,
"ST": 31,
"PB": 32,
Expand All @@ -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)
Expand Down Expand Up @@ -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...)

}
Expand All @@ -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)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/features/l2vpn/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 266cc56

Please sign in to comment.