diff --git a/docs/DETAILS.md b/docs/DETAILS.md index 98d0b75..77271bc 100644 --- a/docs/DETAILS.md +++ b/docs/DETAILS.md @@ -34,6 +34,14 @@ types: - show version - show inventory - show running-config + + routeros: + commands: + - system package print detail without-paging + - / export terse + exclude: + - "^# ....-..-.. ..:..:.. by RouterOS" # Filter timestamp headers + - "^# .../../.... ..:..:.. by RouterOS" # Alternative date format ``` **Main configuration** (`config.yaml`): @@ -64,6 +72,7 @@ devices: #### Types Section - **``**: Device type name (e.g., `srlinux`, `eos`) - **`commands`**: Array of CLI commands to execute + - **`exclude`** (optional): Array of regex patterns to filter out unwanted lines from output #### Devices Section - **``**: Device hostname (used for SSH config lookup and output filename) @@ -85,6 +94,43 @@ ipng-router-backup --yaml "*.yaml" ipng-router-backup --yaml "config/*.yaml" ``` +## Output Filtering + +The tool supports filtering unwanted lines from command output using regular expressions in the `exclude` field of device types. + +### How Exclude Patterns Work + +- **Regex matching**: Each line of command output is tested against all exclude patterns +- **Line removal**: Lines matching any pattern are completely removed from the output file +- **Per-device type**: Exclude patterns are defined at the device type level and apply to all devices of that type + +### Common Use Cases + +```yaml +types: + routeros: + commands: + - / export terse + exclude: + - "^# ....-..-.. ..:..:.. by RouterOS" # Remove timestamp headers + - "^# .../../.... ..:..:.. by RouterOS" # Alternative date format + + cisco-ios: + commands: + - show running-config + exclude: + - "^Building configuration" # Remove config build messages + - "^Current configuration" # Remove current config headers + - "^!" # Remove comment lines + + debug-device: + commands: + - show logs + exclude: + - "^DEBUG:" # Filter debug messages + - "^TRACE:" # Filter trace messages +``` + ## Command Line Usage ### Required Flags diff --git a/docs/ipng-router-backup.1 b/docs/ipng-router-backup.1 index aed430d..16aa608 100644 --- a/docs/ipng-router-backup.1 +++ b/docs/ipng-router-backup.1 @@ -48,6 +48,11 @@ types: commands: - show version - show platform linecard + routeros: + commands: + - / export terse + exclude: + - "^# ....-..-.. ..:..:.. by RouterOS" .EE .SS devices Define individual devices: @@ -70,6 +75,8 @@ Default SSH keys (~/.ssh/id_rsa, ~/.ssh/id_ed25519, ~/.ssh/id_ecdsa) Password authentication (--password option) .SH OUTPUT For each device, a text file named after the hostname is created in the specified directory. Each command output is prefixed with "## COMMAND: " for easy identification. +.PP +Output can be filtered using regex patterns defined in the device type's 'exclude' field to remove unwanted lines such as timestamps or debug messages. .SH EXAMPLES .TP Basic usage with glob patterns: