From 9f0b61e941ddab5016ddc88bd487b704c6342397 Mon Sep 17 00:00:00 2001 From: Kaigan Woodford Date: Tue, 11 Feb 2025 15:07:58 +1000 Subject: [PATCH 1/4] Fix: mikrotik_routeros_system_resource_print Build time regex to support v7.16+ --- ...tik_routeros_system_resource_print.textfsm | 2 +- ...rotik_routeros_system_resource_print_5.raw | 17 +++++++++++++ ...rotik_routeros_system_resource_print_5.yml | 25 +++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tests/mikrotik_routeros/system_resource_print/mikrotik_routeros_system_resource_print_5.raw create mode 100644 tests/mikrotik_routeros/system_resource_print/mikrotik_routeros_system_resource_print_5.yml diff --git a/ntc_templates/templates/mikrotik_routeros_system_resource_print.textfsm b/ntc_templates/templates/mikrotik_routeros_system_resource_print.textfsm index d7f2b5ef45..5a5b9535a0 100644 --- a/ntc_templates/templates/mikrotik_routeros_system_resource_print.textfsm +++ b/ntc_templates/templates/mikrotik_routeros_system_resource_print.textfsm @@ -5,7 +5,7 @@ Value UPTIME_HOURS (\d+) Value UPTIME_MINUTES (\d+) Value UPTIME_SECONDS (\d+) Value VERSION (.+) -Value BUILD_TIME ([A-Za-z]{3}\/\d{1,2}\/\d{4} \d{2}:\d{2}:\d{2}) +Value BUILD_TIME (\d{4}-\d{2}-\d{2}\s*\d{2}:\d{2}:\d{2}|[A-Za-z]{3}\/\d{1,2}\/\d{4} \d{2}:\d{2}:\d{2}) Value FACTORY_SOFTWARE (\S+) Value FREE_MEMORY (\d+\.\d{1}(K|M|G)iB) Value TOTAL_MEMORY (\d+\.\d{1}(K|M|G)iB) diff --git a/tests/mikrotik_routeros/system_resource_print/mikrotik_routeros_system_resource_print_5.raw b/tests/mikrotik_routeros/system_resource_print/mikrotik_routeros_system_resource_print_5.raw new file mode 100644 index 0000000000..b8cf4d6edb --- /dev/null +++ b/tests/mikrotik_routeros/system_resource_print/mikrotik_routeros_system_resource_print_5.raw @@ -0,0 +1,17 @@ + uptime: 7w5d6h42m45s + version: 7.16.1 (stable) + build-time: 2024-10-10 14:03:32 + factory-software: 6.41.3 + free-memory: 178.4MiB + total-memory: 256.0MiB + cpu: MIPS 1004Kc V2.15 + cpu-count: 4 + cpu-frequency: 880MHz + cpu-load: 1% + free-hdd-space: 5.5MiB + total-hdd-space: 16.0MiB + write-sect-since-reboot: 12691 + write-sect-total: 576299 + architecture-name: mmips + board-name: hEX S + platform: MikroTik diff --git a/tests/mikrotik_routeros/system_resource_print/mikrotik_routeros_system_resource_print_5.yml b/tests/mikrotik_routeros/system_resource_print/mikrotik_routeros_system_resource_print_5.yml new file mode 100644 index 0000000000..9852b0d910 --- /dev/null +++ b/tests/mikrotik_routeros/system_resource_print/mikrotik_routeros_system_resource_print_5.yml @@ -0,0 +1,25 @@ +--- +parsed_sample: + - architecture_name: "mmips" + bad_blocks: "" + board_name: "hEX S" + build_time: "2024-10-10 14:03:32" + cpu: "MIPS 1004Kc V2.15" + cpu_count: "4" + cpu_frequency: "880MHz" + cpu_load: "1%" + factory_software: "6.41.3" + free_hdd_space: "5.5MiB" + free_memory: "178.4MiB" + platform: "MikroTik" + total_hdd_space: "16.0MiB" + total_memory: "256.0MiB" + uptime: "7w5d6h42m45s" + uptime_days: "5" + uptime_hours: "6" + uptime_minutes: "42" + uptime_seconds: "45" + uptime_weeks: "7" + version: "7.16.1 (stable)" + write_sect_since_reboot: "12691" + write_sect_total: "576299" From 2bbe8eaefaeaf73a177ce40ad2509e7e1afec222 Mon Sep 17 00:00:00 2001 From: Michael Bear <38406045+mjbear@users.noreply.github.com> Date: Tue, 17 Feb 2026 20:52:23 -0500 Subject: [PATCH 2/4] Modify spacing between date+time Swap out \s* regex (between date and time) for a single literal space since there is always a space. --- .../templates/mikrotik_routeros_system_resource_print.textfsm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ntc_templates/templates/mikrotik_routeros_system_resource_print.textfsm b/ntc_templates/templates/mikrotik_routeros_system_resource_print.textfsm index 5a5b9535a0..ac1ddc99ab 100644 --- a/ntc_templates/templates/mikrotik_routeros_system_resource_print.textfsm +++ b/ntc_templates/templates/mikrotik_routeros_system_resource_print.textfsm @@ -5,7 +5,7 @@ Value UPTIME_HOURS (\d+) Value UPTIME_MINUTES (\d+) Value UPTIME_SECONDS (\d+) Value VERSION (.+) -Value BUILD_TIME (\d{4}-\d{2}-\d{2}\s*\d{2}:\d{2}:\d{2}|[A-Za-z]{3}\/\d{1,2}\/\d{4} \d{2}:\d{2}:\d{2}) +Value BUILD_TIME (\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}|[A-Za-z]{3}\/\d{1,2}\/\d{4} \d{2}:\d{2}:\d{2}) Value FACTORY_SOFTWARE (\S+) Value FREE_MEMORY (\d+\.\d{1}(K|M|G)iB) Value TOTAL_MEMORY (\d+\.\d{1}(K|M|G)iB) From a21846f5ecaaef7ba59d57d27f3f01a97cd92222 Mon Sep 17 00:00:00 2001 From: Michael Bear <38406045+mjbear@users.noreply.github.com> Date: Tue, 17 Feb 2026 21:08:58 -0500 Subject: [PATCH 3/4] Reduce duplication of build time regex Both old and new build time formats use the same time format for hour:minute:second. So we can reduce the duplication by adjusting the build time regex. --- .../templates/mikrotik_routeros_system_resource_print.textfsm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ntc_templates/templates/mikrotik_routeros_system_resource_print.textfsm b/ntc_templates/templates/mikrotik_routeros_system_resource_print.textfsm index ac1ddc99ab..f669e5d887 100644 --- a/ntc_templates/templates/mikrotik_routeros_system_resource_print.textfsm +++ b/ntc_templates/templates/mikrotik_routeros_system_resource_print.textfsm @@ -5,7 +5,7 @@ Value UPTIME_HOURS (\d+) Value UPTIME_MINUTES (\d+) Value UPTIME_SECONDS (\d+) Value VERSION (.+) -Value BUILD_TIME (\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}|[A-Za-z]{3}\/\d{1,2}\/\d{4} \d{2}:\d{2}:\d{2}) +Value BUILD_TIME ((\d{4}-\d{2}-\d{2}|[A-Za-z]{3}\/\d{1,2}\/\d{4}) \d{2}:\d{2}:\d{2}) Value FACTORY_SOFTWARE (\S+) Value FREE_MEMORY (\d+\.\d{1}(K|M|G)iB) Value TOTAL_MEMORY (\d+\.\d{1}(K|M|G)iB) From bc21a464f846641d5024de7cd8175668061405de Mon Sep 17 00:00:00 2001 From: Kaigan Woodford Date: Thu, 19 Feb 2026 08:36:28 +1000 Subject: [PATCH 4/4] Fix: mikrotik_routeros_system_resource_print Newer versions of RouterOS7 contains whitespace at the end of strings to pad it out to the end of the build-time string. New regex fixes that. --- ...tik_routeros_system_resource_print.textfsm | 12 ++++----- ...rotik_routeros_system_resource_print_6.raw | 18 +++++++++++++ ...rotik_routeros_system_resource_print_6.yml | 25 +++++++++++++++++++ 3 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 tests/mikrotik_routeros/system_resource_print/mikrotik_routeros_system_resource_print_6.raw create mode 100644 tests/mikrotik_routeros/system_resource_print/mikrotik_routeros_system_resource_print_6.yml diff --git a/ntc_templates/templates/mikrotik_routeros_system_resource_print.textfsm b/ntc_templates/templates/mikrotik_routeros_system_resource_print.textfsm index f669e5d887..4892ef92f2 100644 --- a/ntc_templates/templates/mikrotik_routeros_system_resource_print.textfsm +++ b/ntc_templates/templates/mikrotik_routeros_system_resource_print.textfsm @@ -4,12 +4,12 @@ Value UPTIME_DAYS (\d+) Value UPTIME_HOURS (\d+) Value UPTIME_MINUTES (\d+) Value UPTIME_SECONDS (\d+) -Value VERSION (.+) +Value VERSION (\S+(?:\s+\S+)*) Value BUILD_TIME ((\d{4}-\d{2}-\d{2}|[A-Za-z]{3}\/\d{1,2}\/\d{4}) \d{2}:\d{2}:\d{2}) -Value FACTORY_SOFTWARE (\S+) +Value FACTORY_SOFTWARE (\S+(?:\s+\S+)*) Value FREE_MEMORY (\d+\.\d{1}(K|M|G)iB) Value TOTAL_MEMORY (\d+\.\d{1}(K|M|G)iB) -Value CPU (.+) +Value CPU (\S+(?:\s+\S+)*) Value CPU_COUNT (\d+) Value CPU_FREQUENCY (\d+(M|G)Hz) Value CPU_LOAD (\d{1,3}%) @@ -18,9 +18,9 @@ Value TOTAL_HDD_SPACE (\d+\.\d{1}(K|M|G)iB) Value WRITE_SECT_SINCE_REBOOT (\d+) Value WRITE_SECT_TOTAL (\d+) Value BAD_BLOCKS (\d{1,3}(\.\d+)?%) -Value ARCHITECTURE_NAME (\S*) -Value BOARD_NAME (.+) -Value PLATFORM (.+) +Value ARCHITECTURE_NAME (\S+(?:\s+\S+)*) +Value BOARD_NAME (\S+(?:\s+\S+)*) +Value PLATFORM (\S+(?:\s+\S+)*) Start ^\s*uptime\:\s+${UPTIME}\s*$$ -> Continue diff --git a/tests/mikrotik_routeros/system_resource_print/mikrotik_routeros_system_resource_print_6.raw b/tests/mikrotik_routeros/system_resource_print/mikrotik_routeros_system_resource_print_6.raw new file mode 100644 index 0000000000..99c7362172 --- /dev/null +++ b/tests/mikrotik_routeros/system_resource_print/mikrotik_routeros_system_resource_print_6.raw @@ -0,0 +1,18 @@ + uptime: 2h14m31s + version: 7.18.2 (stable) + build-time: 2025-03-11 11:59:04 + factory-software: 7.4.1 + free-memory: 845.8MiB + total-memory: 1024.0MiB + cpu: ARM64 + cpu-count: 4 + cpu-frequency: 350MHz + cpu-load: 1% + free-hdd-space: 992.3MiB + total-hdd-space: 1024.0MiB + write-sect-since-reboot: 40 + write-sect-total: 315102 + bad-blocks: 0% + architecture-name: arm64 + board-name: RB5009UG+S+ + platform: MikroTik \ No newline at end of file diff --git a/tests/mikrotik_routeros/system_resource_print/mikrotik_routeros_system_resource_print_6.yml b/tests/mikrotik_routeros/system_resource_print/mikrotik_routeros_system_resource_print_6.yml new file mode 100644 index 0000000000..72c8ccee93 --- /dev/null +++ b/tests/mikrotik_routeros/system_resource_print/mikrotik_routeros_system_resource_print_6.yml @@ -0,0 +1,25 @@ +--- +parsed_sample: + - architecture_name: "arm64" + bad_blocks: "0%" + board_name: "RB5009UG+S+" + build_time: "2025-03-11 11:59:04" + cpu: "ARM64" + cpu_count: "4" + cpu_frequency: "350MHz" + cpu_load: "1%" + factory_software: "7.4.1" + free_hdd_space: "992.3MiB" + free_memory: "845.8MiB" + platform: "MikroTik" + total_hdd_space: "1024.0MiB" + total_memory: "1024.0MiB" + uptime: "2h14m31s" + uptime_days: "" + uptime_hours: "2" + uptime_minutes: "14" + uptime_seconds: "31" + uptime_weeks: "" + version: "7.18.2 (stable)" + write_sect_since_reboot: "40" + write_sect_total: "315102"