feat: add ipv4_port_range

This commit is contained in:
nyyu 2023-03-04 22:44:07 +01:00
parent 24fc2a21f5
commit ee7e1806e2
2 changed files with 7 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
"fmt"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/trazfr/freebox-exporter/fbx" "github.com/trazfr/freebox-exporter/fbx"
@ -24,7 +25,7 @@ var (
promDescInfo = prometheus.NewDesc( promDescInfo = prometheus.NewDesc(
metricPrefix+"info", metricPrefix+"info",
"constant metric with value=1. Various information about the Freebox", "constant metric with value=1. Various information about the Freebox",
[]string{"firmware", "mac", "serial", "boardname", "box_flavor", "connection_type", "connection_state", "connection_media", "ipv4", "ipv6"}, nil) []string{"firmware", "mac", "serial", "boardname", "box_flavor", "connection_type", "connection_state", "connection_media", "ipv4", "ipv6", "ipv4_port_range"}, nil)
promDescSystemUptime = prometheus.NewDesc( promDescSystemUptime = prometheus.NewDesc(
metricPrefix+"system_uptime", metricPrefix+"system_uptime",
@ -240,6 +241,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) {
var cnxMedia string var cnxMedia string
var cnxIPv4 string var cnxIPv4 string
var cnxIPv6 string var cnxIPv6 string
var cnxIPv4PortRange string
go func() { go func() {
defer wg.Done() defer wg.Done()
log.Debug.Println("Collect connection") log.Debug.Println("Collect connection")
@ -250,6 +252,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) {
cnxMedia = m.Media cnxMedia = m.Media
cnxIPv4 = m.IPv4 cnxIPv4 = m.IPv4
cnxIPv6 = m.IPv6 cnxIPv6 = m.IPv6
cnxIPv4PortRange = fmt.Sprintf("%d-%d", m.IPv4PortRange[0], m.IPv4PortRange[1])
c.collectCounter(ch, m.RateUp, promDescConnectionRatesBytes, "tx") c.collectCounter(ch, m.RateUp, promDescConnectionRatesBytes, "tx")
c.collectCounter(ch, m.RateDown, promDescConnectionRatesBytes, "rx") c.collectCounter(ch, m.RateDown, promDescConnectionRatesBytes, "rx")
@ -530,7 +533,8 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) {
cnxState, cnxState,
cnxMedia, cnxMedia,
cnxIPv4, cnxIPv4,
cnxIPv6) cnxIPv6,
cnxIPv4PortRange)
} }
func (c *Collector) collectXdslStats(ch chan<- prometheus.Metric, stats *fbx.MetricsFreeboxConnectionXdslStats, dir string) { func (c *Collector) collectXdslStats(ch chan<- prometheus.Metric, stats *fbx.MetricsFreeboxConnectionXdslStats, dir string) {

View File

@ -47,7 +47,7 @@ type MetricsFreeboxConnection struct {
BandwidthDown *int64 `json:"bandwidth_down"` BandwidthDown *int64 `json:"bandwidth_down"`
BytesUp *int64 `json:"bytes_up"` BytesUp *int64 `json:"bytes_up"`
BytesDown *int64 `json:"bytes_down"` BytesDown *int64 `json:"bytes_down"`
// ipv4_port_range IPv4PortRange []int64 `json:"ipv4_port_range"`
} }
// MetricsFreeboxConnectionXdslStats https://dev.freebox.fr/sdk/os/connection/#XdslStats // MetricsFreeboxConnectionXdslStats https://dev.freebox.fr/sdk/os/connection/#XdslStats