[telemetry] add API for TREL telemetry (#9710)

Create OT API to support trel telemetry which is supported through
platform API and also add cli support to get/reset trel counters.

Metrics we are adding are:
- trel_frames_tx
- trel_bytes_tx
- trel_frames_rx
- trel_bytes_rx
- trel_frames_tx_failed
- num_trel_peers

Metrics already supported through API:
- trel_enabled
This commit is contained in:
Yang Liu
2024-01-06 14:10:27 +08:00
committed by GitHub
parent 09d07a7c6a
commit d81c6fab98
14 changed files with 261 additions and 11 deletions
+24
View File
@@ -1390,6 +1390,30 @@ class NodeImpl:
raise
def get_trel_counters(self):
cmd = 'trel counters'
self.send_command(cmd)
result = self._expect_command_output()
counters = {}
for line in result:
m = re.match(r'(\w+)\:[^\d]+(\d+)[^\d]+(\d+)(?:[^\d]+(\d+))?', line)
if m:
groups = m.groups()
sub_counters = {
'packets': int(groups[1]),
'bytes': int(groups[2]),
}
if groups[3]:
sub_counters['failures'] = int(groups[3])
counters[groups[0]] = sub_counters
return counters
def reset_trel_counters(self):
cmd = 'trel counters reset'
self.send_command(cmd)
self._expect_done()
def _encode_txt_entry(self, entry):
"""Encodes the TXT entry to the DNS-SD TXT record format as a HEX string.