I am trying to parse using textfsm but getting below error , any suggestions ? any easy way to just parse and print like below
Destination: 8.8.8.8
TX:15 packets
RX:15 packets
PKTLOSS:0%
right now i am generating output1 and from there want to parse using textfsm which is output2. but is there way to parse ping using texfsm directly from output0 ?
- name: output0
debug:
msg: "{{ping.results|map(attribute='output')|list}}"
- name: output1
debug:
msg:
- "{{r1.0.split('
')[-5]}} {{r1.0.split('
')[-4]}}"
- "{{r2.0.split('
')[-5]}} {{r2.0.split('
')[-4]}}"
vars:
r1: "{{ ping.results|map(attribute='output')|first }}"
r2: "{{ ping.results|map(attribute='output')|last }}"
register: externalping
- name: output2
debug:
msg: "{{externalping.msg | parse_cli_textfsm('templates/ping.textfsm')}}"
my textfsm template
Value Destination (S+)
Value TX (S+)
Value RX (S+)
Value PKTLOSS (S+)
Start
^---s+${Destination}s+pings+statisticss+---
s+${TX}s+packetss+transmitted,s+${RX}s+packetss+received,s+${PKTLOSS}s+packetss+loss+
-> Record
error on parsing ping results using textfsm
```TASK [output0]
*************************
ok: [route-server.ip.att.net] => {
"msg": [
[
" ping 8.8.8.8 count 15
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=118 time=4.108 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=118 time=4.100 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=118 time=4.115 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=118 time=7.177 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=118 time=4.132 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=118 time=4.129 ms
64 bytes from 8.8.8.8: icmp_seq=6 ttl=118 time=4.119 ms
64 bytes from 8.8.8.8: icmp_seq=7 ttl=118 time=4.155 ms
64 bytes from 8.8.8.8: icmp_seq=8 ttl=118 time=4.085 ms
64 bytes from 8.8.8.8: icmp_seq=9 ttl=118 time=4.075 ms
64 bytes from 8.8.8.8: icmp_seq=10 ttl=118 time=10.247 ms
64 bytes from 8.8.8.8: icmp_seq=11 ttl=118 time=4.274 ms
64 bytes from 8.8.8.8: icmp_seq=12 ttl=118 time=4.581 ms
64 bytes from 8.8.8.8: icmp_seq=13 ttl=118 time=4.125 ms
64 bytes from 8.8.8.8: icmp_seq=14 ttl=118 time=4.037 ms
--- 8.8.8.8 ping statistics ---
15 packets transmitted, 15 packets received, 0% packet loss
round-trip min/avg/max/stddev = 4.037/4.764/10.247/1.652 ms
rviews@route-server.ip.att.net>"
],
[
" ping 1.1.1.1 count 15
PING 1.1.1.1 (1.1.1.1): 56 data bytes
64 bytes from 1.1.1.1: icmp_seq=0 ttl=57 time=4.967 ms
64 bytes from 1.1.1.1: icmp_seq=1 ttl=57 time=4.934 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=57 time=4.969 ms
64 bytes from 1.1.1.1: icmp_seq=3 ttl=57 time=4.921 ms
64 bytes from 1.1.1.1: icmp_seq=4 ttl=57 time=4.994 ms
64 bytes from 1.1.1.1: icmp_seq=5 ttl=57 time=4.895 ms
64 bytes from 1.1.1.1: icmp_seq=6 ttl=57 time=4.588 ms
64 bytes from 1.1.1.1: icmp_seq=7 ttl=57 time=4.847 ms
64 bytes from 1.1.1.1: icmp_seq=8 ttl=57 time=5.001 ms
64 bytes from 1.1.1.1: icmp_seq=9 ttl=57 time=4.958 ms
64 bytes from 1.1.1.1: icmp_seq=10 ttl=57 time=4.845 ms
64 bytes from 1.1.1.1: icmp_seq=11 ttl=57 time=4.971 ms
64 bytes from 1.1.1.1: icmp_seq=12 ttl=57 time=5.003 ms
64 bytes from 1.1.1.1: icmp_seq=13 ttl=57 time=4.642 ms
64 bytes from 1.1.1.1: icmp_seq=14 ttl=57 time=4.914 ms
--- 1.1.1.1 ping statistics ---
15 packets transmitted, 15 packets received, 0% packet loss
round-trip min/avg/max/stddev = 4.588/4.897/5.003/0.121 ms
rviews@route-server.ip.att.net>"
]
]
}
TASK [output1]
*****************************************************
ok: [route-server.ip.att.net] => {
"msg": [
"--- 8.8.8.8 ping statistics ---
15 packets transmitted, 15 packets received, 0% packet loss
",
"--- 1.1.1.1 ping statistics ---
15 packets transmitted, 15 packets received, 0% packet loss
"
]
}
TASK [output2] ***************************************************
fatal: [route-server.ip.att.net]: FAILED! => {"msg": "parse_cli_textfsm input should be a string, but was given a input of "}```
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…