Skip to content

Commit 4f39ef4

Browse files
authored
Merge pull request #231 from itsDNNS/fix/ofdm-error-metrics
fix: omit error metrics for channels without error data
2 parents 2aca00d + 0689549 commit 4f39ef4

File tree

5 files changed

+23
-17
lines changed

5 files changed

+23
-17
lines changed

app/analyzer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ def analyze(data: dict) -> dict:
394394
"power": power,
395395
"modulation": ch.get("modulation") or ch.get("type", ""),
396396
"snr": snr,
397-
"correctable_errors": ch.get("corrErrors", 0),
398-
"uncorrectable_errors": ch.get("nonCorrErrors", 0),
397+
"correctable_errors": ch.get("corrErrors"),
398+
"uncorrectable_errors": ch.get("nonCorrErrors"),
399399
"docsis_version": "3.0",
400400
"health": health,
401401
"health_detail": health_detail,
@@ -416,8 +416,8 @@ def analyze(data: dict) -> dict:
416416
"power": power,
417417
"modulation": ch.get("modulation") or ch.get("type", ""),
418418
"snr": snr,
419-
"correctable_errors": ch.get("corrErrors", 0),
420-
"uncorrectable_errors": ch.get("nonCorrErrors", 0),
419+
"correctable_errors": ch.get("corrErrors"),
420+
"uncorrectable_errors": ch.get("nonCorrErrors"),
421421
"docsis_version": "3.1",
422422
"health": health,
423423
"health_detail": health_detail,
@@ -480,8 +480,8 @@ def analyze(data: dict) -> dict:
480480
us_powers = [c["power"] for c in us_channels if c["power"] is not None]
481481
ds_snrs = [c["snr"] for c in ds_channels if c["snr"] is not None]
482482

483-
total_corr = sum(c["correctable_errors"] for c in ds_channels)
484-
total_uncorr = sum(c["uncorrectable_errors"] for c in ds_channels)
483+
total_corr = sum(c["correctable_errors"] for c in ds_channels if c["correctable_errors"] is not None)
484+
total_uncorr = sum(c["uncorrectable_errors"] for c in ds_channels if c["uncorrectable_errors"] is not None)
485485

486486
us_bitrates = [c["theoretical_bitrate"] for c in us_channels if c["theoretical_bitrate"] is not None]
487487
us_capacity = round(sum(us_bitrates), 1) if us_bitrates else None

app/blueprints/data_bp.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,14 @@ def api_export():
133133
"|----|-----------|-------------|----------|------------|-------------|---------------|--------|--------|",
134134
]
135135
for ch in ds:
136+
corr = ch.get("correctable_errors")
137+
uncorr = ch.get("uncorrectable_errors")
138+
err_corr = f"{corr:,}" if corr is not None else "-"
139+
err_uncorr = f"{uncorr:,}" if uncorr is not None else "-"
136140
lines.append(
137141
f"| {ch.get('channel_id','')} | {ch.get('frequency','')} | {ch.get('power','')} "
138142
f"| {ch.get('snr', '-')} | {ch.get('modulation','')} "
139-
f"| {ch.get('correctable_errors', 0):,} | {ch.get('uncorrectable_errors', 0):,} "
143+
f"| {err_corr} | {err_uncorr} "
140144
f"| {ch.get('docsis_version','')} | {ch.get('health','')} |"
141145
)
142146
lines += [

app/drivers/cm3500.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ def _parse_ds_ofdm(self, table) -> list:
276276
"powerLevel": None,
277277
"mer": mer_data,
278278
"mse": None,
279-
"corrErrors": 0,
280-
"nonCorrErrors": 0,
279+
"corrErrors": None,
280+
"nonCorrErrors": None,
281281
})
282282
chan_id += 1
283283
except (ValueError, TypeError, IndexError) as e:

app/drivers/ultrahub7.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ def _parse_downstream_channels(self, channels: list) -> list:
308308
"mer": snr if snr > 0 else None, # DOCSIS 3.1 uses MER
309309
"mse": None, # Not provided
310310
"latency": 0,
311-
"corrErrors": 0, # Not provided by Ultra Hub 7 API
312-
"nonCorrErrors": 0 # Not provided by Ultra Hub 7 API
311+
"corrErrors": None, # Not provided by Ultra Hub 7 API
312+
"nonCorrErrors": None # Not provided by Ultra Hub 7 API
313313
})
314314

315315
except (ValueError, TypeError) as e:

app/prometheus.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,10 @@ def format_metrics(analysis, device_info, connection_info, last_poll_timestamp):
162162
"docsight_downstream_corrected_errors_total",
163163
)
164164
for ch in ds_channels:
165-
_metric_value(lines, "docsight_downstream_corrected_errors_total",
166-
ch.get("correctable_errors", 0),
167-
_channel_labels(ch))
165+
if ch.get("correctable_errors") is not None:
166+
_metric_value(lines, "docsight_downstream_corrected_errors_total",
167+
ch["correctable_errors"],
168+
_channel_labels(ch))
168169

169170
_metric_family_open(
170171
lines,
@@ -173,9 +174,10 @@ def format_metrics(analysis, device_info, connection_info, last_poll_timestamp):
173174
"docsight_downstream_uncorrected_errors_total",
174175
)
175176
for ch in ds_channels:
176-
_metric_value(lines, "docsight_downstream_uncorrected_errors_total",
177-
ch.get("uncorrectable_errors", 0),
178-
_channel_labels(ch))
177+
if ch.get("uncorrectable_errors") is not None:
178+
_metric_value(lines, "docsight_downstream_uncorrected_errors_total",
179+
ch["uncorrectable_errors"],
180+
_channel_labels(ch))
179181

180182
_metric_family_open(
181183
lines,

0 commit comments

Comments
 (0)