Skip to content

Commit

Permalink
Setting device info to 0 if device is offline
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Tanaka <[email protected]>
  • Loading branch information
pedro-stanaka committed Sep 22, 2024
1 parent 2ff0cef commit 90310f0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/exporter/air_monitor_lite.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,20 @@ func (a *AirMonitorLite) updateDeviceInfo(device client.Device) {
if device.Info.Status.Offline {
status = "offline"
}

value := 1.0
if device.Info.Status.Offline {
value = 0.0
}

a.m.deviceInfo.WithLabelValues(
device.Info.Name,
device.Info.MAC,
status,
device.Info.Product.EnName,
device.Info.Product.Code,
strconv.FormatInt(int64(device.Info.Product.ID), 10),
).Set(1)
).Set(value)

a.m.lastDataTimestamp.WithLabelValues(device.Info.MAC).Set(device.Data.Timestamp.Value)
}

0 comments on commit 90310f0

Please sign in to comment.