diff --git a/src/__main__.py b/src/__main__.py index 39cd1b7..751552a 100644 --- a/src/__main__.py +++ b/src/__main__.py @@ -197,7 +197,7 @@ def send_to_influx(stats, config): current_time = datetime.now(UTC).strftime('%Y-%m-%dT%H:%M:%SZ') for stats_down in stats['downstream']: - series.append(Point.from_dict({ + data = { 'measurement': 'downstream_statistics', 'time': current_time, 'fields': { @@ -211,7 +211,12 @@ def send_to_influx(stats, config): 'channel_id': int(stats_down['channel_id']), 'modulation': stats_down['modulation'] } - })) + } + ## Only some modems, like the XB8, has the 'unerrored' value + if 'unerrored' in stats_down: + data['fields']['unerrored'] = int(stats_down['unerrored']) + + series.append(Point.from_dict(data)) for stats_up in stats['upstream']: series.append(Point.from_dict({ diff --git a/src/comcast_xb8_stats.py b/src/comcast_xb8_stats.py index cd187f3..2392d7f 100644 --- a/src/comcast_xb8_stats.py +++ b/src/comcast_xb8_stats.py @@ -119,6 +119,7 @@ def parse_html(html): # NOTE: Indexing by channel_id is important as this table might be ordered # differently than the "Channel Bonding" table parsed above. channel = stats['downstream'][channel_id] + channel['unerrored'] = codeword_rows[1].find_all("td")[i].text.strip() channel['corrected'] = codeword_rows[2].find_all("td")[i].text.strip() channel['uncorrectables'] = codeword_rows[3].find_all("td")[i].text.strip()