mirror of
https://github.com/unpoller/unpoller.git
synced 2026-09-30 11:36:41 +02:00
Adds 21 new data types from unifi v5.26.0 across all metric output plugins (InfluxDB, Prometheus, DataDog). Per-site Integration/v1 calls are gated on API key configuration and only run for user-configured sites; ErrEndpointNotFound is handled gracefully so older firmware continues to work without log spam. Also migrates events collection (collectAlarms, collectAnomalies, collectEvents, collectIDs, collectProtectLogs) to handle Network 10.x+ endpoint removals via ErrEndpointNotFound, with debug-level logging to avoid per-poll noise. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package datadogunifi
|
|
|
|
import (
|
|
"github.com/unpoller/unifi/v5"
|
|
)
|
|
|
|
// batchUPSDevice generates UPS device selector datapoints for Datadog.
|
|
func (u *DatadogUnifi) batchUPSDevice(r report, ups *unifi.UPSDeviceSelector) {
|
|
if ups == nil {
|
|
return
|
|
}
|
|
|
|
metricName := metricNamespace("ups_device")
|
|
|
|
tags := cleanTags(map[string]string{
|
|
"site_name": ups.SiteName,
|
|
"source": ups.SourceName,
|
|
"id": ups.ID,
|
|
"mac": ups.MAC,
|
|
"label": ups.Label,
|
|
})
|
|
|
|
// Emit a presence gauge (1.0 = device exists in the adoption list).
|
|
_ = r.reportGauge(metricName("present"), 1.0, tagMapToTags(tags))
|
|
}
|
|
|
|
// batchWANStatus generates WAN status datapoints for Datadog.
|
|
func (u *DatadogUnifi) batchWANStatus(r report, ws *unifi.WANStatus) {
|
|
if ws == nil {
|
|
return
|
|
}
|
|
|
|
metricName := metricNamespace("wan_status")
|
|
|
|
for i := range ws.WANInterfaces {
|
|
iface := &ws.WANInterfaces[i]
|
|
|
|
active := 0.0
|
|
if iface.State == "ACTIVE" {
|
|
active = 1.0
|
|
}
|
|
|
|
tags := cleanTags(map[string]string{
|
|
"site_name": ws.SiteName,
|
|
"wan_name": iface.Name,
|
|
"wan_networkgroup": iface.WANNetworkgroup,
|
|
"state": iface.State,
|
|
})
|
|
|
|
_ = r.reportGauge(metricName("active"), active, tagMapToTags(tags))
|
|
}
|
|
}
|