From aa3dd339fa69e2692d7e43c8d4681f9d5bf87002 Mon Sep 17 00:00:00 2001 From: JYS Date: Wed, 11 May 2022 05:28:07 +0200 Subject: [PATCH 1/5] adding basic lacp metrics --- collectors.go | 2 ++ config/config.go | 1 + lacp/collector.go | 65 +++++++++++++++++++++++++++++++++++++++++++++++ lacp/rpc.go | 25 ++++++++++++++++++ main.go | 1 + 5 files changed, 94 insertions(+) create mode 100644 lacp/collector.go create mode 100644 lacp/rpc.go diff --git a/collectors.go b/collectors.go index 59343300..bf6c4237 100644 --- a/collectors.go +++ b/collectors.go @@ -17,6 +17,7 @@ import ( "github.com/czerwonk/junos_exporter/ipsec" "github.com/czerwonk/junos_exporter/isis" "github.com/czerwonk/junos_exporter/l2circuit" + "github.com/czerwonk/junos_exporter/lacp" "github.com/czerwonk/junos_exporter/ldp" "github.com/czerwonk/junos_exporter/mac" "github.com/czerwonk/junos_exporter/nat" @@ -85,6 +86,7 @@ func (c *collectors) initCollectorsForDevices(device *connector.Device) { c.addCollectorIfEnabledForDevice(device, "ipsec", f.IPSec, ipsec.NewCollector) c.addCollectorIfEnabledForDevice(device, "isis", f.ISIS, isis.NewCollector) c.addCollectorIfEnabledForDevice(device, "l2c", f.L2Circuit, l2circuit.NewCollector) + c.addCollectorIfEnabledForDevice(device, "lacp", f.LACP, lacp.NewCollector) c.addCollectorIfEnabledForDevice(device, "ldp", f.LDP, ldp.NewCollector) c.addCollectorIfEnabledForDevice(device, "nat", f.NAT, nat.NewCollector) c.addCollectorIfEnabledForDevice(device, "nat2", f.NAT2, nat2.NewCollector) diff --git a/config/config.go b/config/config.go index ea5b66a8..51362d7a 100644 --- a/config/config.go +++ b/config/config.go @@ -37,6 +37,7 @@ type FeatureConfig struct { NAT bool `yaml:"nat,omitempty"` NAT2 bool `yaml:"nat2,omitempty"` L2Circuit bool `yaml:"l2circuit,omitempty"` + LACP bool `yaml:"lacp,omitempty"` LDP bool `yaml:"ldp,omitempty"` Routes bool `yaml:"routes,omitempty"` RoutingEngine bool `yaml:"routing_engine,omitempty"` diff --git a/lacp/collector.go b/lacp/collector.go new file mode 100644 index 00000000..165db6c1 --- /dev/null +++ b/lacp/collector.go @@ -0,0 +1,65 @@ +package lacp + +import ( + "github.com/czerwonk/junos_exporter/collector" + "github.com/czerwonk/junos_exporter/rpc" + "github.com/prometheus/client_golang/prometheus" +) + +const prefix = "junos_lacp_" + +var ( + lacpMuxState *prometheus.Desc + lacpMuxStateMap = map[string]int{ + "Detached": 1, + "Waiting": 2, + "Attached": 3, + "Collecting": 4, + "Distributing": 5, + "Collecting distributing": 6, +} +) + +func init() { + l := []string{"target", "name", "member"} + lacpMuxState = prometheus.NewDesc(prefix+"muxstate", "lacp mux state (1: detached, 2: waiting, 3: attached, 4: collecting, 5: distributing, 6: collecting distribuging)", l, nil) +} + +type lacpCollector struct { +} + +// Name returns the name of the collector +func (*lacpCollector) Name() string { + return "lacp" +} + +// NewCollector creates a new collector +func NewCollector() collector.RPCCollector { + return &lacpCollector{} +} + +// Describe describes the metrics +func (*lacpCollector) Describe(ch chan<- *prometheus.Desc) { + ch <- lacpMuxState +} + + +// Collect collects metrics from JunOS +func (c *lacpCollector) Collect(client *rpc.Client, ch chan<- prometheus.Metric, labelValues []string) error { + var x = lacpRpc{} + err := client.RunCommandAndParse("show lacp interfaces", &x) + if err != nil { + return err + } + + for _, iface := range x.Information.LacpInterfaces { + + for _, member := range iface.LagLacpProtocols { + l := append(labelValues, iface.LagLacpHeader.Name, member.Member) + ch <- prometheus.MustNewConstMetric(lacpMuxState, prometheus.GaugeValue, float64(lacpMuxStateMap[member.LacpMuxState]), l...) + } + + } + + return nil +} diff --git a/lacp/rpc.go b/lacp/rpc.go new file mode 100644 index 00000000..f8bf3f03 --- /dev/null +++ b/lacp/rpc.go @@ -0,0 +1,25 @@ +package lacp + +type lacpRpc struct { + Information struct { + LacpInterfaces []lacpInterface `xml:"lacp-interface-information"` + } `xml:"lacp-interface-information-list"` +} + +type lacpInterface struct { + LagLacpHeader struct { + Name string `xml:"aggregate-name"` + } `xml:"lag-lacp-header"` + LagLacpStates []LagLacpStateStruct `xml:"lag-lacp-state"` + LagLacpProtocols []LagLacpProtocolStruct `xml:"lag-lacp-protocol"` +} + + +type LagLacpStateStruct struct{ +} + +type LagLacpProtocolStruct struct{ + Member string `xml:"name"` + LacpMuxState string `xml:"lacp-mux-state"` +} + diff --git a/main.go b/main.go index 55104cd3..705db42c 100644 --- a/main.go +++ b/main.go @@ -66,6 +66,7 @@ var ( interfaceDescriptionRegex = flag.String("interface-description-regex", "", "give a regex to retrieve the interface description labels") lsEnabled = flag.Bool("logical-systems.enabled", false, "Enable logical systems support") powerEnabled = flag.Bool("power.enabled", true, "Scrape power metrics") + lacpEnabled = flag.Bool("lacp.enabled", true, "Scrape lacp metrics") cfg *config.Config devices []*connector.Device connManager *connector.SSHConnectionManager From 761966641099914d2c5dc672ffa9f45b89d52dae Mon Sep 17 00:00:00 2001 From: Jean-Yves Simon Date: Wed, 11 May 2022 10:24:05 +0200 Subject: [PATCH 2/5] add basic bfd --- bfd/collector.go | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ bfd/rpc.go | 21 ++++++++++++++++++ collectors.go | 2 ++ config/config.go | 1 + main.go | 1 + 5 files changed, 83 insertions(+) create mode 100644 bfd/collector.go create mode 100644 bfd/rpc.go diff --git a/bfd/collector.go b/bfd/collector.go new file mode 100644 index 00000000..5298568f --- /dev/null +++ b/bfd/collector.go @@ -0,0 +1,58 @@ +package bfd + +import ( + "github.com/czerwonk/junos_exporter/collector" + "github.com/czerwonk/junos_exporter/rpc" + "github.com/prometheus/client_golang/prometheus" +) + +const prefix = "junos_bfd_" + +var ( + bfdState *prometheus.Desc + bfdStateMap = map[string]int{ + "Down": 0, + "Up": 1, + } + +) + +func init() { + l := []string{"target", "neighbor", "interface", "client"} + bfdState = prometheus.NewDesc(prefix+"state", "bfd state (0: down, 1:up)", l, nil) +} + +type bfdCollector struct { +} + +// Name returns the name of the collector +func (*bfdCollector) Name() string { + return "bfd" +} + +// NewCollector creates a new collector +func NewCollector() collector.RPCCollector { + return &bfdCollector{} +} + +// Describe describes the metrics +func (*bfdCollector) Describe(ch chan<- *prometheus.Desc) { + ch <- bfdState +} + + +// Collect collects metrics from JunOS +func (c *bfdCollector) Collect(client *rpc.Client, ch chan<- prometheus.Metric, labelValues []string) error { + var x = bfdRpc{} + err := client.RunCommandAndParse("show bfd session extensive", &x) + if err != nil { + return err + } + + for _, bfds := range x.Information.BfdSessions { + l := append(labelValues, bfds.Neighbor, bfds.Interface, bfds.Client.Name) + ch <- prometheus.MustNewConstMetric(bfdState, prometheus.GaugeValue, float64(bfdStateMap[bfds.State]), l...) + } + + return nil +} diff --git a/bfd/rpc.go b/bfd/rpc.go new file mode 100644 index 00000000..815e1b05 --- /dev/null +++ b/bfd/rpc.go @@ -0,0 +1,21 @@ +package bfd + +type bfdRpc struct { + Information struct { + BfdSessions []bfdSession `xml:"bfd-session"` + sessions int64 `xml:"sessions"` + clients int64 `xml:"clients"` + CumTransRate float64 `xml:"cumulative-transmission-rate"` + CumRecRate float64 `xml:"cumulative-reception-rate"` + } `xml:"bfd-session-information"` +} + +type bfdSession struct { + Neighbor string `xml:"session-neighbor"` + State string `xml:"session-state"` + Interface string `xml:"session-interface"` + Client struct { + Name string `xml:"client-name"` + } `xml:"bfd-client"` +} + diff --git a/collectors.go b/collectors.go index bf6c4237..e8e6807f 100644 --- a/collectors.go +++ b/collectors.go @@ -3,6 +3,7 @@ package main import ( "github.com/czerwonk/junos_exporter/accounting" "github.com/czerwonk/junos_exporter/alarm" + "github.com/czerwonk/junos_exporter/bfd" "github.com/czerwonk/junos_exporter/bgp" "github.com/czerwonk/junos_exporter/collector" "github.com/czerwonk/junos_exporter/config" @@ -68,6 +69,7 @@ func (c *collectors) initCollectorsForDevices(device *connector.Device) { c.addCollectorIfEnabledForDevice(device, "alarm", f.Alarm, func() collector.RPCCollector { return alarm.NewCollector(*alarmFilter) }) + c.addCollectorIfEnabledForDevice(device, "bfd", f.BFD, bfd.NewCollector) c.addCollectorIfEnabledForDevice(device, "bgp", f.BGP, func() collector.RPCCollector { return bgp.NewCollector(c.logicalSystem) }) diff --git a/config/config.go b/config/config.go index 51362d7a..7f81705c 100644 --- a/config/config.go +++ b/config/config.go @@ -31,6 +31,7 @@ type DeviceConfig struct { type FeatureConfig struct { Alarm bool `yaml:"alarm,omitempty"` Environment bool `yaml:"environment,omitempty"` + BFD bool `yaml:"bfd,omitempty"` BGP bool `yaml:"bgp,omitempty"` OSPF bool `yaml:"ospf,omitempty"` ISIS bool `yaml:"isis,omitempty"` diff --git a/main.go b/main.go index 705db42c..c667e834 100644 --- a/main.go +++ b/main.go @@ -67,6 +67,7 @@ var ( lsEnabled = flag.Bool("logical-systems.enabled", false, "Enable logical systems support") powerEnabled = flag.Bool("power.enabled", true, "Scrape power metrics") lacpEnabled = flag.Bool("lacp.enabled", true, "Scrape lacp metrics") + bfdEnabled = flag.Bool("bfd.enabled", true, "Scrape bfd metrics") cfg *config.Config devices []*connector.Device connManager *connector.SSHConnectionManager From 1e57ac8cdd0449954da734bdc00f3428e2f56c1d Mon Sep 17 00:00:00 2001 From: Jean-Yves Simon Date: Wed, 11 May 2022 14:52:18 +0200 Subject: [PATCH 3/5] add vpws --- collectors.go | 2 ++ config/config.go | 1 + main.go | 1 + vpws/collector.go | 82 +++++++++++++++++++++++++++++++++++++++++++++++ vpws/rpc.go | 48 +++++++++++++++++++++++++++ 5 files changed, 134 insertions(+) create mode 100644 vpws/collector.go create mode 100644 vpws/rpc.go diff --git a/collectors.go b/collectors.go index e8e6807f..04c56721 100644 --- a/collectors.go +++ b/collectors.go @@ -33,6 +33,7 @@ import ( "github.com/czerwonk/junos_exporter/storage" "github.com/czerwonk/junos_exporter/system" "github.com/czerwonk/junos_exporter/vrrp" + "github.com/czerwonk/junos_exporter/vpws" ) type collectors struct { @@ -104,6 +105,7 @@ func (c *collectors) initCollectorsForDevices(device *connector.Device) { c.addCollectorIfEnabledForDevice(device, "power", f.Power, power.NewCollector) c.addCollectorIfEnabledForDevice(device, "mac", f.MAC, mac.NewCollector) c.addCollectorIfEnabledForDevice(device, "vrrp", f.VRRP, vrrp.NewCollector) + c.addCollectorIfEnabledForDevice(device, "vpws", f.VPWS, vpws.NewCollector) } func (c *collectors) addCollectorIfEnabledForDevice(device *connector.Device, key string, enabled bool, newCollector func() collector.RPCCollector) { diff --git a/config/config.go b/config/config.go index 7f81705c..cacf0987 100644 --- a/config/config.go +++ b/config/config.go @@ -57,6 +57,7 @@ type FeatureConfig struct { System bool `yaml:"system,omitempty"` Power bool `yaml:"power,omitempty"` MAC bool `yaml:"mac,omitempty"` + VPWS bool `yaml:"vpws,omitempty"` VRRP bool `yaml:"vrrp,omitempty"` } diff --git a/main.go b/main.go index c667e834..2bffeff0 100644 --- a/main.go +++ b/main.go @@ -68,6 +68,7 @@ var ( powerEnabled = flag.Bool("power.enabled", true, "Scrape power metrics") lacpEnabled = flag.Bool("lacp.enabled", true, "Scrape lacp metrics") bfdEnabled = flag.Bool("bfd.enabled", true, "Scrape bfd metrics") + vpwsEnabled = flag.Bool("vpws.enabled", true, "Scrape evpn vpws metrics") cfg *config.Config devices []*connector.Device connManager *connector.SSHConnectionManager diff --git a/vpws/collector.go b/vpws/collector.go new file mode 100644 index 00000000..7aa5c18b --- /dev/null +++ b/vpws/collector.go @@ -0,0 +1,82 @@ +package vpws + +import ( + "github.com/czerwonk/junos_exporter/collector" + "github.com/czerwonk/junos_exporter/rpc" + "github.com/prometheus/client_golang/prometheus" +) + +const prefix = "junos_vpws_" + +var ( + vpwsStatus *prometheus.Desc + vpwsSid *prometheus.Desc + + vpwsStatusMap = map[string]int{ + "Down": 0, + "Up": 1, + } + + vpwsSidMap = map[string]int{ + "Unresolved": 0, + "Resolved": 1, + } + +) + +func init() { + l := []string{"target", "vpwsinstance", "rd", "interface", "esi", "mode", "role"} + vpwsStatus = prometheus.NewDesc(prefix+"status", "vpws status (0: down, 1:up)", l, nil) + + ls := []string{"target", "vpwsinstance", "rd", "interface", "sidorigin", "sid", "ip", "esi", "mode", "role"} + vpwsSid = prometheus.NewDesc(prefix+"sid", "vpws sid (0: Unresolved, 1:Resolved)", ls, nil) +} + +type vpwsCollector struct { +} + +// Name returns the name of the collector +func (*vpwsCollector) Name() string { + return "vpws" +} + +// NewCollector creates a new collector +func NewCollector() collector.RPCCollector { + return &vpwsCollector{} +} + +// Describe describes the metrics +func (*vpwsCollector) Describe(ch chan<- *prometheus.Desc) { + ch <- vpwsStatus + ch <- vpwsSid +} + + +// Collect collects metrics from JunOS +func (c *vpwsCollector) Collect(client *rpc.Client, ch chan<- prometheus.Metric, labelValues []string) error { + var x = vpwsRpc{} + err := client.RunCommandAndParse("show evpn vpws-instance", &x) + if err != nil { + return err + } + + for _, vInst := range x.Information.VpwsInstances { + for _, vIf := range vInst.VpwsInterfaces { + l := append(labelValues, vInst.Name, vInst.RD, vIf.Name, vIf.Esi, vIf.Mode, vIf.Role ) + ch <- prometheus.MustNewConstMetric(vpwsStatus, prometheus.GaugeValue, float64(vpwsStatusMap[vIf.Status]), l...) + + for _, vSid := range vIf.LocalStatus.SidPeInfo { + l := append(labelValues, vInst.Name, vInst.RD, vIf.Name, "local", vIf.LocalStatus.Sid, vSid.IP, vSid.Esi, vSid.Mode, vSid.Role ) + ch <- prometheus.MustNewConstMetric(vpwsSid, prometheus.GaugeValue, float64(vpwsSidMap[vSid.Status]), l...) + } + + for _, vSid := range vIf.RemoteStatus.SidPeInfo { + l := append(labelValues, vInst.Name, vInst.RD, vIf.Name, "remote", vIf.RemoteStatus.Sid, vSid.IP, vSid.Esi, vSid.Mode, vSid.Role ) + ch <- prometheus.MustNewConstMetric(vpwsSid, prometheus.GaugeValue, float64(vpwsSidMap[vSid.Status]), l...) + } + + } + } + + return nil +} diff --git a/vpws/rpc.go b/vpws/rpc.go new file mode 100644 index 00000000..aa7224aa --- /dev/null +++ b/vpws/rpc.go @@ -0,0 +1,48 @@ +package vpws + + +type vpwsRpc struct { + Information struct { + VpwsInstances []vpwsInstance `xml:"evpn-vpws-instance"` + } `xml:"evpn-vpws-information"` +} + + +type vpwsInstance struct { + Name string `xml:"evpn-vpws-instance-name"` + RD string `xml:"route-distinguisher"` + LocalInterfaces int64 `xml:"local-interfaces"` + LocalInterfacesUp int64 `xml:"local-interfaces-up"` + + VpwsInterfaces []vpwsInterface `xml:"evpn-vpws-interface-status-table>evpn-vpws-interface"` +} + + + +type vpwsInterface struct { + Name string `xml:"evpn-vpws-interface-name"` + Esi string `xml:"evpn-vpws-interface-esi"` + Mode string `xml:"evpn-vpws-interface-mode"` + Role string `xml:"evpn-vpws-interface-role"` + Status string `xml:"evpn-vpws-interface-status"` + + LocalStatus struct { + Sid string `xml:"evpn-vpws-sid-local-value"` + SidPeInfo []vpwsSidPeInfo `xml:"evpn-vpws-sid-pe-status-table>evpn-vpws-sid-pe-info"` + } `xml:"evpn-vpws-service-id-local-status-table>evpn-vpws-sid-local"` + + RemoteStatus struct { + Sid string `xml:"evpn-vpws-sid-remote-value"` + SidPeInfo []vpwsSidPeInfo `xml:"evpn-vpws-sid-pe-status-table>evpn-vpws-sid-pe-info"` + } `xml:"evpn-vpws-service-id-remote-status-table>evpn-vpws-sid-remote"` + +} + + +type vpwsSidPeInfo struct { + Esi string `xml:"evpn-vpws-sid-interface-esi"` + IP string `xml:"evpn-vpws-sid-pe-ipaddr"` + Mode string `xml:"evpn-vpws-sid-pe-mode"` + Role string `xml:"evpn-vpws-sid-pe-role"` + Status string `xml:"evpn-vpws-sid-pe-status"` +} \ No newline at end of file From e1e31a7881e543ee1c6a4fcf35fd5cf102987c8c Mon Sep 17 00:00:00 2001 From: Jean-Yves Simon Date: Fri, 13 May 2022 12:49:34 +0200 Subject: [PATCH 4/5] add basic mpls lsp metrics --- collectors.go | 2 ++ config/config.go | 1 + main.go | 1 + mpls_lsp/collector.go | 71 +++++++++++++++++++++++++++++++++++++++++++ mpls_lsp/rpc.go | 24 +++++++++++++++ 5 files changed, 99 insertions(+) create mode 100644 mpls_lsp/collector.go create mode 100644 mpls_lsp/rpc.go diff --git a/collectors.go b/collectors.go index 04c56721..9429bb19 100644 --- a/collectors.go +++ b/collectors.go @@ -21,6 +21,7 @@ import ( "github.com/czerwonk/junos_exporter/lacp" "github.com/czerwonk/junos_exporter/ldp" "github.com/czerwonk/junos_exporter/mac" + "github.com/czerwonk/junos_exporter/mpls_lsp" "github.com/czerwonk/junos_exporter/nat" "github.com/czerwonk/junos_exporter/nat2" "github.com/czerwonk/junos_exporter/ospf" @@ -106,6 +107,7 @@ func (c *collectors) initCollectorsForDevices(device *connector.Device) { c.addCollectorIfEnabledForDevice(device, "mac", f.MAC, mac.NewCollector) c.addCollectorIfEnabledForDevice(device, "vrrp", f.VRRP, vrrp.NewCollector) c.addCollectorIfEnabledForDevice(device, "vpws", f.VPWS, vpws.NewCollector) + c.addCollectorIfEnabledForDevice(device, "mpls_lsp", f.MPLS_LSP, mpls_lsp.NewCollector) } func (c *collectors) addCollectorIfEnabledForDevice(device *connector.Device, key string, enabled bool, newCollector func() collector.RPCCollector) { diff --git a/config/config.go b/config/config.go index cacf0987..6ecf8eef 100644 --- a/config/config.go +++ b/config/config.go @@ -57,6 +57,7 @@ type FeatureConfig struct { System bool `yaml:"system,omitempty"` Power bool `yaml:"power,omitempty"` MAC bool `yaml:"mac,omitempty"` + MPLS_LSP bool `yaml:"mpls_lsp,omitempty"` VPWS bool `yaml:"vpws,omitempty"` VRRP bool `yaml:"vrrp,omitempty"` } diff --git a/main.go b/main.go index 2bffeff0..ce19f36b 100644 --- a/main.go +++ b/main.go @@ -69,6 +69,7 @@ var ( lacpEnabled = flag.Bool("lacp.enabled", true, "Scrape lacp metrics") bfdEnabled = flag.Bool("bfd.enabled", true, "Scrape bfd metrics") vpwsEnabled = flag.Bool("vpws.enabled", true, "Scrape evpn vpws metrics") + mpls_lspEnabled = flag.Bool("mpls_lsp.enabled", true, "Scrape mpls LSP metrics") cfg *config.Config devices []*connector.Device connManager *connector.SSHConnectionManager diff --git a/mpls_lsp/collector.go b/mpls_lsp/collector.go new file mode 100644 index 00000000..32888326 --- /dev/null +++ b/mpls_lsp/collector.go @@ -0,0 +1,71 @@ +package mpls_lsp + +import ( + "github.com/czerwonk/junos_exporter/collector" + "github.com/czerwonk/junos_exporter/rpc" + "github.com/prometheus/client_golang/prometheus" +) + +const prefix = "junos_mpls_lsp_" + +var ( + mpls_lspState *prometheus.Desc + mpls_lspPathState *prometheus.Desc + mpls_lspPathFlapCount *prometheus.Desc + + mpls_lspStateMap = map[string]int{ + "Dn": 0, + "Up": 1, + } + +) + +func init() { + ls := []string{"target", "lspname", "lspsrc", "lspdst" } + mpls_lspState = prometheus.NewDesc(prefix+"state", "mpls_lsp state (0: down, 1:up)", ls, nil) + + lps := []string{"target", "lspname", "lspsrc", "lspdst", "title", "name"} + mpls_lspPathState = prometheus.NewDesc(prefix+"path_state", "mpls_lsp pathstate (0: down, 1:up)", lps, nil) + mpls_lspPathFlapCount = prometheus.NewDesc(prefix+"path_flapcount", "mpls_lsp path flap count", lps, nil) +} + +type mpls_lspCollector struct { +} + +// Name returns the name of the collector +func (*mpls_lspCollector) Name() string { + return "mpls_lsp" +} + +// NewCollector creates a new collector +func NewCollector() collector.RPCCollector { + return &mpls_lspCollector{} +} + +// Describe describes the metrics +func (*mpls_lspCollector) Describe(ch chan<- *prometheus.Desc) { + ch <- mpls_lspState +} + + +// Collect collects metrics from JunOS +func (c *mpls_lspCollector) Collect(client *rpc.Client, ch chan<- prometheus.Metric, labelValues []string) error { + var x = mpls_lspRpc{} + err := client.RunCommandAndParse("show mpls lsp ingress extensive", &x) //ingress:Display LSPs originating at this router + if err != nil { + return err + } + + for _, lsp := range x.Information.Sessions { + l := append(labelValues, lsp.Name, lsp.SrcIP, lsp.DstIP) + ch <- prometheus.MustNewConstMetric(mpls_lspState, prometheus.GaugeValue, float64(mpls_lspStateMap[lsp.LSPState]), l...) + + for _, path := range lsp.Path { + l := append(labelValues, lsp.Name, lsp.SrcIP, lsp.DstIP, path.Title, path.Name) + ch <- prometheus.MustNewConstMetric(mpls_lspPathState, prometheus.GaugeValue, float64(mpls_lspStateMap[path.State]), l...) + ch <- prometheus.MustNewConstMetric(mpls_lspPathFlapCount, prometheus.GaugeValue, float64(path.FlapCount), l...) + } + } + + return nil +} diff --git a/mpls_lsp/rpc.go b/mpls_lsp/rpc.go new file mode 100644 index 00000000..d069ac3f --- /dev/null +++ b/mpls_lsp/rpc.go @@ -0,0 +1,24 @@ +package mpls_lsp + +type mpls_lspRpc struct { + Information struct { + Sessions []mpls_lspSession `xml:"rsvp-session"` + } `xml:"mpls-lsp-information>rsvp-session-data"` +} + +type mpls_lspSession struct { + DstIP string `xml:"mpls-lsp>destination-address"` + SrcIP string `xml:"mpls-lsp>source-address"` + LSPState string `xml:"mpls-lsp>lsp-state"` + Name string `xml:"mpls-lsp>name"` + + Path []mpls_lspPath `xml:"mpls-lsp>mpls-lsp-path"` +} + +type mpls_lspPath struct { + Title string `xml:"title"` + Name string `xml:"name"` + State string `xml:"path-state"` + FlapCount int64 `xml:"path-flap-count"` +} + From 362c786c514ca077c4b0e4d7cd8631336a85c16b Mon Sep 17 00:00:00 2001 From: Jean-Yves Simon Date: Sat, 14 May 2022 07:21:28 +0200 Subject: [PATCH 5/5] adding missing defaults --- config/config.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/config.go b/config/config.go index 6ecf8eef..6ce06839 100644 --- a/config/config.go +++ b/config/config.go @@ -116,6 +116,8 @@ func setDefaultValues(c *Config) { f.Satellite = false f.Power = false f.MAC = false + f.MPLS_LSP = false + f.VPWS = false f.VRRP = false }