Pipe Filters
Filter and format output from show commands using pipe filters.
Overview
Pipe filters allow you to process the output of show commands:
abng> show subscribers | match user1
abng> show subscribers | count
abng> show configuration | no-more
abng> show subscribers | save /tmp/subscribers.txt
Available Filters
match — Filter by Regex
Filter lines matching a regular expression.
Syntax
show <command> | match <regex>
Examples
# Show only PPPoE sessions
abng> show subscribers | match "PPPoE"
# Show sessions with IP starting with 203
abng> show subscribers | match "203\."
# Show configuration lines with "radius"
abng> show configuration | match "radius"
# Show interfaces with "eth"
abng> show interfaces | match "eth[0-9]"
Output
abng> show subscribers | match user1
│ 1 │ PPPoE │ user1 │ 203.0.113.10 │ ppp0 │ 100M/40M │
count — Count Matching Lines
Count the number of lines in the output.
Syntax
show <command> | count
Examples
# Count total sessions
abng> show subscribers | count
Count: 42
# Count PPPoE sessions
abng> show subscribers pppoe | count
Count: 38
# Count configuration lines
abng> show configuration | count
Count: 127
no-more — Disable Pager
Disable the pager and show all output without pausing.
Syntax
show <command> | no-more
Examples
# Show all configuration without paging
abng> show configuration | no-more
# Show all subscribers without paging
abng> show subscribers | no-more
save — Save to File
Save output to a file.
Syntax
show <command> | save <filepath>
Examples
# Save subscribers to file
abng> show subscribers | save /tmp/subscribers.txt
# Save configuration to file
abng> show configuration | save /tmp/running-config.yaml
# Save with timestamp
abng> show subscribers | save /tmp/subscribers-$(date +%Y%m%d-%H%M%S).txt
Combining Filters
You can chain filters together:
# Match and save
abng> show subscribers | match "pppoe" | save /tmp/pppoe-sessions.txt
# Match and count
abng> show subscribers | match "user" | count
Count: 25
# Match and disable pager
abng> show configuration | match "radius" | no-more
Filter Examples
Find Sessions by Username
abng> show subscribers | match "user1"
│ 1 │ PPPoE │ user1 │ 203.0.113.10 │ ppp0 │ 100M/40M │
Find Sessions by IP Range
abng> show subscribers | match "203\.0\.113\."
│ 1 │ PPPoE │ user1 │ 203.0.113.10 │ ppp0 │ 100M/40M │
│ 2 │ DHCP │ - │ 203.0.113.20 │ eth1.111.5 │ 50M/20M │
Find Configuration Sections
abng> show configuration | match "^pppoe:"
pppoe:
enabled: true
ac_name: AthenaBNG
mtu: 1492
mru: 1492
Count Sessions by Type
# Count PPPoE sessions
abng> show subscribers pppoe | count
Count: 38
# Count DHCP sessions
abng> show subscribers dhcp | count
Count: 4
Export Configuration
# Save running config
abng> show configuration | save /tmp/running-config.yaml
# Save config as set commands
abng> show configuration commands | save /tmp/config-commands.txt
Find Slow Sessions
# Find sessions with low upload speed
abng> show subscribers | match "10M"
│ 5 │ DHCP │ - │ 203.0.113.25 │ eth1.111.6 │ 50M/10M │
Regex Patterns
Common regex patterns for filtering:
| Pattern | Matches |
|---|---|
user1 | Literal string "user1" |
203\. | IP starting with "203." |
^pppoe: | Line starting with "pppoe:" |
enabled: true | Configuration line |
[0-9]+M | Speed in Mbps (e.g., "100M") |
PPPoE|DHCP | Either "PPPoE" or "DHCP" |
eth[0-9] | Interface name (eth0, eth1, etc.) |
Use Cases
Monitoring
# Monitor high-speed sessions
abng> show subscribers | match "100M"
# Find sessions in a specific VLAN
abng> show vlans | match "111"
# Check RADIUS configuration
abng> show configuration | match "radius"
Troubleshooting
# Find sessions with errors
abng> show subscribers | match "error"
# Check interface status
abng> show interfaces | match "DOWN"
# Find configuration issues
abng> show configuration | match "enabled: false"
Reporting
# Export subscriber list
abng> show subscribers | save /tmp/subscribers-$(date +%Y-%m-%d).txt
# Export configuration
abng> show configuration | save /tmp/config-backup.yaml
# Count sessions by type
abng> show subscribers pppoe | count
abng> show subscribers dhcp | count
Scripting
# Get session count
SESSION_COUNT=$(/opt/athena-bng/bin/abng -c "show subscribers | count" | grep -oP '\d+')
echo "Active sessions: $SESSION_COUNT"
# Get PPPoE count
PPPOE_COUNT=$(/opt/athena-bng/bin/abng -c "show subscribers pppoe | count" | grep -oP '\d+')
echo "PPPoE sessions: $PPPOE_COUNT"
# Export config
/opt/athena-bng/bin/abng -c "show configuration | save /tmp/config.yaml"
Tips and Tricks
Save with Timestamp
abng> show subscribers | save /tmp/subscribers-$(date +%Y%m%d-%H%M%S).txt
Count Specific Sessions
# Count sessions matching a pattern
abng> show subscribers | match "user" | count
Count: 25
Disable Pager for Long Output
# Show full configuration without paging
abng> show configuration | no-more
Combine with System Tools
# Export and process with grep
/opt/athena-bng/bin/abng -c "show subscribers | save /tmp/subs.txt"
grep "PPPoE" /tmp/subs.txt | wc -l
# Export and process with awk
/opt/athena-bng/bin/abng -c "show subscribers | save /tmp/subs.txt"
awk '{print $4}' /tmp/subs.txt # Extract IP addresses
Next Steps
- Non-Interactive Mode — Scripting and automation
- Operational Mode — All
showandrequestcommands