Skip to content

Commit

Permalink
Merge pull request #1 from mjbear/asa_sh_run_obj_service_pr1970
Browse files Browse the repository at this point in the history
Simplify structured data and add support for operators and ICMP
  • Loading branch information
wollmannbruno authored Jan 14, 2025
2 parents 183466b + 18572ec commit 4e14881
Show file tree
Hide file tree
Showing 9 changed files with 296 additions and 227 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Value PORT (\S+)
Value STATUS (\S+)
Value ADMIN_STATUS (\S+)
Value PORT_DOWN_VIOLATION_REASON (\S.+\S)
Value LAST_TIME_LINK_CHANGED (\S.+\S)
Value PORT_DOWN_VIOLATION_REASON (.+?)
Value LAST_TIME_LINK_CHANGED (.+?)
Value NUMBER_OF_STATUS_CHANGE (\d+)
Value PORT_TYPE (\S.+\S)
Value SFP_XFP (\S.+\S)
Value INTERFACE_TYPE (\S.+\S)
Value ETHERNET_POWER_POLICY (\S.+\S)
Value LINK_QUALITY (\S.+\S)
Value MAC_ADDRESS (\S.+\S)
Value PORT_TYPE (.+?)
Value SFP_XFP (.+?)
Value INTERFACE_TYPE (.+?)
Value ETHERNET_POWER_POLICY (.+?)
Value LINK_QUALITY (.+?)
Value MAC_ADDRESS (.+?)
Value BANDWIDTH (\d+)
Value DUPLEX (\S+)
Value AUTONEGOTIATION (\S.+\S)
Value AUTONEGOTIATION (.+?)
Value LONG_FRAME_SIZE (\d+)
Value INTER_FRAME_GAP (\d+)
Value LOOPBACK_MODE (\S.+\S)
Value LOOPBACK_MODE (.+?)
Value RX_BYTES_RECEIVED (\d+)
Value RX_BROADCAST_FRAMES (\d+)
Value RX_UNDERSIZE_FRAMES (\d+)
Expand All @@ -39,48 +39,44 @@ Value TX_COLLISIONS (\d+)
Value TX_LATE_COLLISIONS (\d+)
Value TX_EXCESSIVE_COLLISIONS (\d+)


