Skip to content

Commit

Permalink
Merge pull request #48 from sharkoz/master
Browse files Browse the repository at this point in the history
added labels "vendor" and "ip" to lan_reachable
  • Loading branch information
saphoooo authored Feb 14, 2021
2 parents 62a0ffd + 945ed99 commit 20730e9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions gauges.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ var (
},
[]string{
"name", // hostname
"vendor",
"ip",
},
)

Expand Down
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down
6 changes: 6 additions & 0 deletions structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 20730e9

Please sign in to comment.