Skip to content

Commit

Permalink
Add Fortinet exec ping template (#1480)
Browse files Browse the repository at this point in the history
Co-authored-by: pskliarenko <“[email protected]”>
  • Loading branch information
PavloSkliarenko and pskliarenko authored Jul 22, 2024
1 parent 2f09a14 commit 355b09a
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ntc_templates/templates/fortinet_execute_ping.textfsm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Value List SENT_PACKET_SIZE (\d+)
Value List SENT_PACKET_ADDRESS (\S+)
Value List SENT_PACKET_ICMP_SEQ (\d+)
Value List SENT_PACKET_TTL (\d+)
Value List SENT_PACKET_TIME (\d+(?:\.\d+)?)
Value ADDRESS (\S+)
Value TRANSMITTED (\d+)
Value RECEIVED (\d+)
Value PACKET_LOSS (\d+)
Value MIN_RTT (\d+(?:\.\d+)?)
Value AVG_RTT (\d+(?:\.\d+)?)
Value MAX_RTT (\d+(?:\.\d+)?)

Start
^\s*PING.*\s*$$
^\s*${SENT_PACKET_SIZE}\s+bytes\s+from\s+${SENT_PACKET_ADDRESS}:\s+icmp_seq=${SENT_PACKET_ICMP_SEQ}\s+ttl=${SENT_PACKET_TTL}\s+time=${SENT_PACKET_TIME}\s+.*$$
^\s*---\s+${ADDRESS}\s+ping\s+statistics\s+---\s*$$
^\s*${TRANSMITTED}\s+packets\s+transmitted\,\s+${RECEIVED}\s+packets\s+received\,\s+${PACKET_LOSS}\%\s+packet\s+loss\s*$$
^\s*round-trip\s+min/avg/max\s+=\s+${MIN_RTT}/${AVG_RTT}/${MAX_RTT}\s+ms\s*$$
^\s*$$
^. -> Error
1 change: 1 addition & 0 deletions ntc_templates/templates/index
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ fortinet_get_system_interface.textfsm, .*, fortinet, g[[et]] sy[[stem]] in[[terf
fortinet_get_system_status.textfsm, .*, fortinet, g[[et]] sy[[stem]] stat[[us]]
fortinet_get_hardware_nic.textfsm, .*, fortinet, g[[et]] hard[[ware]] n[[ic]]
fortinet_get_system_arp.textfsm, .*, fortinet, g[[et]] sy[[stem]] arp
fortinet_execute_ping.textfsm, .*, fortinet, exec[[ute]] ping
fortinet_execute_time.textfsm, .*, fortinet, exec[[ute]] ti[[me]]

hp_comware_display_lldp_neighbor-information_verbose.textfsm, .*, hp_comware, di[[splay]] ll[[dp]] n[[eighbor-information]] v[[erbose]]
Expand Down
10 changes: 10 additions & 0 deletions tests/fortinet/execute_ping/fortinet_execute_ping.raw
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=110 time=25.9 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=110 time=25.8 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=110 time=25.8 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=110 time=25.8 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=110 time=25.8 ms

--- 8.8.8.8 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 25.8/25.8/25.9 ms
39 changes: 39 additions & 0 deletions tests/fortinet/execute_ping/fortinet_execute_ping.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
parsed_sample:
- address: "8.8.8.8"
avg_rtt: "25.8"
max_rtt: "25.9"
min_rtt: "25.8"
packet_loss: "0"
received: "5"
sent_packet_address:
- "8.8.8.8"
- "8.8.8.8"
- "8.8.8.8"
- "8.8.8.8"
- "8.8.8.8"
sent_packet_icmp_seq:
- "0"
- "1"
- "2"
- "3"
- "4"
sent_packet_size:
- "64"
- "64"
- "64"
- "64"
- "64"
sent_packet_time:
- "25.9"
- "25.8"
- "25.8"
- "25.8"
- "25.8"
sent_packet_ttl:
- "110"
- "110"
- "110"
- "110"
- "110"
transmitted: "5"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PING 8.87.8.8 (8.87.8.8): 56 data bytes

--- 8.87.8.8 ping statistics ---
5 packets transmitted, 0 packets received, 100% packet loss
14 changes: 14 additions & 0 deletions tests/fortinet/execute_ping/fortinet_execute_ping_unreachable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
parsed_sample:
- address: "8.87.8.8"
avg_rtt: ""
max_rtt: ""
min_rtt: ""
packet_loss: "100"
received: "0"
sent_packet_address: []
sent_packet_icmp_seq: []
sent_packet_size: []
sent_packet_time: []
sent_packet_ttl: []
transmitted: "5"

0 comments on commit 355b09a

Please sign in to comment.