Files
unpoller_unpoller/pkg/datadogunifi/port_forward.go
T
Cody LeeandClaude Opus 4.7 d2948b8bd0 feat: upgrade unifi to v5.26.0 and add Integration/v1 + new legacy metrics
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>
2026-05-08 16:45:47 -05:00

55 lines
1.7 KiB
Go

package datadogunifi
import (
"github.com/unpoller/unifi/v5"
)
// batchPortForward generates PortForward datapoints for Datadog.
func (u *DatadogUnifi) batchPortForward(r report, pf *unifi.PortForward) {
if pf == nil {
return
}
metricName := metricNamespace("port_forward")
tags := cleanTags(map[string]string{
"site_name": pf.SiteName,
"source": pf.SourceName,
"id": pf.ID,
"name": pf.Name,
"proto": pf.Proto,
"fwd_ip": pf.FwdIP,
"fwd_port": pf.FwdPort,
"dst_port": pf.DstPort,
"pf_iface": pf.PfwdPf,
})
_ = r.reportGauge(metricName("enabled"), boolToFloat64(pf.Enabled.Val), tagMapToTags(tags))
_ = r.reportGauge(metricName("log"), boolToFloat64(pf.Log.Val), tagMapToTags(tags))
}
// batchSSLCertificate generates SSLCertificate datapoints for Datadog.
func (u *DatadogUnifi) batchSSLCertificate(r report, cert *unifi.SSLCertificate) {
if cert == nil || cert.ID == "" {
return
}
metricName := metricNamespace("ssl_cert")
tags := cleanTags(map[string]string{
"site_name": cert.SiteName,
"id": cert.ID,
"cert_type": cert.CertType,
"status": cert.Status,
"issuer": cert.Issuer,
"subject": cert.Subject,
"fingerprint": cert.Fingerprint,
})
_ = r.reportGauge(metricName("is_active"), boolToFloat64(cert.IsActive.Val), tagMapToTags(tags))
_ = r.reportGauge(metricName("is_valid"), boolToFloat64(cert.IsValid.Val), tagMapToTags(tags))
_ = r.reportGauge(metricName("valid_from"), cert.ValidFrom.Val, tagMapToTags(tags))
_ = r.reportGauge(metricName("valid_to"), cert.ValidTo.Val, tagMapToTags(tags))
_ = r.reportGauge(metricName("chain_length"), float64(len(cert.Chain)), tagMapToTags(tags))
}