Start
# R6
^\s*Slot\/Port\s*${PORT}\s*:\s*$$
# R8
^\s*Chassis\/Slot\/Port\s*:\s*${PORT}\s*$$
^\s*Operational\s*Status\s*:\s*${STATUS},\s*(?:"(?:${ADMIN_STATUS})?"\s*)?$$
^\s*Port-Down\/Violation\s*Reason\s*:\s*${PORT_DOWN_VIOLATION_REASON},\s*$$
^\s*Last\s*Time\s*Link\s*Changed\s*:\s*${LAST_TIME_LINK_CHANGED}\s*,\s*$$
^\s*Number\s*of\s*Status\s*Change\s*:\s*${NUMBER_OF_STATUS_CHANGE},\s*$$
^\s*Type\s*:\s*${PORT_TYPE},\s*$$
^\s*SFP\/(?:SFP\+\/)?XFP\s*:\s*${SFP_XFP},\s*$$
^\s*Interface\s*Type\s*:\s*${INTERFACE_TYPE},\s*$$
^\s*EPP\s*:\s*${ETHERNET_POWER_POLICY},\s*$$
^\s*Link-Quality\s*:\s*${LINK_QUALITY},\s*$$
^\s*MAC\s*address\s*:\s*${MAC_ADDRESS},\s*$$
^\s*BandWidth\s*\(Megabits\)\s*:\s*(-|${BANDWIDTH})\s*,\s*Duplex\s*:\s*(-|${DUPLEX})\s*,\s*$$
^\s*Autonegotiation\s*:\s*\d+\s*\[(\s*|\s*${AUTONEGOTIATION}\s*)\],\s*$$
^\s*Long\s*Frame\s*Size\(Bytes\)\s*:\s*${LONG_FRAME_SIZE},\s*$$
^\s*Inter\s*Frame\s*Gap\(Bytes\)\s*:\s*${INTER_FRAME_GAP},\s*$$
^\s*loopback\s*mode\s*:\s*${LOOPBACK_MODE},\s*$$
^\s*(Chassis\/)?Slot\/Port\s*(:\s+)?${PORT}(\s+:)?\s*$$
^\s*Operational\s+Status\s*:\s+${STATUS},(?:\s+"(?:${ADMIN_STATUS})?")?\s*$$
^\s*Port-Down\/Violation\s+Reason\s*:\s+${PORT_DOWN_VIOLATION_REASON},\s*$$
^\s*Last\s+Time\s+Link\s+Changed\s*:\s+${LAST_TIME_LINK_CHANGED}\s*,\s*$$
^\s*Number\s+of\s+Status\s+Change\s*:\s+${NUMBER_OF_STATUS_CHANGE},\s*$$
^\s*Type\s*:\s+${PORT_TYPE},\s*$$
^\s*(?:SFP\+?\/)+XFP\s*:\s+${SFP_XFP},\s*$$
^\s*Interface\s+Type\s*:\s+${INTERFACE_TYPE},\s*$$
^\s*EPP\s*:\s+${ETHERNET_POWER_POLICY},\s*$$
^\s*Link-Quality\s*:\s+${LINK_QUALITY},\s*$$
^\s*MAC\s+address\s*:\s+${MAC_ADDRESS},\s*$$
^\s*Band[Ww]idth\s+\(Megabits\)\s*:\s+(-|${BANDWIDTH})\s*,\s+Duplex\s+:\s+(-|${DUPLEX})\s*,\s*$$
^\s*Autonegotiation\s*:\s+\d+\s+\[(\s*${AUTONEGOTIATION}?\s*)\],\s*$$
^\s*Long\s+Frame\s+Size\(Bytes\)\s*:\s+${LONG_FRAME_SIZE},\s*$$
^\s*Inter\s+Frame\s+Gap\(Bytes\)\s*:\s+${INTER_FRAME_GAP},\s*$$
^\s*loopback\s+mode\s*:\s+${LOOPBACK_MODE},\s*$$
^\s*Rx\s*:\s*$$ -> RX_Table
^\s*Tx\s*:\s*$$ -> TX_Table
^\s*$$
^.+ -> Error

RX_Table
^\s*Bytes\s*Received\s*:\s*${RX_BYTES_RECEIVED},\s*Unicast\s*Frames\s*:\s*${RX_UNICAST_FRAMES},\s*$$
^\s*Broadcast\s*Frames\s*:\s*${RX_BROADCAST_FRAMES},\s*M-cast\s*Frames\s*:\s*${RX_MULTICAST_FRAMES},\s*$$
^\s*UnderSize\s*Frames\s*:\s*${RX_UNDERSIZE_FRAMES},\s*OverSize\s*Frames\s*:\s*${RX_OVERSIZE_FRAMES},\s*$$
^\s*Lost\s*Frames\s*:\s*${RX_LOST_FRAMES},\s*Error\s*Frames\s*:\s*${RX_ERROR_FRAMES},\s*$$
^\s*CRC\s*Error\s*Frames\s*:\s*${RX_CRC_ERROR_FRAMES},\s*Alignments\s*Err\s*:\s*${RX_ALIGNMENT_ERRORS},\s*$$ -> Start
^\s*Bytes\s+Received\s*:\s+${RX_BYTES_RECEIVED},\s+Unicast\s+Frames\s*:\s+${RX_UNICAST_FRAMES},\s*$$
^\s*Broadcast\s+Frames\s*:\s+${RX_BROADCAST_FRAMES},\s+M-cast\s+Frames\s*:\s+${RX_MULTICAST_FRAMES},\s*$$
^\s*UnderSize\s+Frames\s*:\s+${RX_UNDERSIZE_FRAMES},\s+OverSize\s+Frames\s*:\s+${RX_OVERSIZE_FRAMES},\s*$$
^\s*Lost\s+Frames\s*:\s+${RX_LOST_FRAMES},\s+Error\s+Frames\s*:\s+${RX_ERROR_FRAMES},\s*$$
^\s*CRC\s+Error\s+Frames\s*:\s+${RX_CRC_ERROR_FRAMES},\s+Alignments\s+Err\s*:\s+${RX_ALIGNMENT_ERRORS},\s*$$ -> Start
^\s*$$
^. -> Error

