Compare commits
No commits in common. "e5470dec4f71cbe601cf764d5387efc45ecbdb89" and "1dd976e37fa1c7f8cdd77cbd1cac21166c4ef91a" have entirely different histories.
e5470dec4f
...
1dd976e37f
@ -31,28 +31,6 @@ func collectDevices(client *tailscale.Client) []prometheus.Collector {
|
|||||||
[]string{"id", "created", "name"},
|
[]string{"id", "created", "name"},
|
||||||
)
|
)
|
||||||
|
|
||||||
deviceLastSeen := prometheus.NewGaugeVec(
|
|
||||||
prometheus.GaugeOpts{
|
|
||||||
Name: "tailscale_devices_last_seen",
|
|
||||||
Help: "The last time the device was active on the tailnet",
|
|
||||||
ConstLabels: prometheus.Labels{
|
|
||||||
"tailnet": client.GetTailnet(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[]string{"id", "created", "name"},
|
|
||||||
)
|
|
||||||
|
|
||||||
deviceLastSeenAgo := prometheus.NewGaugeVec(
|
|
||||||
prometheus.GaugeOpts{
|
|
||||||
Name: "tailscale_devices_last_seen_ago",
|
|
||||||
Help: "The number of seconds since the device was last active on the tailnet",
|
|
||||||
ConstLabels: prometheus.Labels{
|
|
||||||
"tailnet": client.GetTailnet(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[]string{"id", "created", "name"},
|
|
||||||
)
|
|
||||||
|
|
||||||
deviceUpdateAvailable := prometheus.NewGaugeVec(
|
deviceUpdateAvailable := prometheus.NewGaugeVec(
|
||||||
prometheus.GaugeOpts{
|
prometheus.GaugeOpts{
|
||||||
Name: "tailscale_devices_update_available",
|
Name: "tailscale_devices_update_available",
|
||||||
@ -73,8 +51,6 @@ func collectDevices(client *tailscale.Client) []prometheus.Collector {
|
|||||||
// Reset gauges so we don't leave old devices around
|
// Reset gauges so we don't leave old devices around
|
||||||
deviceExpiry.Reset()
|
deviceExpiry.Reset()
|
||||||
deviceSecondsRemaining.Reset()
|
deviceSecondsRemaining.Reset()
|
||||||
deviceLastSeen.Reset()
|
|
||||||
deviceLastSeenAgo.Reset()
|
|
||||||
deviceUpdateAvailable.Reset()
|
deviceUpdateAvailable.Reset()
|
||||||
|
|
||||||
for _, device := range devices {
|
for _, device := range devices {
|
||||||
@ -85,10 +61,6 @@ func collectDevices(client *tailscale.Client) []prometheus.Collector {
|
|||||||
deviceSecondsRemaining.With(prometheus.Labels{"id": device.ID, "created": device.Created.String(), "name": device.Name}).Set(remainingSeconds)
|
deviceSecondsRemaining.With(prometheus.Labels{"id": device.ID, "created": device.Created.String(), "name": device.Name}).Set(remainingSeconds)
|
||||||
}
|
}
|
||||||
|
|
||||||
secondsAgo := time.Since(device.LastSeen.Time).Seconds()
|
|
||||||
deviceLastSeen.With(prometheus.Labels{"id": device.ID, "created": device.Created.String(), "name": device.Name}).Set(float64(device.LastSeen.Unix()))
|
|
||||||
deviceLastSeenAgo.With(prometheus.Labels{"id": device.ID, "created": device.Created.String(), "name": device.Name}).Set(secondsAgo)
|
|
||||||
|
|
||||||
updateAvailable := 0.0
|
updateAvailable := 0.0
|
||||||
if device.UpdateAvailable {
|
if device.UpdateAvailable {
|
||||||
updateAvailable = 1.0
|
updateAvailable = 1.0
|
||||||
@ -101,5 +73,5 @@ func collectDevices(client *tailscale.Client) []prometheus.Collector {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return []prometheus.Collector{deviceExpiry, deviceSecondsRemaining, deviceLastSeen, deviceLastSeenAgo, deviceUpdateAvailable}
|
return []prometheus.Collector{deviceExpiry, deviceSecondsRemaining, deviceUpdateAvailable}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user