Allow PoE-providing ports to be scraped even when disabled

Ports providing PoE power are no longer considered "dead" even when
disabled or down. This allows users to collect PoE metrics from ports
that are disabled for security reasons but still providing power.

Fixes #910

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Cody Lee 2026-01-25 11:31:39 -06:00
parent 347467a969
commit 9e3debd58a
No known key found for this signature in database
4 changed files with 8 additions and 8 deletions

View File

@ -79,8 +79,8 @@ func (u *DatadogUnifi) batchUSWstat(sw *unifi.Sw) map[string]float64 {
//nolint:funlen
func (u *DatadogUnifi) batchPortTable(r report, t map[string]string, pt []unifi.Port) {
for _, p := range pt {
if !u.DeadPorts && (!p.Up.Val || !p.Enable.Val) {
continue // only record UP ports.
if !u.DeadPorts && (!p.Up.Val || !p.Enable.Val) && p.PoePower.Val == 0 {
continue // only record UP ports, or ports providing PoE power.
}
tags := cleanTags(map[string]string{

View File

@ -75,8 +75,8 @@ func (u *InfluxUnifi) batchUSWstat(sw *unifi.Sw) map[string]any {
//nolint:funlen
func (u *InfluxUnifi) batchPortTable(r report, t map[string]string, pt []unifi.Port) {
for _, p := range pt {
if !u.DeadPorts && (!p.Up.Val || !p.Enable.Val) {
continue // only record UP ports.
if !u.DeadPorts && (!p.Up.Val || !p.Enable.Val) && p.PoePower.Val == 0 {
continue // only record UP ports, or ports providing PoE power.
}
tags := map[string]string{

View File

@ -197,8 +197,8 @@ func (u *promUnifi) exportPDUstats(r report, labels []string, sw *unifi.Sw) {
func (u *promUnifi) exportPDUPrtTable(r report, labels []string, pt []unifi.Port) {
// Per-port data on a switch
for _, p := range pt {
if !u.DeadPorts && (!p.Up.Val || !p.Enable.Val) {
continue
if !u.DeadPorts && (!p.Up.Val || !p.Enable.Val) && p.PoePower.Val == 0 {
continue // skip dead ports unless they're providing PoE power
}
// Copy labels, and add four new ones.

View File

@ -176,8 +176,8 @@ func (u *promUnifi) exportUSWstats(r report, labels []string, sw *unifi.Sw) {
func (u *promUnifi) exportPRTtable(r report, labels []string, pt []unifi.Port) {
// Per-port data on a switch
for _, p := range pt {
if !u.DeadPorts && (!p.Up.Val || !p.Enable.Val) {
continue
if !u.DeadPorts && (!p.Up.Val || !p.Enable.Val) && p.PoePower.Val == 0 {
continue // skip dead ports unless they're providing PoE power
}
// Copy labels, and add four new ones.