Skip to content

Commit

Permalink
Remove online devices
Browse files Browse the repository at this point in the history
  • Loading branch information
r-darwish committed Nov 23, 2021
1 parent 1bde211 commit ae3b415
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 14 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Connect Prometheus to port 9919 of the machine running this daemon

## Metrics

* `deco_device_online` - Connected clients
* `deco_download_speed` - Client download speed
* `deco_upload_speed` - Client upload speed
* `deco_errors` - Errors encountered by the daemon
13 changes: 0 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ import (
)

var (
deviceOnline = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "deco_device_online",
Help: "Online devices",
}, []string{"device"})

uploadSpeed = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "deco_download_speed",
Help: "Online devices",
Expand All @@ -43,7 +38,6 @@ func main() {
log.Fatal(err.Error())
}

prometheus.MustRegister(deviceOnline)
prometheus.MustRegister(uploadSpeed)
prometheus.MustRegister(downloadSpeed)
prometheus.MustRegister(errors)
Expand All @@ -61,7 +55,6 @@ func main() {

func updateDevices(c *deco.Client) {
currentNames := make(map[string]struct{})
deviceOnline.DeleteLabelValues()
devices, err := c.ClientList()
if err != nil {
log.Println(err)
Expand All @@ -75,12 +68,7 @@ func updateDevices(c *deco.Client) {
}
for _, client := range devices.Result.ClientList {
currentNames[client.Name] = exists
clientOnline := 0
if client.Online {
clientOnline = 1
}

deviceOnline.WithLabelValues(client.Name).Set(float64(clientOnline))
uploadSpeed.WithLabelValues(client.Name).Set(float64(client.UpSpeed))
downloadSpeed.WithLabelValues(client.Name).Set(float64(client.DownSpeed))
}
Expand All @@ -89,7 +77,6 @@ func updateDevices(c *deco.Client) {
for client := range *names {
_, present := currentNames[client]
if !present {
deviceOnline.DeleteLabelValues(client)
uploadSpeed.DeleteLabelValues(client)
downloadSpeed.DeleteLabelValues(client)
}
Expand Down

0 comments on commit ae3b415

Please sign in to comment.