Skip to content

Commit

Permalink
Add flaps metrics and remote_ip in PDUs counter
Browse files Browse the repository at this point in the history
  • Loading branch information
netixx committed Mar 12, 2024
1 parent 237da11 commit 5bd7849
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cmd/stayrtr/stayrtr.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,19 @@ var (
},
[]string{"bind", "remote_ip"},
)
ClientsFlaps = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "rtr_client_flaps",
Help: "Total count of connect/disconnect events per local and remote IP.",
},
[]string{"bind", "remote_ip"},
)
PDUsRecv = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "rtr_pdus",
Help: "PDU received.",
},
[]string{"type"},
[]string{"type", "remote_ip"},
)
CurrentSerial = prometheus.NewGauge(
prometheus.GaugeOpts{
Expand All @@ -164,6 +171,7 @@ func initMetrics() {
prometheus.MustRegister(LastRefresh)
prometheus.MustRegister(RefreshStatusCode)
prometheus.MustRegister(ClientsMetric)
prometheus.MustRegister(ClientsFlaps)
prometheus.MustRegister(PDUsRecv)
prometheus.MustRegister(CurrentSerial)
}
Expand Down Expand Up @@ -694,10 +702,12 @@ type metricsEvent struct {

func (m *metricsEvent) ClientConnected(c *rtr.Client) {
ClientsMetric.WithLabelValues(c.GetLocalAddress().String(), c.GetRemoteAddress().String()).Inc()
ClientsFlaps.WithLabelValues(c.GetLocalAddress().String(), c.GetRemoteAddress().String()).Add(1)
}

func (m *metricsEvent) ClientDisconnected(c *rtr.Client) {
ClientsMetric.WithLabelValues(c.GetLocalAddress().String(), c.GetRemoteAddress().String()).Dec()
ClientsFlaps.WithLabelValues(c.GetLocalAddress().String(), c.GetRemoteAddress().String()).Add(1)
}

func (m *metricsEvent) HandlePDU(c *rtr.Client, pdu rtr.PDU) {
Expand All @@ -707,7 +717,9 @@ func (m *metricsEvent) HandlePDU(c *rtr.Client, pdu rtr.PDU) {
rtr.TypeToString(
pdu.GetType()),
" ",
"_", -1))).Inc()
"_", -1)),
c.GetRemoteAddress().String(),
).Inc()
}

func (m *metricsEvent) UpdateMetrics(numIPv4 int, numIPv6 int, numIPv4filtered int, numIPv6filtered int, changed time.Time, refreshed time.Time, file string, brkCount int, aspaCount int) {
Expand Down

0 comments on commit 5bd7849

Please sign in to comment.