Update docs with exclude patterns

This commit is contained in:
Pim van Pelt
2025-07-07 00:54:52 +02:00
parent 4260067ea8
commit c6775736ac
2 changed files with 53 additions and 0 deletions

View File

@ -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
- **`<type-name>`**: 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
- **`<hostname>`**: 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