From 8765b630b870000d887c78659f3571b17ad75e74 Mon Sep 17 00:00:00 2001 From: PavloSkliarenko <78343937+PavloSkliarenko@users.noreply.github.com> Date: Tue, 23 Jul 2024 01:51:51 +0400 Subject: [PATCH] Add Mikrotik ip dhcp-server lease print template (#1495) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: pskliarenko <“pskliarenko@bsh.ru”> --- ntc_templates/templates/index | 1 + ...outeros_ip_dhcp-server_lease_print.textfsm | 19 ++++++++++ ...ik_routeros_ip_dhcp-server_lease_print.raw | 6 +++ ...ik_routeros_ip_dhcp-server_lease_print.yml | 38 +++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 ntc_templates/templates/mikrotik_routeros_ip_dhcp-server_lease_print.textfsm create mode 100644 tests/mikrotik_routeros/ip_dhcp-server_lease_print/mikrotik_routeros_ip_dhcp-server_lease_print.raw create mode 100644 tests/mikrotik_routeros/ip_dhcp-server_lease_print/mikrotik_routeros_ip_dhcp-server_lease_print.yml diff --git a/ntc_templates/templates/index b/ntc_templates/templates/index index 792874ff7c..579d5e66d3 100644 --- a/ntc_templates/templates/index +++ b/ntc_templates/templates/index @@ -712,6 +712,7 @@ mikrotik_routeros_log_print_detail_without-paging.textfsm, .*, mikrotik_routeros mikrotik_routeros_routing_bgp_peer_print_status.textfsm, .*, mikrotik_routeros, [[/]]r[[outing]] bg[[p]] p[[eer]] p[[rint]] s[[tatus]] mikrotik_routeros_ip_arp_print_without-paging.textfsm, .*, mikrotik_routeros, [[/]]ip arp print without-paging mikrotik_routeros_routing_ospf_neighbor_print.textfsm, .*, mikrotik_routeros, [[/]]r[[outing]] o[[spf]] nei[[ghbor]] p[[rint]] +mikrotik_routeros_ip_dhcp-server_lease_print.textfsm, .*, mikrotik_routeros, [[/]]ip dh[[cp-server]] l[[ease]] p[[rint]] 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_ip_neighbor_print_detail.textfsm, .*, mikrotik_routeros, [[/]]ip n[[eighbor]] p[[rint]] d[[etail]] diff --git a/ntc_templates/templates/mikrotik_routeros_ip_dhcp-server_lease_print.textfsm b/ntc_templates/templates/mikrotik_routeros_ip_dhcp-server_lease_print.textfsm new file mode 100644 index 0000000000..0800daed67 --- /dev/null +++ b/ntc_templates/templates/mikrotik_routeros_ip_dhcp-server_lease_print.textfsm @@ -0,0 +1,19 @@ +Value NUMBER (\d+) +Value FLAGS ([XRDB]+) +Value ADDRESS (\S+) +Value MAC_ADDRESS ((?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}) +Value HOST_NAME (\S+) +Value SERVER (\S+) +Value RATE_LIMIT (\S+) +Value STATUS (\S+) +Value LAST_SEEN (\S+) + +Start + ^\s*#\s+ADDRESS\s+MAC-ADDRESS\s+HOST-NAME\s+SERVER\s+RATE-LIMIT\s+STATUS\s+LAST-SEEN\s*$$ -> EntriesTable + +EntriesTable + # Impossible to separate HOST-NAME and SERVER? Have the same regex, can be empty, + # are next to each other -> use '...print terse...' version of the command + ^\s*${NUMBER}(?:\s+${FLAGS})?\s+${ADDRESS}(?:\s+${MAC_ADDRESS})?(?:\s+${HOST_NAME})?\s+${SERVER}(?:\s+${RATE_LIMIT})?\s+${STATUS}\s+${LAST_SEEN}\s*$$ -> Record + ^\s*$$ + ^. -> Error diff --git a/tests/mikrotik_routeros/ip_dhcp-server_lease_print/mikrotik_routeros_ip_dhcp-server_lease_print.raw b/tests/mikrotik_routeros/ip_dhcp-server_lease_print/mikrotik_routeros_ip_dhcp-server_lease_print.raw new file mode 100644 index 0000000000..9661af4e7a --- /dev/null +++ b/tests/mikrotik_routeros/ip_dhcp-server_lease_print/mikrotik_routeros_ip_dhcp-server_lease_print.raw @@ -0,0 +1,6 @@ +Flags: X - disabled, R - radius, D - dynamic, B - blocked + # ADDRESS MAC-ADDRESS HOST-NAME SERVER RATE-LIMIT STATUS LAST-SEEN + 0 192.168.60.254 *1 bound 35w13h13m15s + 1 X 192.168.61.254 MikroTik DHCPv4_Server waiting never + 1 192.168.62.254 12:34:56:78:90:AA DHCPv4_Server waiting never + 2 D 192.168.88.254 12:34:56:78:90:AB MikroTik DHCPv4_Server waiting never diff --git a/tests/mikrotik_routeros/ip_dhcp-server_lease_print/mikrotik_routeros_ip_dhcp-server_lease_print.yml b/tests/mikrotik_routeros/ip_dhcp-server_lease_print/mikrotik_routeros_ip_dhcp-server_lease_print.yml new file mode 100644 index 0000000000..6ec9da96cd --- /dev/null +++ b/tests/mikrotik_routeros/ip_dhcp-server_lease_print/mikrotik_routeros_ip_dhcp-server_lease_print.yml @@ -0,0 +1,38 @@ +--- +parsed_sample: + - address: "192.168.60.254" + flags: "" + host_name: "" + last_seen: "35w13h13m15s" + mac_address: "" + number: "0" + rate_limit: "" + server: "*1" + status: "bound" + - address: "192.168.61.254" + flags: "X" + host_name: "MikroTik" + last_seen: "never" + mac_address: "" + number: "1" + rate_limit: "" + server: "DHCPv4_Server" + status: "waiting" + - address: "192.168.62.254" + flags: "" + host_name: "" + last_seen: "never" + mac_address: "12:34:56:78:90:AA" + number: "1" + rate_limit: "" + server: "DHCPv4_Server" + status: "waiting" + - address: "192.168.88.254" + flags: "D" + host_name: "MikroTik" + last_seen: "never" + mac_address: "12:34:56:78:90:AB" + number: "2" + rate_limit: "" + server: "DHCPv4_Server" + status: "waiting"