netops.parsers — Output Parsers¶
Vendor-specific parsers for CLI and structured API output.
netops.parsers.arista¶
Parsers for Arista EOS eAPI JSON responses and CLI text output.
Arista EOS supports two output modes:
- eAPI JSON — structured JSON returned by the
/command-apiendpoint or via Netmiko withoutput_format="json". These are the primary parsers and accept already-decodeddictobjects. - CLI text — plain-text
showoutput, used as a fallback when eAPI is unavailable. These parsers operate on raw strings.
arista ¶
Parsers for Arista EOS eAPI JSON responses and CLI text output.
Arista EOS supports two output modes:
- eAPI JSON – structured JSON returned by the
/command-apiendpoint or via Netmikosend_command(..., use_genie=False)withoutput_format="json". These are the primary parsers and accept already-decodeddictobjects. - CLI text – plain-text
showoutput, used as a fallback when eAPI is unavailable. These parsers operate on raw strings.
All parser functions return lists or dicts that match the health-check schema used by the rest of the toolkit (same key names as Juniper/Cisco equivalents where possible).
Supported checks:
- CPU / memory –
show versionJSON (systemStatsblock) - Interface counters –
show interfacesJSON /show interfaces counters errorsJSON - Transceiver DOM –
show interfaces transceiverJSON - BGP summary –
show bgp summaryJSON (IPv4 + EVPN) - OSPF neighbours –
show ip ospf neighborJSON - MLAG health –
show mlagJSON +show mlag config-sanityJSON - Environment –
show environment allJSON (temperature, fans, PSUs)
Functions:¶
parse_cpu_memory_eos ¶
Parse show version eAPI JSON response for CPU and memory.
Arista's show version JSON includes a systemStats sub-dict with:
cpuInfo (per-core usage) and memUsed / memTotal fields.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with:
Returns a dict with all values |
parse_interfaces_eos ¶
Parse show interfaces eAPI JSON response.
Returns:
| Type | Description |
|---|---|
list
|
List of per-interface dicts:
|
parse_interface_counters_eos ¶
Parse show interfaces counters errors eAPI JSON response.
Returns:
| Type | Description |
|---|---|
list
|
List of per-interface error-counter dicts:
|
parse_transceivers_eos ¶
Parse show interfaces transceiver eAPI JSON response.
Returns:
| Type | Description |
|---|---|
list
|
List of per-interface transceiver dicts:
|
parse_bgp_summary_eos ¶
Parse show bgp summary eAPI JSON response (IPv4 unicast).
Returns:
| Type | Description |
|---|---|
list
|
List of BGP peer dicts:
|
parse_bgp_evpn_eos ¶
Parse show bgp evpn summary eAPI JSON response.
Returns:
| Type | Description |
|---|---|
list
|
Same per-peer structure as :func: |
parse_ospf_neighbors_eos ¶
Parse show ip ospf neighbor eAPI JSON response.
Returns:
| Type | Description |
|---|---|
list
|
List of OSPF neighbour dicts:
|
parse_mlag_eos ¶
Parse show mlag eAPI JSON response.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with:
|
parse_mlag_config_sanity_eos ¶
Parse show mlag config-sanity eAPI JSON response.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with:
|
parse_environment_eos ¶
Parse show environment all eAPI JSON response.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with:
|
parse_bgp_summary_eos_text ¶
Parse show bgp summary plain-text output from Arista EOS.
Handles output similar to::
BGP summary information for VRF default
Router identifier 10.0.0.1, local AS number 65001
Neighbor Status Codes: m - Under maintenance
Description Neighbor V AS MsgRcvd MsgSent InQ OutQ Up/Down State PfxRcd PfxAcc
10.0.0.2 4 65002 1000 1001 0 0 5d03h Estab 50 50
10.0.0.3 4 65003 50 51 0 0 00:05:23 Active
Returns:
| Type | Description |
|---|---|
list
|
Same structure as :func: |
parse_ospf_neighbors_eos_text ¶
Parse show ip ospf neighbor plain-text output from Arista EOS.
Handles output similar to::
Neighbor ID Pri State Dead Time Address Interface
10.0.0.2 1 Full/DR 00:00:38 10.1.0.2 Ethernet1
10.0.0.3 1 Full/BDR 00:00:36 10.1.0.3 Ethernet2
10.0.0.4 0 ExStart/- 00:00:39 10.1.0.4 Ethernet3
Returns:
| Type | Description |
|---|---|
list
|
Same structure as :func: |
parse_mlag_eos_text ¶
Parse show mlag plain-text output from Arista EOS.
Handles output similar to::
MLAG Configuration:
domain-id : mlag-domain
local-interface : Vlan4094
peer-address : 10.255.0.2
peer-link : Port-Channel1
peer-config : consistent
MLAG Status:
state : Active
negotiation status : Connected
peer-link status : Up
local-int status : Up
system-id : 02:1c:73:00:00:99
dual-primary detection : Disabled
dual-primary interface errdisabled : False
MLAG Ports:
Disabled : 0
Configured : 0
Inactive : 0
Active-partial : 0
Active-full : 2
Returns:
| Type | Description |
|---|---|
dict
|
Same structure as :func: |
parse_lldp_neighbors_eos ¶
Parse show lldp neighbors eAPI JSON response.
Returns:
| Type | Description |
|---|---|
list
|
List of LLDP neighbor dicts:
|
parse_lldp_neighbors_eos_text ¶
Parse show lldp neighbors plain-text output from Arista EOS.
Handles output similar to::
Last table change time : 0:05:23 ago
Number of table inserts : 3
Number of table deletes : 0
Number of table drops : 0
Number of table age-outs : 0
Port Neighbor Device ID Neighbor Port ID TTL
Port Neighbor Device ID Neighbor Port ID TTL
Ethernet1 switch-1 Ethernet1 120
Ethernet2 switch-2.example.com Ethernet3 120
Ethernet49 router-3 ge-0/0/0 120
Returns:
| Type | Description |
|---|---|
list
|
Same structure as :func: |
parse_vlan_eos ¶
Parse show vlan eAPI JSON response.
Returns:
| Type | Description |
|---|---|
list
|
List of VLAN dicts:
|
parse_vlan_eos_text ¶
Parse show vlan plain-text output from Arista EOS.
Handles output similar to::
VLAN Name Status Ports
VLAN Name Status Ports
1 default active Et1, Et2, Et3
10 management active Et49, Et50
100 servers suspended
200 guests active Et10, Et11
Returns:
| Type | Description |
|---|---|
list
|
Same structure as :func: |
netops.parsers.bgp¶
Cisco IOS/IOS-XE/IOS-XR BGP summary parsers.
bgp ¶
Parsers for BGP CLI output.
Supports Cisco IOS/IOS-XE (show ip bgp summary) and
Cisco IOS-XR (show bgp summary).
Nokia SR-OS BGP output is handled by
:func:netops.parsers.nokia_sros.parse_bgp_summary.
Functions:¶
parse_bgp_summary_cisco ¶
Parse show ip bgp summary / show bgp summary output.
Handles Cisco IOS, IOS-XE, and IOS-XR formats.
Returns:
| Type | Description |
|---|---|
list
|
List of per-peer dicts. Returns an empty list when the output cannot be parsed. |
Each returned dict contains:
|
|
* ``neighbor`` – peer IPv4/IPv6 address
|
|
* ``peer_as`` – remote AS number (``int``)
|
|
* ``msg_rcvd`` – BGP messages received (``int``)
|
|
* ``msg_sent`` – BGP messages sent (``int``)
|
|
* ``up_down`` – session uptime or time-since-reset string
|
|
* ``state`` – ``'Established'`` or FSM state string
|
(e.g. |
* ``prefixes_received`` – prefixes received (``int``) when
|
|
updown_to_seconds ¶
Convert a BGP session up/down time string to total seconds.
Handles the most common Cisco and Nokia SR-OS formats:
HH:MM:SS— e.g.'00:15:30'XdYh— e.g.'2d03h','1d02h'XwYd— e.g.'1w2d'XhYm— Nokia SR-OS, e.g.'00h15m'never— session was never established →None
Returns:
| Type | Description |
|---|---|
int or None
|
Total seconds as an integer, or |
netops.parsers.brocade¶
Brocade FastIron/ICX and Network OS/VDX CLI output parsers.
brocade ¶
Parsers for Brocade FastIron / Network OS / Fabric OS CLI output.
Functions:¶
parse_interfaces ¶
Parse show interfaces or show interface brief output.
Supports Brocade FastIron/ICX interface summary lines.
Returns:
| Type | Description |
|---|---|
list
|
List of per-interface dicts. |
Each returned dict contains:
|
|
* ``name`` – interface identifier (e.g. ``'GigabitEthernet1/1/1'``)
|
|
* ``status`` – administrative state: ``'up'`` or ``'down'``
|
|
* ``protocol`` – line-protocol state: ``'up'`` or ``'down'``
|
|
* ``up`` – ``True`` when both admin and line-protocol are ``'up'``
|
|
The field names match the Cisco / Nokia parser convention so callers can
|
|
treat output from all vendors uniformly.
|
|
Handles both the detailed form::
|
GigabitEthernet1/1/1 is up, line protocol is up |
and the brief tabular form::
|
GigabitEthernet1/1/1 up up ... |
parse_ip_routes ¶
Parse show ip route output from Brocade FastIron/ICX.
Returns:
| Type | Description |
|---|---|
list
|
List of per-route dicts. Returns an empty list when the output cannot be parsed. |
Each returned dict contains:
|
|
* ``type`` – route type code (e.g. ``'B'``, ``'C'``, ``'S'``, ``'R'``)
|
|
* ``network`` – destination prefix in CIDR notation (e.g. ``'10.0.0.0/8'``)
|
|
* ``next_hop`` – next-hop IP address, or ``'DIRECT'`` for connected routes
|
|
* ``interface`` – egress interface (e.g. ``'e1/1/1'``)
|
|
* ``metric`` – route metric / cost (``int``)
|
|
Example input lines::
|
B 10.0.0.0/8 192.168.1.254 e1/1 1 C 192.168.1.0/24 DIRECT e1/2 1 S 0.0.0.0/0 10.0.0.1 e1/1 1 |
parse_version ¶
Parse show version output from a Brocade FastIron/ICX device.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
Returns a dict with |
Example input lines::
|
HW: ICX7550-48 SW: Version 09.0.10T215 Copyright (c) 1996-2023 Ruckus Networks, Inc. |
parse_fabric ¶
Parse show fabric output from a Brocade Fabric OS (FOS) SAN switch.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
Returns a dict with empty defaults when the output cannot be parsed. |
Example input::
|
Fabric Name: FabricA Fabric OS: v9.1.0 Switch: fc-sw-01 (domain 1) Port 0/1: Online Port 0/2: Offline |
netops.parsers.cisco¶
Cisco IOS/IOS-XE CLI output parsers — OSPF neighbors, environment, version, inventory, and serial number.
cisco ¶
Parsers for Cisco IOS/IOS-XE show command output.
Covers OSPF neighbor tables, device environment (temperature, fans, power
supplies) and show version (uptime, reload reason, IOS version).
Functions:¶
parse_ospf_neighbors ¶
Parse show ip ospf neighbor output from Cisco IOS/IOS-XE.
Returns:
| Type | Description |
|---|---|
list
|
List of per-neighbor dicts. Returns an empty list when no neighbors are parsed. |
Each returned dict contains:
|
|
* ``neighbor_id`` – OSPF router-ID of the neighbor (``str``)
|
|
* ``priority`` – interface priority (``int``)
|
|
* ``state`` – adjacency state string (e.g. ``'FULL/DR'``, ``'INIT/DROTHER'``)
|
|
* ``dead_time`` – dead-timer countdown in ``HH:MM:SS`` format (``str``)
|
|
* ``address`` – neighbor IP address (``str``)
|
|
* ``interface`` – local interface name (``str``)
|
|
* ``is_full`` – ``True`` when the state starts with ``'FULL'``
|
|
Example input::
|
Neighbor ID Pri State Dead Time Address Interface 192.168.1.2 1 FULL/DR 00:00:37 10.0.0.2 GigabitEthernet0/0 192.168.1.3 1 FULL/BDR 00:00:38 10.0.0.3 GigabitEthernet0/0 192.168.1.4 0 INIT/DROTHER 00:00:35 10.0.0.4 GigabitEthernet0/1 |
parse_environment_cisco ¶
Parse show environment all output from Cisco IOS/IOS-XE.
Handles both IOS (router) and IOS-XE (Catalyst switch) output formats.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
Returns a dict with empty lists when the output cannot be parsed. |
Example IOS-XE input lines::
|
Switch 1 FAN 1 is OK Switch 1: TEMPERATURE is OK SYSTEM INLET : 28 Celsius, Critical threshold is 60 Celsius Switch 1: POWER-SUPPLY 1 is PRESENT Switch 1: POWER-SUPPLY 2 is NOT PRESENT |
parse_version_cisco ¶
Parse show version output from Cisco IOS/IOS-XE.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
Returns a dict with all |
Example input lines::
|
Cisco IOS Software, Version 15.2(4)E8, RELEASE SOFTWARE (fc2) cisco WS-C3750X-48P (PowerPC405) processor ... Switch uptime is 2 weeks, 3 days, 4 hours, 5 minutes Last reload reason: Reload command System image file is "flash:c3750x-ipservicesk9-mz.152-4.E8.bin" |
parse_inventory_cisco ¶
Parse show inventory output from Cisco IOS/NX-OS/IOS-XE.
Returns:
| Type | Description |
|---|---|
list
|
List of dicts, each with:
|
Example input::
|
NAME: "Chassis", DESCR: "Nexus 9000 Series Chassis" PID: N9K-C93180YC-FX3, VID: V01, SN: FDO23456789 |
parse_serial_cisco ¶
Extract the chassis serial number from show inventory output.
Returns:
| Type | Description |
|---|---|
str or None
|
The serial number string for the first entry whose name contains
"chassis" (case-insensitive), or the first entry if no chassis
is found. Returns |
netops.parsers.health¶
Multi-vendor CPU, memory, interface error, and log parsers.
health ¶
Parsers for health-check CLI output (CPU, memory, interface errors, logs).
Supports Cisco IOS/XE/XR/NXOS, Nokia SR-OS, and Brocade FastIron/NOS output formats.
Functions:¶
parse_cpu_cisco ¶
Parse show processes cpu output from Cisco IOS/XE/XR.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
Returns an empty dict when the output cannot be parsed. |
Example input line::
|
CPU utilization for five seconds: 12%/3%; one minute: 8%; five minutes: 6% |
parse_cpu_nokia ¶
Parse show system cpu output from Nokia SR-OS.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
Returns an empty dict when the output cannot be parsed. |
Example input lines::
|
CPU Usage : 5% 12% |
parse_memory_cisco ¶
Parse show processes memory output from Cisco IOS/XE.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
Returns an empty dict when the output cannot be parsed. |
Example input line::
|
Processor 7F2B3C18 402702336 141058576 261643760 ... |
parse_memory_nokia ¶
Parse show system memory-pools output from Nokia SR-OS.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
Returns an empty dict when the output cannot be parsed. |
Example input lines::
|
Total In Use : 141058576 Total Available : 261643760 |
parse_interface_errors_cisco ¶
Parse show interfaces output for error counters on Cisco IOS/XE/XR.
Returns:
| Type | Description |
|---|---|
list
|
List of per-interface error-counter dicts. Returns an empty list when no interfaces are parsed. |
Each returned dict contains:
|
|
* ``name`` – interface name (e.g. ``'GigabitEthernet0/0'``)
|
|
* ``input_errors`` – total input errors (``int``)
|
|
* ``output_errors`` – total output errors (``int``)
|
|
* ``crc`` – CRC errors (``int``)
|
|
* ``drops`` – total input/output drops (``int``)
|
|
* ``has_errors`` – ``True`` when any counter is non-zero
|
|
parse_interface_errors_nokia ¶
Parse show port detail output for error counters on Nokia SR-OS.
Returns:
| Type | Description |
|---|---|
list
|
List of per-interface error-counter dicts. Returns an empty list when no ports are parsed. |
Each returned dict contains:
|
|
* ``name`` – port identifier (e.g. ``'1/1/1'``)
|
|
* ``input_errors`` – total input errors (``int``)
|
|
* ``output_errors`` – total output errors (``int``)
|
|
* ``crc`` – CRC/alignment errors (``int``)
|
|
* ``drops`` – ingress/egress drops (``int``)
|
|
* ``has_errors`` – ``True`` when any counter is non-zero
|
|
parse_logs_cisco ¶
Scan show logging output for severity 0–3 (critical/major) events.
Returns:
| Type | Description |
|---|---|
list
|
List of per-log-entry dicts. Returns an empty list when no matching events are found. |
Each returned dict contains:
|
|
* ``facility`` – syslog facility (e.g. ``'SYS'``)
|
|
* ``severity`` – numeric severity 0–3 (``int``)
|
|
* ``mnemonic`` – syslog mnemonic (e.g. ``'MALLOCFAIL'``)
|
|
* ``message`` – event description
|
|
parse_logs_nokia ¶
Scan Nokia SR-OS log output for CRITICAL and MAJOR severity events.
Returns:
| Type | Description |
|---|---|
list
|
List of per-log-entry dicts. Returns an empty list when no matching events are found. |
Each returned dict contains:
|
|
* ``timestamp`` – event timestamp string
|
|
* ``severity`` – ``'CRITICAL'`` or ``'MAJOR'``
|
|
* ``subject`` – log subject/application
|
|
* ``message`` – event description
|
|
parse_cpu_brocade ¶
Parse show cpu output from Brocade FastIron/ICX.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
Returns an empty dict when the output cannot be parsed. |
Example input lines::
|
CPU Utilization: 1-second average: 12 percent 5-second average: 10 percent 60-second average: 8 percent |
parse_memory_brocade ¶
Parse show memory output from Brocade FastIron/ICX.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
Returns an empty dict when the output cannot be parsed. |
Example input lines::
|
System memory information: Total DRAM: 1048576 KBytes Used DRAM: 512000 KBytes Free DRAM: 536576 KBytes |
parse_interface_errors_brocade ¶
Parse show interfaces output for error counters on Brocade FastIron/ICX.
Returns:
| Type | Description |
|---|---|
list
|
List of per-interface error-counter dicts. Returns an empty list when no interfaces are parsed. |
Each returned dict contains:
|
|
* ``name`` – interface name (e.g. ``'GigabitEthernet1/1/1'``)
|
|
* ``input_errors`` – total input errors (``int``)
|
|
* ``output_errors`` – total output errors (``int``)
|
|
* ``crc`` – CRC/alignment errors (``int``)
|
|
* ``drops`` – input/output discards (``int``)
|
|
* ``has_errors`` – ``True`` when any counter is non-zero
|
|
Example input lines::
|
GigabitEthernet1/1/1 is up, line protocol is up 0 input errors, 0 CRC, 0 alignment errors, 0 runts, 0 giants 0 output errors, 0 output discards |
parse_logs_brocade ¶
Scan show logging output for critical/error severity events on Brocade.
Returns:
| Type | Description |
|---|---|
list
|
List of per-log-entry dicts. Returns an empty list when no matching events are found. |
Each returned dict contains:
|
|
* ``timestamp`` – event timestamp string (e.g. ``'Mar 15 12:34:56'``)
|
|
* ``severity`` – normalised severity: ``'CRITICAL'``, ``'ERROR'``, or
|
|
* ``message`` – event description
|
|
parse_cpu_paloalto ¶
Parse show system resources follow duration 1 output from PAN-OS.
PAN-OS runs on a Linux kernel and exposes a top-style resource
snapshot. This parser extracts the CPU idle percentage and derives
utilization.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
Returns an empty dict when the output cannot be parsed. |
Example input line::
|
%Cpu(s): 5.0 us, 1.5 sy, 0.0 ni, 92.5 id, 0.5 wa, 0.0 hi, 0.5 si |
parse_memory_paloalto ¶
Parse show system resources follow duration 1 output from PAN-OS.
Extracts the memory summary line from the top-style output.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
Returns an empty dict when the output cannot be parsed. |
Example input line::
|
MiB Mem : 16384.0 total, 8192.0 free, 6144.0 used, 2048.0 buff/cache |
netops.parsers.juniper¶
Juniper JunOS CLI output parsers — Routing Engine, FPC, BGP, OSPF, chassis alarms, environment, and route summary.
juniper ¶
Parsers for Juniper JunOS CLI output.
Supports both plain-text (show …) and XML-like text output produced by
JunOS show commands. All parsers operate on strings returned from the
device connection and do not require the lxml or ncclient libraries.
Parsers are grouped into:
- Routing Engine – CPU, memory, uptime (
show chassis routing-engine) - FPC – slot status and temperatures (
show chassis fpc) - Interfaces – error counters (
show interfaces extensive) - BGP – neighbour summary (
show bgp summary) - OSPF – neighbour table (
show ospf neighbor) - Chassis alarms – active alarms (
show chassis alarms) - Chassis environment – power/temperature/fans (
show chassis environment) - Route summary – routing table statistics (
show route summary)
Functions:¶
parse_re_status ¶
Parse show chassis routing-engine output.
Returns:
| Type | Description |
|---|---|
list
|
List of routing-engine dicts. Returns an empty list when the output cannot be parsed. |
Each returned dict represents one Routing Engine slot and contains:
|
|
* ``slot`` – RE slot index (``int``, 0 or 1)
|
|
* ``mastership`` – mastership state (e.g. ``'Master'``, ``'Backup'``, ``'Disabled'``)
|
|
* ``state`` – RE state (e.g. ``'Online'``, ``'Offline'``)
|
|
* ``cpu_util`` – CPU utilisation % (``int``) or ``None``
|
|
* ``memory_util`` – DRAM utilisation % (``int``) or ``None``
|
|
* ``memory_total`` – total DRAM in MB (``int``) or ``None``
|
|
* ``memory_used`` – used DRAM in MB (``int``) or ``None``
|
|
* ``uptime`` – uptime string (e.g. ``'10 days, 3 hours, 22 minutes'``)
|
or |
* ``temperature`` – temperature in Celsius (``int``) or ``None``
|
|
Example input::
|
Routing Engine status: Slot 0: Current state Master Election priority Master (default) Temperature 40 degrees C / 104 degrees F Total memory 2048 MB Memory utilization 65 percent CPU utilization: User 2 percent Background 0 percent Kernel 3 percent Interrupt 0 percent Idle 95 percent Model RE-S-1800x4 Start time: 2024-01-01 00:00:00 UTC Uptime: 10 days, 3 hours, 22 minutes, 15 seconds |
parse_fpc_status ¶
Parse show chassis fpc output.
Returns:
| Type | Description |
|---|---|
list
|
List of FPC slot dicts. Returns an empty list when the output cannot be parsed. |
Each returned dict represents one FPC slot:
|
|
* ``slot`` – FPC slot index (``int``)
|
|
* ``state`` – operational state (e.g. ``'Online'``, ``'Offline'``,
|
|
* ``cpu_util`` – CPU utilisation % (``int``) or ``None``
|
|
* ``memory_used`` – DRAM used in MB (``int``) or ``None``
|
|
* ``memory_total`` – total DRAM in MB (``int``) or ``None``
|
|
* ``temperature`` – temperature in Celsius (``int``) or ``None``
|
|
* ``ok`` – ``True`` when state is ``'Online'`` or ``'Empty'``
|
|
Example input::
|
Slot State (C) Total Interrupt DRAM (MB) Heap Buffer 0 Online 43 3 0 2048 34 47 1 Online 42 5 1 2048 36 49 2 Empty - - - - - - |
parse_interface_errors_junos ¶
Parse show interfaces extensive (or show interfaces detail) output.
Extracts per-interface error counters.
Returns:
| Type | Description |
|---|---|
list
|
List of per-interface error-counter dicts. Returns an empty list when the output cannot be parsed. |
Each returned dict contains:
|
|
* ``name`` – interface name (e.g. ``'ge-0/0/0'``, ``'xe-0/1/0'``)
|
|
* ``input_errors`` – total input errors (``int``)
|
|
* ``output_errors`` – total output errors (``int``)
|
|
* ``input_drops`` – input drops/discards (``int``)
|
|
* ``output_drops`` – output drops/discards (``int``)
|
|
* ``crc_errors`` – CRC/frame-check errors (``int``)
|
|
* ``has_errors`` – ``True`` when any counter is > 0
|
|
Example excerpt::
|
Physical interface: ge-0/0/0, Enabled, Physical link is Up Input errors: Errors: 0, Drops: 0, Framing errors: 0, Runts: 0, Giants: 0, Policed discards: 0, L3 incompletes: 0, L2 channel errors: 0, L2 mismatch timeouts: 0, FIFO errors: 0, Resource errors: 0 Output errors: Carrier transitions: 1, Errors: 0, Drops: 0, Collisions: 0, Aged packets: 0, FIFO errors: 0, HS link CRC errors: 0, MTU errors: 0, Resource errors: 0 |
parse_bgp_summary_junos ¶
Parse show bgp summary output from JunOS.
Returns:
| Type | Description |
|---|---|
list
|
List of BGP peer dicts. Returns an empty list when the output cannot be parsed. |
Each returned dict contains:
|
|
* ``neighbor`` – peer IPv4/IPv6 address (``str``)
|
|
* ``peer_as`` – remote AS number (``int``)
|
|
* ``state`` – session state (e.g. ``'Established'``, ``'Active'``,
|
|
* ``up_down`` – session uptime or time-since-reset string
|
|
* ``prefixes_received`` – prefixes received (``int``) when Established,
|
otherwise |
* ``active_prefixes`` – active prefixes (``int``) or ``None``
|
|
Example input::
|
Groups: 2 Peers: 3 Down peers: 0 Table Tot Paths Act Paths Suppressed History Damp State Pending inet.0 40 38 0 0 0 0 Peer AS InPkt OutPkt OutQ Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped... 10.0.0.1 65001 14621 14609 0 0 5d 3:14 Establ inet.0: 38/40/40/0 10.0.0.2 65002 1823 1821 0 1 1:23:45 Active 10.0.0.3 65003 0 0 0 0 never Connect |
parse_ospf_neighbors_junos ¶
Parse show ospf neighbor output from JunOS.
Returns:
| Type | Description |
|---|---|
list
|
List of OSPF neighbor dicts. Returns an empty list when the output cannot be parsed. |
Each returned dict contains:
|
|
* ``neighbor_id`` – OSPF Router-ID of the neighbour (``str``)
|
|
* ``address`` – neighbour interface IP address (``str``)
|
|
* ``interface`` – local interface name (``str``)
|
|
* ``state`` – adjacency state (e.g. ``'Full'``, ``'ExStart'``, ``'2Way'``)
|
|
* ``dead_time`` – dead-timer countdown in ``HH:MM:SS`` format (``str``)
|
|
* ``priority`` – interface priority (``int``)
|
|
* ``is_full`` – ``True`` when ``state == 'Full'``
|
|
Example input::
|
Address Interface State ID Pri Dead 10.0.0.2 ge-0/0/0.0 Full 192.168.1.2 1 33 10.0.0.3 ge-0/0/1.0 Full 192.168.1.3 1 35 10.0.0.4 ge-0/0/2.0 ExStart 192.168.1.4 0 38 |
parse_chassis_alarms ¶
Parse show chassis alarms output.
Returns:
| Type | Description |
|---|---|
list
|
List of alarm dicts. Returns an empty list when no alarms are present or the output cannot be parsed. |
Each returned dict represents one active alarm:
|
|
* ``time`` – timestamp string (e.g. ``'2024-01-15 10:23:01 UTC'``)
|
|
* ``class_`` – alarm class (``'Major'`` or ``'Minor'``)
|
|
* ``description`` – alarm description string
|
|
* ``is_major`` – ``True`` when class is ``'Major'``
|
|
Example input::
|
2 alarms currently active Alarm time Class Description 2024-01-15 10:23:01 UTC Major FPC 1 Major Errors 2024-01-15 10:30:12 UTC Minor PEM Input Failure |
parse_chassis_environment ¶
Parse show chassis environment output.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
Returns a dict with empty lists when the output cannot be parsed. |
Example input::
|
Class Item Status Measurement Power Power Supply 0 OK Power Power Supply 1 Absent Cooling FPC 0 Fan 0 OK 2250 RPM Cooling FPC 0 Fan 1 OK 2250 RPM Temp CPU OK 38 degrees C / 100 degrees F Temp FPC 0 OK 43 degrees C / 109 degrees F |
parse_route_summary ¶
Parse show route summary output.
Returns:
| Type | Description |
|---|---|
list
|
List of routing-table summary dicts. Returns an empty list when the output cannot be parsed. |
Each returned dict represents one routing table:
|
|
* ``table`` – routing table name (e.g. ``'inet.0'``, ``'inet6.0'``)
|
|
* ``active_routes`` – number of active (best-path) routes (``int``)
|
|
* ``holddown_routes``– routes in holddown state (``int``)
|
|
* ``hidden_routes`` – hidden routes (``int``)
|
|
* ``total_routes`` – total routes in the table (``int``)
|
|
Example input::
|
Routing table: inet.0 Destinations: 1204 Routes: 1219 Holddown: 0 Hidden: 0 Limit/Threshold: 1048576/1048576 destinations Direct: 3 routes, 3 active Local: 3 routes, 3 active BGP: 1213 routes, 1198 active |
parse_lldp_neighbors_junos ¶
Parse show lldp neighbors output from JunOS.
Returns:
| Type | Description |
|---|---|
list
|
List of LLDP neighbor dicts. Returns an empty list when the output cannot be parsed. |
Each returned dict contains:
|
|
* ``local_interface`` – local interface name (e.g. ``'ge-0/0/0'``)
|
|
* ``parent_interface`` – parent interface (e.g. ``'ae0'``, or ``'-'``)
|
|
* ``chassis_id`` – remote chassis ID (MAC address)
|
|
* ``port_id`` – remote port identifier or description
|
|
* ``system_name`` – remote system name
|
|
Example input::
|
Local Interface Parent Interface Chassis Id Port info System Name ge-0/0/0 - 00:11:22:33:44:55 Ethernet1 switch-1 ge-0/0/1 ae0 00:11:22:33:44:66 ge-0/0/0 router-2 xe-0/1/0 - aa:bb:cc:dd:ee:ff 1/1/1 nokia-3 |
parse_lacp_interfaces_junos ¶
Parse show lacp interfaces output from JunOS.
Returns:
| Type | Description |
|---|---|
list
|
List of LACP interface dicts. Returns an empty list when the output cannot be parsed. |
Each returned dict contains:
|
|
* ``name`` – aggregated interface name (e.g. ``'ae0'``)
|
|
* ``protocol`` – LACP protocol state (``'Up'`` / ``'Down'``)
|
|
* ``member_count`` – number of member links (``int``)
|
|
* ``members`` – list of member dicts, each with:
|
|
Example input::
|
Aggregated interface: ae0 LACP state: Role Exp Def Dist Col Syn Aggr Timeout Activity ge-0/0/0 Actor No No Yes Yes Yes Yes Fast Active ge-0/0/0 Partner No No Yes Yes Yes Yes Fast Active ge-0/0/1 Actor No No Yes Yes Yes Yes Fast Active ge-0/0/1 Partner No No Yes Yes Yes Yes Fast Active LACP protocol: Receive State Transmit State Mux State ge-0/0/0 Current Fast periodic Collecting distributing ge-0/0/1 Current Fast periodic Collecting distributing |
netops.parsers.nokia_sros¶
Nokia SR-OS CLI output parsers — interfaces, BGP, OSPF, system info, chassis, environment, routes, and LSPs.
nokia_sros ¶
Parsers for Nokia SR OS CLI output.
Covers classic CLI (7750, 7450, 7210, 7705, 7250 IXR, 7730 SXR) and handles common formatting variations across TiMOS releases.
Functions:¶
parse_interfaces ¶
Parse show port output into a list of interface dicts.
Returns:
| Type | Description |
|---|---|
list
|
List of interface dicts. |
Each dict contains:
|
|
* ``name`` – port identifier (e.g. ``'1/1/1'``, ``'1/1/c3/1'``)
|
|
* ``status`` – administrative state: ``'Up'`` or ``'Down'``
|
|
* ``protocol`` – operational state: ``'Up'`` or ``'Down'``
|
|
* ``up`` – ``True`` when both admin and oper state are ``'Up'``
|
|
Field names match the Cisco ``parse_cisco_interfaces`` convention so
|
|
callers can treat output from both vendors uniformly.
|
|
parse_bgp_summary ¶
Parse show router bgp summary output into a BGP peer list.
Returns:
| Type | Description |
|---|---|
list
|
List of BGP peer dicts. |
Each dict contains:
|
|
* ``neighbor`` – peer IPv4 address
|
|
* ``description`` – peer description string, or ``None``
|
|
* ``peer_as`` – remote AS number (``int``)
|
|
* ``received`` – prefixes received / Adj-RIB-In count (``int``)
|
|
* ``sent`` – prefixes advertised (``int``)
|
|
* ``active`` – active (best-path) prefixes (``int``)
|
|
* ``up_down`` – session uptime or time-since-reset (e.g. ``'1d02h'``)
|
|
* ``state`` – session state (e.g. ``'Established'``, ``'Active'``)
|
|
parse_ospf_neighbors ¶
Parse show router ospf neighbor output into an adjacency list.
Returns:
| Type | Description |
|---|---|
list
|
List of OSPF neighbor dicts. |
Each dict contains:
|
|
* ``interface`` – interface or link name (e.g. ``'to-core-1'``)
|
|
* ``router_id`` – neighbour router-ID as an IPv4 string
|
|
* ``state`` – OSPF adjacency state (e.g. ``'Full'``, ``'Init'``)
|
|
* ``priority`` – DR election priority (``int``)
|
|
* ``retx_queue`` – retransmit queue length (``int``)
|
|
parse_system_info ¶
Parse show system information output.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with normalised keys:
|
parse_chassis ¶
Parse show chassis or show chassis detail output.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with:
|
parse_cards ¶
Parse show card output into a list of card dicts.
Each dict contains:
slot– card slot number (str)card_type– provisioned or equipped card type stringadmin_state–'up'or'down'oper_state–'up','down','provisioned', etc.serial– serial number (fromshow card detail, may be None)part_number– part number (from detail, may be None)equipped_type– equipped type (may differ from provisioned)
parse_mda ¶
Parse show mda output into a list of MDA dicts.
Each dict contains:
slot– slot/mda identifier (e.g.'1/1')mda_type– provisioned MDA typeadmin_state–'up'or'down'oper_state– operational stateserial– serial number (None if not in output)equipped_type– equipped type
parse_bof ¶
Parse show bof (Boot Options File) output.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with:
|
parse_version ¶
Parse show version output.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with:
|
parse_service_summary ¶
Parse show service service-using output.
Returns:
| Type | Description |
|---|---|
list
|
List of dicts with:
|
parse_lag ¶
Parse show lag output.
Returns:
| Type | Description |
|---|---|
list
|
List of dicts with:
|
parse_router_interface ¶
Parse show router interface output.
Returns:
| Type | Description |
|---|---|
list
|
List of dicts with:
|
parse_lldp_neighbors ¶
Parse show system lldp neighbor output.
Returns:
| Type | Description |
|---|---|
list
|
List of dicts with:
|
Example input::
|
=============================================================================== Link Layer Discovery Protocol (LLDP) System Information =============================================================================== NB = nearest-bridge NTPMR = nearest-non-tpmr NC = nearest-customer =============================================================================== LLDP Neighbor Information =============================================================================== Lcl Port Scope Remote Chassis ID Index Remote Port Remote Sys Name 1/1/1 NB 00:11:22:33:44:55 1 Ethernet1 switch-1 1/1/2 NB 00:11:22:33:44:66 2 Ethernet2 switch-2 1/1/c3/1 NB 00:AA:BB:CC:DD:EE 3 ge-0/0/0 router-3 No. of Neighbors: 3¶ |
netops.parsers.paloalto¶
Palo Alto PAN-OS CLI output parsers — system info, interfaces, routes, sessions, security policy, and HA state.
paloalto ¶
Parsers for Palo Alto Networks PAN-OS CLI output.
Supports structured output for the core show commands used by
health checks and security policy audits.
Functions:¶
parse_system_info ¶
Parse show system info output from a PAN-OS device.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
Returns a dict with |
Example input lines::
|
Hostname: pa-fw-01 IP address: 10.0.0.1 Model: PA-3220 Serial: 0123456789AB PAN-OS Version: 10.2.3 App version: 8700-7709 Threat version: 8700-7709 URL filtering version: 20231201.20079 HA mode: Active-Passive HA state: active |
parse_interfaces ¶
Parse show interface all output from a PAN-OS device.
Returns:
| Type | Description |
|---|---|
list
|
List of per-interface dicts. Returns an empty list when the output cannot be parsed. |
Each returned dict contains:
|
|
* ``name`` – interface name (e.g. ``'ethernet1/1'``)
|
|
* ``state`` – interface state: ``'up'`` or ``'down'``
|
|
* ``ip`` – IP address with prefix length (e.g. ``'10.0.1.1/24'``),
|
or |
* ``vsys`` – virtual system the interface belongs to
|
|
* ``zone`` – security zone, or ``None`` when not displayed
|
|
* ``up`` – ``True`` when state is ``'up'``
|
|
Example input lines::
|
Name State IP (prefix) VSys Zone ethernet1/1 up 10.0.1.1/24 vsys1 trust ethernet1/2 up 203.0.113.1/30 vsys1 untrust ethernet1/3 down unassigned vsys1 loopback.1 up 1.1.1.1/32 vsys1 |
parse_routes ¶
Parse show routing route output from a PAN-OS device.
Returns:
| Type | Description |
|---|---|
list
|
List of per-route dicts. Returns an empty list when the output cannot be parsed. |
Each returned dict contains:
|
|
* ``destination`` – destination prefix in CIDR notation
|
|
* ``nexthop`` – next-hop IP address, or ``'0.0.0.0'`` for connected routes
|
|
* ``metric`` – route metric (``int``)
|
|
* ``flags`` – raw flags string (e.g. ``'A S'``)
|
|
* ``active`` – ``True`` when the ``A`` (active) flag is set
|
|
* ``type`` – route type letter(s) extracted from flags
|
( |
* ``age`` – route age string (e.g. ``'1d'``), or ``None``
|
|
* ``interface`` – egress interface name
|
|
Example input lines::
|
destination nexthop metric flags age interface 0.0.0.0/0 10.0.0.1 10 A S 1d ethernet1/2 10.0.1.0/24 0.0.0.0 0 A C - ethernet1/1 10.0.0.0/8 192.168.1.1 10 A B 1d ethernet1/2 |
parse_session_info ¶
Parse show session info output from a PAN-OS device.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
Any field that cannot be parsed will be |
Example input lines::
|
Number of sessions supported: 131072 Number of active sessions: 1234 Number of active TCP sessions: 1000 Number of active UDP sessions: 200 Number of active ICMP sessions: 34 Session utilization: 1% |
parse_security_policy ¶
Parse show running security-policy output from a PAN-OS device.
Returns:
| Type | Description |
|---|---|
list
|
List of per-policy dicts. Returns an empty list when the output cannot be parsed. |
Each returned dict represents one security rule and contains:
|
|
* ``name`` – rule name
|
|
* ``from_zones`` – list of source security zones
|
|
* ``to_zones`` – list of destination security zones
|
|
* ``sources`` – list of source address objects / prefixes
|
|
* ``destinations`` – list of destination address objects / prefixes
|
|
* ``applications`` – list of application names
|
|
* ``services`` – list of service objects
|
|
* ``action`` – rule action: ``'allow'``, ``'deny'``, or ``'drop'``
|
|
Example input::
|
Rule: web-access from trust to untrust source [ any ] destination [ any ] application [ web-browsing ssl ] service [ application-default ] action allow Rule: block-all from any to any source [ any ] destination [ any ] application [ any ] service [ any ] action deny |
parse_security_policy_stats ¶
Parse show security policy statistics output from a PAN-OS device.
Returns:
| Type | Description |
|---|---|
list
|
List of per-policy stats dicts. Returns an empty list when the output cannot be parsed. |
Each returned dict contains:
|
|
* ``name`` – rule name
|
|
* ``hit_count`` – number of times the rule has been matched (``int``)
|
|
* ``last_hit`` – last hit timestamp string, or ``None``
|
|
Example input::
|
Rule Name Hit Count Last Hit Date web-access 1523 2024-03-24 06:00:00 block-malware 45 2024-03-23 12:00:00 allow-dns 0 never unused-rule 0 never |
parse_ha_state ¶
Parse show high-availability state output from a PAN-OS device.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
Returns defaults ( |
Example input lines::
|
Group 1: Mode: Active-Passive Local state: active Peer state: passive Peer IP: 192.168.1.2 Preemptive: no |
netops.parsers.vlan¶
Cisco VLAN CLI parsers — VLAN brief table, trunk interfaces.
vlan ¶
Parsers for VLAN CLI output.
Supports Cisco IOS/IOS-XE:
show vlan brief→ :func:parse_vlan_briefshow interfaces trunk→ :func:parse_interfaces_trunk
Utility:
- :func:
expand_vlan_range— expands VLAN range strings ("1,10-20,100")
Functions:¶
expand_vlan_range ¶
Expand a VLAN range string into a set of integer VLAN IDs.
Handles comma-separated lists and dash-delimited ranges:
"10"→{10}"10,20,30"→{10, 20, 30}"10-14"→{10, 11, 12, 13, 14}"1,10-12,20"→{1, 10, 11, 12, 20}"none"→set()""→set()
Non-parseable tokens are silently ignored.
Returns:
| Type | Description |
|---|---|
set
|
Set of integer VLAN IDs. |
parse_vlan_brief ¶
Parse show vlan brief output.
Handles Cisco IOS and IOS-XE formats.
Returns:
| Type | Description |
|---|---|
list
|
List of per-VLAN dicts. Returns an empty list when the output cannot be parsed. |
Each returned dict contains:
|
|
* ``vlan_id`` – VLAN ID (``int``)
|
|
* ``name`` – VLAN name (``str``)
|
|
* ``status`` – status string, e.g. ``'active'``, ``'act/unsup'``
|
|
* ``ports`` – list of access-port names assigned to this VLAN
|
|
parse_interfaces_trunk ¶
Parse show interfaces trunk output.
Handles Cisco IOS and IOS-XE formats. The command output is divided into four stanzas; all four are parsed and merged per-port:
- Port / Mode / Encapsulation / Status / Native VLAN
- Port / VLANs allowed on trunk
- Port / VLANs allowed and active in management domain
- Port / VLANs in spanning tree forwarding state and not pruned
Returns:
| Type | Description |
|---|---|
list
|
List of per-interface trunk dicts. Returns an empty list when the output cannot be parsed or contains no trunking ports. |
Each returned dict contains:
|
|
* ``port`` – interface name
|
|
* ``mode`` – trunk mode (``'on'``, ``'auto'``, ``'desirable'``, …)
|
|
* ``encapsulation`` – ``'802.1q'``, ``'isl'``, or ``'n-802.1q'``
|
|
* ``status`` – ``'trunking'`` or ``'not-trunking'``
|
|
* ``native_vlan`` – native VLAN ID (``int``)
|
|
* ``allowed_vlans`` – raw allowed-VLAN string (e.g. ``'1-4094'``)
|
|
* ``active_vlans`` – set of active VLAN IDs (``set[int]``)
|
|
* ``forwarding_vlans`` – set of forwarding VLAN IDs (``set[int]``)
|
|