TX_Table
^\s*Bytes\s*Xmitted\s*:\s*${TX_BYTES_TRANSMITTED},\s*Unicast\s*Frames\s*:\s*${TX_UNICAST_FRAMES},\s*$$
^\s*Broadcast\s*Frames\s*:\s*${TX_BROADCAST_FRAMES},\s*M-cast\s*Frames\s*:\s*${TX_MULTICAST_FRAMES},\s*$$
^\s*UnderSize\s*Frames\s*:\s*${TX_UNDERSIZE_FRAMES},\s*OverSize\s*Frames\s*:\s*${TX_OVERSIZE_FRAMES},\s*$$
^\s*Lost\s*Frames\s*:\s*${TX_LOST_FRAMES},\s*Collided\s*Frames\s*:\s*${TX_COLLIDED_FRAMES},\s*$$
^\s*Error\s*Frames\s*:\s*${TX_ERROR_FRAMES}\s*$$ -> Record Start
^\s*Error\s*Frames\s*:\s*${TX_ERROR_FRAMES}(?:,\s*Collisions\s*:\s*${TX_COLLISIONS},)?\s*$$
^\s*Late\s*collisions\s*:\s*${TX_LATE_COLLISIONS},\s*Exc-Collisions\s*:\s*${TX_EXCESSIVE_COLLISIONS}\s*$$ -> Record Start
^\s*Bytes\s+Xmitted\s*:\s+${TX_BYTES_TRANSMITTED},\s+Unicast\s+Frames\s*:\s+${TX_UNICAST_FRAMES},\s*$$
^\s*Broadcast\s+Frames\s*:\s+${TX_BROADCAST_FRAMES},\s+M-cast\s+Frames\s*:\s+${TX_MULTICAST_FRAMES},\s*$$
^\s*UnderSize\s+Frames\s*:\s+${TX_UNDERSIZE_FRAMES},\s+OverSize\s+Frames\s*:\s+${TX_OVERSIZE_FRAMES},\s*$$
^\s*Lost\s+Frames\s*:\s+${TX_LOST_FRAMES},\s+Collided\s+Frames\s*:\s+${TX_COLLIDED_FRAMES},\s*$$
^\s*Error\s+Frames\s*:\s+${TX_ERROR_FRAMES}\s*$$ -> Record Start
^\s*Error\s+Frames\s*:\s+${TX_ERROR_FRAMES}(?:,\s+Collisions\s*:\s+${TX_COLLISIONS},)?\s*$$
^\s*Late\s+collisions\s*:\s+${TX_LATE_COLLISIONS},\s+Exc-Collisions\s*:\s+${TX_EXCESSIVE_COLLISIONS}\s*$$ -> Record Start
^\s*$$
^. -> Error
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
Value Required NAME (\S+)
Value DESCRIPTION (.+?)
Value PROTOCOL ([a-z]+)
Value SRC_PORT_EQ (\S+)
Value SRC_PORT_GT (\S+)
Value SRC_PORT_LT (\S+)
Value PROTOCOL (\S+)
Value SRC_OPERATOR (\S+)
Value SRC_PORT_START (\S+)
Value SRC_PORT_END (\S+)
Value DST_PORT_EQ (\S+)
Value DST_PORT_GT (\S+)
Value DST_PORT_LT (\S+)
Value DST_OPERATOR (\S+)
Value DST_PORT_START (\S+)
Value DST_PORT_END (\S+)
Value ICMP_TYPE (\S+)
Value ICMP_CODE (\S+)

