I'm trying to record optics light readings off a cisco RFGW. The issue I'm facing is that because of the way the data is displayed I capture the Physical interface twice and the data I want appended after each entry. I can of course fix it after I've collected the info but I'd like to avoid much data manipulation after parsing it the output.
Raw text:
HE-EQM-01#show interfaces transceiver detail | begin Transmit Power
Transmit Power Threshold Threshold Threshold Threshold
Port (dBm) (dBm) (dBm) (dBm) (dBm)
--------- ----------------- ---------- --------- --------- ---------
Te1/2 -3.0 1.6 -1.3 -7.3 -11.3
Te1/3 -17.3 1.6 -1.3 -7.3 -11.3
Te1/4 -40.0 1.6 -1.3 -7.3 -11.3
Te2/2 -3.1 1.6 -1.3 -7.3 -11.3
Te2/3 -40.0 1.6 -1.3 -7.3 -11.3
Te2/4 -40.0 1.6 -1.3 -7.3 -11.3
Optical High Alarm High Warn Low Warn Low Alarm
Receive Power Threshold Threshold Threshold Threshold
Port (dBm) (dBm) (dBm) (dBm) (dBm)
------- ----------------- ---------- --------- --------- ---------
Te1/2 -40.0 1.9 -1.0 -9.9 -13.9
Te1/3 -2.6 1.9 -1.0 -9.9 -13.9
Te1/4 -2.9 1.9 -1.0 -9.9 -13.9
Te2/2 -3.0 1.9 -1.0 -9.9 -13.9
Te2/3 -2.6 1.9 -1.0 -9.9 -13.9
Template:
Value interface (\w+\d\/\d+)
Value tx (-*\d+\.\d+)
Value rx (-*\d+\.\d+)
Start
^\s*Transmit\s*Power.+
^\s*${interface}\s+${tx} -> Record
Output:
[['Te1/2', '-3.0', ''],
['Te1/3', '-17.3', ''],
['Te1/4', '-40.0', ''],
['Te2/2', '-3.1', ''],
['Te2/3', '-40.0', ''],
['Te2/4', '-40.0', ''],
['Te1/2', '-40.0', ''],
['Te1/3', '-2.6', ''],
['Te1/4', '-2.9', ''],
['Te2/2', '-3.0', ''],
['Te2/3', '-2.6', ''],
['Te2/4', '-2.4', '']]
Preferably:
[['Te1/2', '-3.0', '-40.0'],
['Te1/3', '-17.3', '-2.6'],
['Te1/4', '-40.0', '-2.9'],
['Te2/2', '-3.1', '-3.0'],
['Te2/3', '-40.0', '-2.6'],
['Te2/4', '-40.0', '-2.4'],