mirror of
https://github.com/unpoller/unpoller.git
synced 2026-09-30 03:21:28 +02:00
Collects Protect device data (sensors, cameras, lights, bridges, link stations, NVR) via the official Integration API and exports it through Prometheus, InfluxDB, and DataDog. Opt-in via save_protect_devices, gated by protect_api_key. Bumps github.com/unpoller/unifi to v6, which added the Protect API client (breaking change: FlexInt/FlexBool/FlexFloat replace nullable pointers).
48 lines
899 B
Go
48 lines
899 B
Go
package influxunifi
|
|
|
|
import (
|
|
"github.com/unpoller/unifi/v6"
|
|
)
|
|
|
|
// batchFirewallPolicy generates a firewall policy datapoint for InfluxDB.
|
|
func (u *InfluxUnifi) batchFirewallPolicy(r report, p *unifi.FirewallPolicy) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
|
|
tags := map[string]string{
|
|
"rule_name": p.Name,
|
|
"action": p.Action,
|
|
"protocol": p.Protocol,
|
|
"ip_version": p.IPVersion,
|
|
"source_zone": p.Source.ZoneID,
|
|
"dest_zone": p.Destination.ZoneID,
|
|
"site_name": p.SiteName,
|
|
"source": p.SourceName,
|
|
}
|
|
|
|
enabled := 0
|
|
if p.Enabled.Val {
|
|
enabled = 1
|
|
}
|
|
|
|
predefined := 0
|
|
if p.Predefined.Val {
|
|
predefined = 1
|
|
}
|
|
|
|
logging := 0
|
|
if p.Logging.Val {
|
|
logging = 1
|
|
}
|
|
|
|
fields := map[string]any{
|
|
"enabled": enabled,
|
|
"index": p.Index.Val,
|
|
"predefined": predefined,
|
|
"logging": logging,
|
|
}
|
|
|
|
r.send(&metric{Table: "firewall_policy", Tags: tags, Fields: fields})
|
|
}
|