From 16467e98da5da90af98dd82356c7214ef8f80e03 Mon Sep 17 00:00:00 2001 From: PavloSkliarenko <78343937+PavloSkliarenko@users.noreply.github.com> Date: Mon, 22 Jul 2024 23:21:03 +0400 Subject: [PATCH] Add MikroTik RouterOS interface print detail template (#1494) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: pskliarenko <“pskliarenko@bsh.ru”> Co-authored-by: Jacob McGill <9847006+jmcgill298@users.noreply.github.com> --- ntc_templates/templates/index | 1 + ...ik_routeros_interface_print_detail.textfsm | 30 ++++ ...krotik_routeros_interface_print_detail.raw | 21 +++ ...krotik_routeros_interface_print_detail.yml | 149 ++++++++++++++++++ 4 files changed, 201 insertions(+) create mode 100644 ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm create mode 100644 tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.raw create mode 100644 tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.yml diff --git a/ntc_templates/templates/index b/ntc_templates/templates/index index 819c4f2dd9..a5974ce2d1 100644 --- a/ntc_templates/templates/index +++ b/ntc_templates/templates/index @@ -707,6 +707,7 @@ mikrotik_routeros_ip_arp_print_without-paging.textfsm, .*, mikrotik_routeros, [[ mikrotik_routeros_ip_address_export_verbose.textfsm, .*, mikrotik_routeros, [[/]]ip a[[ddress]] e[[xport]] [[verbose]] mikrotik_routeros_interface_ethernet_print.textfsm, .*, mikrotik_routeros, [[/]]in[[terface]] et[[hernet]] pr[[int]] mikrotik_routeros_system_routerboard_print.textfsm, .*, mikrotik_routeros, [[/]]system routerboard print +mikrotik_routeros_interface_print_detail.textfsm, .*, mikrotik_routeros, [[/]]in[[terface]] p[[rint]] d[[etail]] mikrotik_routeros_interface_print_brief.textfsm, .*, mikrotik_routeros, [[/]]in[[terface]] p[[rint]] b[[rief]] mikrotik_routeros_ip_route_print_detail.textfsm, .*, mikrotik_routeros, [[/]]ip r[[oute]] p[[rint]] d[[etail]] mikrotik_routeros_ip_route_print_terse.textfsm, .*, mikrotik_routeros, [[/]]ip(v6)? route print terse diff --git a/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm b/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm new file mode 100644 index 0000000000..4d2dcea58d --- /dev/null +++ b/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm @@ -0,0 +1,30 @@ +Value Required ID (\d+) +Value DYNAMIC (D) +Value STATUS (X|R) +Value SLAVE (S) +Value NAME (\S+) +Value List DESCRIPTION ((?!\s*$).+[^\s]) +Value DEFAULT_NAME (\S+) +Value TYPE (\S+) +Value MTU (\d+|auto) +Value ACTUAL_MTU (\d+) +Value L2MTU (\d+|auto) +Value MAX_L2MTU (\d+) +Value MAC_ADDRESS ([a-zA-Z0-9]{2}(?::[a-zA-Z0-9]{2}){5}) +Value LAST_LINK_DOWN_TIME ([a-z]{3}/\d+/\d+\s\d+\:\d+\:\d+) +Value LAST_LINK_UP_TIME ([a-z]{3}/\d+/\d+\s\d+\:\d+\:\d+) +Value LINK_DOWNS (\d+) + +Start + ^\s*Flags:\s+D\s+-\s+dynamic,\s+X\s+-\s+disabled,\s+R\s+-\s+running,\s+S\s+-\s+slave\s*$$ -> Interface + ^\s*$$ + ^. -> Error + +Interface + ^\s*\d+(?:\s+D)?(?:\s*X|R)?(?:\s*S)?\s+ -> Continue.Record + ^\s*${ID}(?:\s+${DYNAMIC})?(?:\s*${STATUS})?(?:\s*${SLAVE})?\s+name="${NAME}"(?:\s+default-name="${DEFAULT_NAME}")?\s+type="${TYPE}"(\s+mtu=${MTU})?(?:\s+actual-mtu=${ACTUAL_MTU})?(?:\s+l2mtu=${L2MTU})?(?:\s+max-l2mtu=${MAX_L2MTU})?(?:\s+mac-address=${MAC_ADDRESS})?(?:\s+last-link-down-time=${LAST_LINK_DOWN_TIME})?(?:\s+last-link-up-time=${LAST_LINK_UP_TIME})?(?:\s+link-downs=${LINK_DOWNS})?\s*$$ + ^\s*name="${NAME}"(?:\s+default-name="${DEFAULT_NAME}")?\s+type="${TYPE}"(\s+mtu=${MTU})?(?:\s+actual-mtu=${ACTUAL_MTU})?(?:\s+l2mtu=${L2MTU})?(?:\s+max-l2mtu=${MAX_L2MTU})?(?:\s+mac-address=${MAC_ADDRESS})?(?:\s+last-link-down-time=${LAST_LINK_DOWN_TIME})?(?:\s+last-link-up-time=${LAST_LINK_UP_TIME})?(?:\s+link-downs=${LINK_DOWNS})?\s*$$ + ^\s*${ID}(?:\s+${DYNAMIC})?(?:\s*${STATUS})?(?:\s*${SLAVE})?\s+;{3}\s+${DESCRIPTION}\s*$$ + ^${DESCRIPTION}\s*$$ + ^\s*$$ + ^. -> Error diff --git a/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.raw b/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.raw new file mode 100644 index 0000000000..420a1b73fd --- /dev/null +++ b/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.raw @@ -0,0 +1,21 @@ +Flags: D - dynamic, X - disabled, R - running, S - slave + 0 name="ether1" default-name="ether1" type="ether" mtu=1500 actual-mtu=1500 l2mtu=1598 max-l2mtu=2028 mac-address=12:34:56:78:90:AA last-link-down-time=jul/09/2023 07:18:33 last-link-up-time=jul/09/2023 07:18:42 link-downs=20 + + 1 D name="ether2" default-name="ether2" type="ether" mtu=1500 actual-mtu=1500 l2mtu=1598 max-l2mtu=2028 mac-address=12:34:56:78:90:AB last-link-down-time=jul/09/2023 07:18:34 last-link-up-time=jul/09/2023 07:18:43 link-downs=20 + + 2 R name="ether3" default-name="ether3" type="ether" mtu=1500 actual-mtu=1500 l2mtu=1598 max-l2mtu=2028 mac-address=12:34:56:78:90:AC link-downs=0 + + 3 S name="ether4" default-name="ether4" type="ether" mtu=1500 actual-mtu=1500 l2mtu=1598 max-l2mtu=2028 mac-address=12:34:56:78:90:AD link-downs=0 + + 4 DR name="ether5" default-name="ether5" type="ether" mtu=1500 actual-mtu=1500 l2mtu=1598 max-l2mtu=2028 mac-address=12:34:56:78:90:AE link-downs=0 + + 5 RS name="ether6" default-name="ether6" type="ether" mtu=1500 actual-mtu=1500 l2mtu=1598 max-l2mtu=2028 mac-address=12:34:56:78:90:AF link-downs=0 + + 6 D S name="lte1" type="lte" mtu=1500 actual-mtu=1500 mac-address=12:34:56:78:90:BA last-link-down-time=jul/21/2023 07:47:40 last-link-up-time=jul/21/2023 07:47:46 link-downs=114 + + 7 DRS ;;; very very long +multiline description + name="pptp-out1" type="pptp-out" mtu=1450 actual-mtu=1450 last-link-down-time=jul/21/2023 07:47:03 last-link-up-time=jul/21/2023 07:47:56 link-downs=304 + + 8 RS ;;; Free Wi-Fi HTTPS + name="pptp-to-AH1100-HS" type="pptp-out" mtu=1596 actual-mtu=1596 last-link-down-time=nov/03/1970 12:24:10 last-link-up-time=nov/03/1970 12:24:10 link-downs=38 diff --git a/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.yml b/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.yml new file mode 100644 index 0000000000..2cc4e96b91 --- /dev/null +++ b/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.yml @@ -0,0 +1,149 @@ +--- +parsed_sample: + - actual_mtu: "1500" + default_name: "ether1" + dynamic: "" + id: "0" + l2mtu: "1598" + last_link_down_time: "jul/09/2023 07:18:33" + last_link_up_time: "jul/09/2023 07:18:42" + link_downs: "20" + mac_address: "12:34:56:78:90:AA" + max_l2mtu: "2028" + mtu: "1500" + name: "ether1" + description: [] + slave: "" + status: "" + type: "ether" + - actual_mtu: "1500" + default_name: "ether2" + dynamic: "D" + id: "1" + l2mtu: "1598" + last_link_down_time: "jul/09/2023 07:18:34" + last_link_up_time: "jul/09/2023 07:18:43" + link_downs: "20" + mac_address: "12:34:56:78:90:AB" + max_l2mtu: "2028" + mtu: "1500" + name: "ether2" + description: [] + slave: "" + status: "" + type: "ether" + - actual_mtu: "1500" + default_name: "ether3" + dynamic: "" + id: "2" + l2mtu: "1598" + last_link_down_time: "" + last_link_up_time: "" + link_downs: "0" + mac_address: "12:34:56:78:90:AC" + max_l2mtu: "2028" + mtu: "1500" + name: "ether3" + description: [] + slave: "" + status: "R" + type: "ether" + - actual_mtu: "1500" + default_name: "ether4" + dynamic: "" + id: "3" + l2mtu: "1598" + last_link_down_time: "" + last_link_up_time: "" + link_downs: "0" + mac_address: "12:34:56:78:90:AD" + max_l2mtu: "2028" + mtu: "1500" + name: "ether4" + description: [] + slave: "S" + status: "" + type: "ether" + - actual_mtu: "1500" + default_name: "ether5" + dynamic: "D" + id: "4" + l2mtu: "1598" + last_link_down_time: "" + last_link_up_time: "" + link_downs: "0" + mac_address: "12:34:56:78:90:AE" + max_l2mtu: "2028" + mtu: "1500" + name: "ether5" + description: [] + slave: "" + status: "R" + type: "ether" + - actual_mtu: "1500" + default_name: "ether6" + dynamic: "" + id: "5" + l2mtu: "1598" + last_link_down_time: "" + last_link_up_time: "" + link_downs: "0" + mac_address: "12:34:56:78:90:AF" + max_l2mtu: "2028" + mtu: "1500" + name: "ether6" + description: [] + slave: "S" + status: "R" + type: "ether" + - actual_mtu: "1500" + default_name: "" + dynamic: "D" + id: "6" + l2mtu: "" + last_link_down_time: "jul/21/2023 07:47:40" + last_link_up_time: "jul/21/2023 07:47:46" + link_downs: "114" + mac_address: "12:34:56:78:90:BA" + max_l2mtu: "" + mtu: "1500" + name: "lte1" + description: [] + slave: "S" + status: "" + type: "lte" + - actual_mtu: "1450" + default_name: "" + dynamic: "D" + id: "7" + l2mtu: "" + last_link_down_time: "jul/21/2023 07:47:03" + last_link_up_time: "jul/21/2023 07:47:56" + link_downs: "304" + mac_address: "" + max_l2mtu: "" + mtu: "1450" + name: "pptp-out1" + description: + - "very very long" + - "multiline description" + slave: "S" + status: "R" + type: "pptp-out" + - actual_mtu: "1596" + default_name: "" + dynamic: "" + id: "8" + l2mtu: "" + last_link_down_time: "nov/03/1970 12:24:10" + last_link_up_time: "nov/03/1970 12:24:10" + link_downs: "38" + mac_address: "" + max_l2mtu: "" + mtu: "1596" + name: "pptp-to-AH1100-HS" + description: + - "Free Wi-Fi HTTPS" + slave: "S" + status: "R" + type: "pptp-out"