From 945ed9950e3bb10014aa43750965b5b174e4a727 Mon Sep 17 00:00:00 2001 From: SharkoZ Date: Sun, 14 Feb 2021 15:49:23 +0100 Subject: [PATCH] added labels "vendor" and "ip" to lan_reachable --- gauges.go | 2 ++ main.go | 10 ++++++++-- structs.go | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gauges.go b/gauges.go index e7932a1..35d0e6c 100644 --- a/gauges.go +++ b/gauges.go @@ -141,6 +141,8 @@ var ( }, []string{ "name", // hostname + "vendor", + "ip", }, ) diff --git a/main.go b/main.go index b6f15af..3e82930 100644 --- a/main.go +++ b/main.go @@ -207,10 +207,16 @@ func main() { log.Printf("An error occured with LAN metrics: %v", err) } for _, v := range lanAvailable { + var Ip string + if len(v.L3c) > 0 { + Ip = v.L3c[0].Addr + } else { + Ip = "" + } if v.Reachable { - lanReachableGauges.WithLabelValues(v.PrimaryName).Set(float64(1)) + lanReachableGauges.With(prometheus.Labels{"name": v.PrimaryName, "vendor":v.Vendor_name, "ip": Ip}).Set(float64(1)) } else { - lanReachableGauges.WithLabelValues(v.PrimaryName).Set(float64(0)) + lanReachableGauges.With(prometheus.Labels{"name": v.PrimaryName, "vendor":v.Vendor_name, "ip": Ip}).Set(float64(0)) } } diff --git a/structs.go b/structs.go index efef738..32f23b8 100644 --- a/structs.go +++ b/structs.go @@ -156,9 +156,15 @@ type freeplugMember struct { } // https://dev.freebox.fr/sdk/os/lan/ +type l3c struct { + Addr string `json:"addr,omitempty"` +} + type lanHost struct { Reachable bool `json:"reachable,omitempty"` PrimaryName string `json:"primary_name,omitempty"` + Vendor_name string `json:"vendor_name,omitempty"` + L3c []l3c `json:"l3connectivities,omitempty"` } type lan struct {