Start
^object\s+service -> Continue.Record
^object\s+service\s+${NAME}\s*$$
^\s+description\s+${DESCRIPTION}\s*$$
^\s+service\s+${PROTOCOL}(\s+source\s+(eq\s+${SRC_PORT_EQ}|gt\s+${SRC_PORT_GT}|lt\s+${SRC_PORT_LT}|range\s+${SRC_PORT_START}\s+${SRC_PORT_END}))?(\s+destination\s+(eq\s+${DST_PORT_EQ}|gt\s+${DST_PORT_GT}|lt\s+${DST_PORT_LT}|range\s+${DST_PORT_START}\s+${DST_PORT_END}))?\s*$$
^\s+service\s+${PROTOCOL}(\s+${ICMP_TYPE}(\s+${ICMP_CODE})?)?\s*$$
^\s+service\s+${PROTOCOL}(\s+source\s+${SRC_OPERATOR}\s+${SRC_PORT_START}(\s+${SRC_PORT_END})?)?(\s+destination\s+${DST_OPERATOR}\s+${DST_PORT_START}(\s+${DST_PORT_END})?)?\s*$$
^. -> Error "Did not match any lines"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Value VERSION (\S+)
Value STARTUP_VERSION (\S+)

Start
^\s*Version:\s+${VERSION}\s*$$
^\s*Startup-Vers:\s+${STARTUP_VERSION}\s*$$
^. -> Error
4 changes: 3 additions & 1 deletion ntc_templates/templates/index
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
Template, Hostname, Platform, Command

alcatel_aos_show_interfaces_ethernet.textfsm, .*, alcatel_aos, sh[[ow]] (in[[terfaces]] e[[thernet]]|in[[terfaces]])$$
alcatel_aos_show_interfaces_ethernet.textfsm, .*, alcatel_aos, sh[[ow]] (in[[terfaces]] e[[thernet]]|in[[terfaces]])$
alcatel_aos_show_lldp_remote-system.textfsm, .*, alcatel_aos, sh[[ow]] lldp r[[emote-system]]
alcatel_aos_show_interfaces_status.textfsm, .*, alcatel_aos, sh[[ow]] in[[terfaces]] st[[atus]]
alcatel_aos_show_mac-address-table.textfsm, .*, alcatel_aos, sh[[ow]] mac-(a[[ddress-table]]|l[[earning]])
Expand Down Expand Up @@ -243,6 +243,8 @@ cisco_asa_dir.textfsm, .*, cisco_asa, dir

cisco_ftd_show_vpn-sessiondb_anyconnect.textfsm, .*, cisco_ftd, sh[[ow]] vpn-[[sessiondb]] a[[nyconnect]]

cisco_fxos_show_system_firmware.textfsm, .*, cisco_fxos, sh[[ow]] sy[[stem]] fi[[rmware]]

cisco_ios_show_module.textfsm:cisco_ios_show_module_status.textfsm:cisco_ios_show_module_submodule.textfsm:cisco_ios_show_module_online_diag.textfsm, .*, cisco_ios, sh[[ow]] mod[[ule]]
cisco_ios_show_switch_detail.textfsm:cisco_ios_show_switch_detail_stack_ports.textfsm, .*, cisco_ios, sh[[ow]] sw[[itch]] d[[etail]]
cisco_ios_show_authentication_sessions_method_details.textfsm, .*, cisco_ios, show authen[[tication]] ses[[sions]] met[[hod]](\s+d[[ot1x]]|\s+m[[ab]])? det[[ails]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object service twelve
description test twelve
service tcp source lt 8000 destination range 9000 9999
object service thirteen
description test twthirteeno
description test thirteen
service tcp source range 8000 8999 destination eq 9000
object service fourteen
description test fourteen
Expand Down Expand Up @@ -69,3 +69,21 @@ object service twenty-three
service tcp destination lt 8000
object service twenty-four
service udp destination range 8000 8999
object service twenty-five
service tcp source range 1 1024 destination eq https
object service twenty-six
service tcp destination eq http
object service twenty-seven
service tcp source eq ssh
object service twenty-eight
service icmp echo
object service twenty-nine
service icmp
object service thirty
service icmp 9 16
object service thirty-one
description Except for IRC-based botnet C&C traffic
service tcp destination neq 6667
object service thirty-two
description Numeric protocol
service 137
Loading

0 comments on commit 4e14881

Please sign in to comment.