netops.check — Health & Compliance Checks¶
Composable health, BGP, interface, VLAN, and vendor-specific checks.
netops.check.health¶
Composable health checks for network devices.
Runs CPU, memory, interface-error, and log checks across vendors and reports results as structured JSON for monitoring integration.
CLI usage:
python -m netops.check.health --inventory inv.yaml --group core \
--threshold cpu=80,mem=85
python -m netops.check.health --host 10.0.0.1 --vendor cisco_ios \
--threshold cpu=80,mem=85 --json
health ¶
Composable health checks for network devices.
Runs CPU, memory, interface-error, and log checks across vendors and reports results as structured JSON for monitoring integration.
Usage::
python -m netops.check.health --inventory inv.yaml --group core \\
--threshold cpu=80,mem=85
python -m netops.check.health --host 10.0.0.1 --vendor cisco_ios \\
--threshold cpu=80,mem=85 --json
Classes¶
Functions:¶
check_cpu ¶
Return CPU utilisation check result.
check_memory ¶
Return memory utilisation check result.
check_interface_errors ¶
Return interface error-counter check result.
check_logs ¶
Return log-scan check result (critical/major events).
run_health_check ¶
run_health_check(params: ConnectionParams, cpu_threshold: float = DEFAULT_CPU_THRESHOLD, mem_threshold: float = DEFAULT_MEM_THRESHOLD) -> dict
Run all health checks against a single device.
Returns:
| Type | Description |
|---|---|
dict
|
Result dict with keys:
|
build_health_report ¶
Build an aggregated health report from a list of per-device results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
list[dict]
|
List of dicts returned by :func: |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Summary dict with keys:
|
netops.check.bgp¶
BGP peer monitoring — peer state, prefix counts, and flap detection.
CLI usage:
python -m netops.check.bgp --inventory inv.yaml
python -m netops.check.bgp --inventory inv.yaml --expected-prefixes 10.0.0.2=100 --fail-on-alert
bgp ¶
BGP session monitor — peer status, prefix counts, flap detection.
Checks BGP sessions across one or many routers and reports:
- Peer up/down status
- Prefix count vs expected (alert on configurable deviation %)
- Flap detection — sessions established for fewer than flap_min_uptime seconds are flagged as potentially flapping
- Summary report aggregated across all polled routers
Supports Cisco IOS/IOS-XE/IOS-XR and Nokia SR-OS.
Usage::
python -m netops.check.bgp --inventory inventory.yaml \\
--expected-prefixes 10.0.0.2=100,10.0.0.3=200 \\
--flap-min-uptime 300 --prefix-deviation 20
python -m netops.check.bgp --host 10.0.0.1 --vendor cisco_ios --json
Classes¶
Functions:¶
check_bgp_peers ¶
check_bgp_peers(params: ConnectionParams, expected_prefixes: dict[str, int] | None = None, flap_min_uptime: int = DEFAULT_FLAP_MIN_UPTIME, prefix_deviation_pct: float = DEFAULT_PREFIX_DEVIATION_PCT) -> dict
Check BGP peer status on a single device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
ConnectionParams
|
Device connection parameters. |
required |
expected_prefixes
|
dict[str, int] | None
|
Optional dict mapping neighbor IP → expected prefix count. An alert fires when the actual received-prefix count deviates from the expected value by more than prefix_deviation_pct percent. |
None
|
flap_min_uptime
|
int
|
Sessions established for fewer than this many seconds are flagged as potentially flapping (default: 300 s = 5 min). |
DEFAULT_FLAP_MIN_UPTIME
|
prefix_deviation_pct
|
float
|
Percentage threshold for prefix-count deviation alerts (default: 20%). |
DEFAULT_PREFIX_DEVIATION_PCT
|
Returns:
| Type | Description |
|---|---|
dict
|
Result dict with keys:
|
build_bgp_report ¶
Build an aggregated BGP report from a list of per-device results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
list[dict]
|
List of dicts returned by :func: |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Summary dict with keys:
|
netops.check.interfaces¶
Interface status and error checking.
CLI usage:
python -m netops.check.interfaces --host 10.0.0.1 --vendor cisco_ios --json
python -m netops.check.interfaces --host 10.0.0.1 --vendor cisco_ios --down-only
interfaces ¶
Check interface status across devices.
Usage: python -m netops.check.interfaces --inventory inventory.yaml --down-only python -m netops.check.interfaces --host 10.0.0.1 --vendor cisco_ios
netops.check.vlan¶
VLAN consistency audit across switching infrastructure.
CLI usage:
python -m netops.check.vlan --inventory inv.yaml --expected-vlans 10,20,30-50
python -m netops.check.vlan --inventory inv.yaml --vlan-db vlans.yaml --json
vlan ¶
VLAN audit — compare declared vs actual VLAN configuration across switches.
Checks VLAN configuration on a switch fabric and reports:
- Missing VLANs — declared VLANs not present on a switch
- Extra VLANs — VLANs present on a switch but not in the declared database
- Name mismatches — VLANs present but with a different name than declared
- Trunk mismatches — declared VLANs not active on trunk interfaces
- Per-switch compliance status
Supports Cisco IOS/IOS-XE.
Usage::
python -m netops.check.vlan --inventory inventory.yaml \\
--expected-vlans 10,20,30-50,100 \\
--check-trunks
python -m netops.check.vlan --host 10.0.0.1 --vendor cisco_ios \\
--vlan-db vlans.yaml --json
VLAN database file (vlans.yaml) format::
vlans:
10: MANAGEMENT
20: SERVERS
100: DMZ
Classes¶
Functions:¶
audit_vlans ¶
audit_vlans(params: ConnectionParams, expected_vlans: set[int], expected_names: dict[int, str] | None = None, check_trunks: bool = False, ignore_vlans: set[int] | None = None) -> dict
Audit VLAN configuration on a single switch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
ConnectionParams
|
Device connection parameters. |
required |
expected_vlans
|
set[int]
|
Set of VLAN IDs that should be present on the switch. |
required |
expected_names
|
dict[int, str] | None
|
Optional mapping of VLAN ID → declared VLAN name. When provided, name mismatches are included in the result. |
None
|
check_trunks
|
bool
|
When |
False
|
ignore_vlans
|
set[int] | None
|
Additional VLAN IDs to exclude from the extra VLANs check (system VLANs 1002–1005 are always excluded regardless). |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Result dict with keys:
|
build_vlan_report ¶
Build an aggregated VLAN audit report from per-switch results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
list[dict]
|
List of dicts returned by :func: |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Summary dict with keys:
|
netops.check.arista¶
Arista EOS health checks — uses eAPI JSON as the primary transport with CLI text fallback.
arista ¶
Arista EOS health checker.
Provides health checks for Arista EOS devices (DCS-7xxx, DCS-720x, etc.):
- CPU and memory utilisation
- Interface error counters and transceiver DOM
- BGP/EVPN session state
- OSPF adjacency verification
- MLAG health and config-consistency
- Environment — temperature sensors, fans, power supplies
eAPI JSON is the primary transport. Plain-text CLI output is used as a fallback when eAPI is unavailable.
Usage::
python -m netops.check.arista --host 10.0.0.1 --user netops \\
--threshold cpu=80,mem=85 --json
python -m netops.check.arista --inventory inv.yaml --group arista \\
--threshold cpu=80,mem=85 --fail-on-alert
Classes¶
Functions:¶
check_eos_cpu_memory ¶
Return CPU and memory utilisation check result.
Queries show version (JSON) and returns:
cpu_utilization– overall CPU % (float) orNonememory_util– memory utilisation % (float) orNonecpu_threshold– configured CPU alert thresholdmem_threshold– configured memory alert thresholdcpu_alert–Truewhen CPU ≥ cpu_thresholdmem_alert–Truewhen memory ≥ mem_thresholdalert–Truewhen either cpu_alert or mem_alerteos_version– EOS software version string orNonemodel– hardware model orNoneserial_number– chassis serial number orNoneerror– error message on failure, elseNone
check_eos_interfaces ¶
Return interface error-counter check result.
Queries show interfaces (JSON) and returns:
interfaces– list of per-interface dictstotal– total interfaces parsedwith_errors– count of interfaces with at least one error counter > 0alert–Truewhen any interface has errorserror– error message on failure, elseNone
check_eos_transceivers ¶
Return transceiver DOM check result.
Queries show interfaces transceiver (JSON) and returns:
transceivers– list of transceiver DOM dictstotal– total transceivers parsedwith_alerts– count of transceivers with DOM alertsalert–Truewhen any transceiver has a DOM alerterror– error message on failure, elseNone
check_eos_bgp ¶
Return BGP session state check result.
Queries show bgp summary (JSON) and returns:
peers– list of BGP peer dictstotal– total peers parsedestablished– count of peers in Established statenot_established– count of peers not Establishedalert–Truewhen any peer is not Establishederror– error message on failure, elseNone
check_eos_bgp_evpn ¶
Return BGP EVPN session state check result.
Queries show bgp evpn summary (JSON). Returns the same structure as
:func:check_eos_bgp.
check_eos_ospf ¶
Return OSPF neighbour state check result.
Queries show ip ospf neighbor (JSON) and returns:
neighbors– list of OSPF neighbour dictstotal– total neighbours parsedfull– count of adjacencies in Full statenot_full– count of adjacencies not in Full statealert–Truewhen any adjacency is not Fullerror– error message on failure, elseNone
check_eos_mlag ¶
Return MLAG health check result.
Queries show mlag and show mlag config-sanity (JSON) and returns:
mlag– parsed mlag status dictconfig_sanity– parsed mlag config-sanity dictis_active–Truewhen MLAG state is activepeer_link_ok–Truewhen peer-link is uppeer_active–Truewhen peer is activeconfig_consistent–Truewhen config-sanity reports consistentalert–Truewhen MLAG is active but has issueserror– error message on failure, elseNone
check_eos_environment ¶
Return environment (temperature, fans, PSUs) check result.
Queries show environment all (JSON) and returns:
power_supplies– list of PSU status dictsfans– list of fan status dictstemperatures– list of temperature sensor dictsoverall_ok–Truewhen every component reports OKalert–Truewhenoverall_okisFalseerror– error message on failure, elseNone
run_health_check ¶
run_health_check(params: ConnectionParams, cpu_threshold: float = DEFAULT_CPU_THRESHOLD, mem_threshold: float = DEFAULT_MEM_THRESHOLD, check_bgp: bool = True, check_evpn: bool = False, check_ospf: bool = True, check_mlag: bool = True, check_transceivers: bool = False) -> dict
Run all EOS health checks against a single device.
Runs:
- cpu_memory – CPU and memory utilisation
- interfaces – interface error counters
- transceivers – DOM alerts (when check_transceivers is
True) - bgp – BGP session states (when check_bgp is
True) - bgp_evpn – EVPN BGP sessions (when check_evpn is
True) - ospf – OSPF adjacency states (when check_ospf is
True) - mlag – MLAG health and config-sanity (when check_mlag is
True) - environment – PSUs, fans and temperatures
Returns:
| Type | Description |
|---|---|
dict
|
Result dict with keys:
|
build_eos_health_report ¶
Build an aggregated health report from a list of per-device results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
list[dict]
|
List of dicts returned by :func: |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Summary dict with keys:
|
netops.check.cisco¶
Cisco IOS/IOS-XE/IOS-XR/NX-OS health checks.
cisco ¶
Cisco IOS/IOS-XE health checker.
Extends the generic health check with Cisco-specific checks:
- CPU utilisation (
show processes cpu) - Memory utilisation (
show processes memory) - Interface error counters (CRC, input/output errors, drops)
- BGP neighbour state and prefix counts
- OSPF adjacency verification
- Environment — temperature, power supplies, fans
- Uptime and last reload reason
Supports IOS 15.x+ and IOS-XE 16.x+.
Usage::
python -m netops.check.cisco --host 10.0.0.1 --user admin \\
--threshold cpu=80,mem=85 --json
python -m netops.check.cisco --inventory inv.yaml --group core \\
--threshold cpu=80,mem=85 --fail-on-alert
Classes¶
Functions:¶
check_cisco_cpu ¶
Return CPU utilisation check result for a Cisco IOS/IOS-XE device.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
|
check_cisco_memory ¶
Return memory utilisation check result for a Cisco IOS/IOS-XE device.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
|
check_cisco_interfaces ¶
Return interface error-counter check result for a Cisco IOS/IOS-XE device.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
|
check_cisco_logs ¶
Return log-scan check result (severity 0–3 events) for a Cisco IOS/IOS-XE device.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
|
check_cisco_bgp ¶
Return BGP neighbour state check result for a Cisco IOS/IOS-XE device.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
|
check_cisco_ospf ¶
Return OSPF adjacency check result for a Cisco IOS/IOS-XE device.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
|
check_cisco_environment ¶
Return environment check result for a Cisco IOS/IOS-XE device.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
|
check_cisco_uptime ¶
Return uptime and reload reason check result for a Cisco IOS/IOS-XE device.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
|
run_cisco_health_check ¶
run_cisco_health_check(params: ConnectionParams, cpu_threshold: float = DEFAULT_CPU_THRESHOLD, mem_threshold: float = DEFAULT_MEM_THRESHOLD, include_bgp: bool = True, include_ospf: bool = True, include_environment: bool = True) -> dict
Run all Cisco IOS/IOS-XE health checks against a single device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
ConnectionParams
|
Device connection parameters. |
required |
cpu_threshold
|
float
|
CPU alert threshold in percent (default: 80). |
DEFAULT_CPU_THRESHOLD
|
mem_threshold
|
float
|
Memory alert threshold in percent (default: 85). |
DEFAULT_MEM_THRESHOLD
|
include_bgp
|
bool
|
When |
True
|
include_ospf
|
bool
|
When |
True
|
include_environment
|
bool
|
When |
True
|
Returns:
| Type | Description |
|---|---|
dict
|
Result dict matching the standard health-check schema:: |
build_cisco_health_report ¶
Build an aggregated health report from a list of per-device results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
list[dict]
|
List of dicts returned by :func: |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Summary dict with keys:
|
netops.check.juniper¶
Juniper JunOS health checks — Routing Engine status, FPC, BGP, OSPF, chassis alarms, environment, and route summary.
juniper ¶
Juniper JunOS health checker.
Provides health checks for Juniper JunOS devices (MX, QFX, EX, SRX):
- Routing Engine (RE) CPU and memory utilisation
- FPC slot operational status
- Interface error counters
- BGP neighbour state and prefix counts
- OSPF adjacency verification
- Chassis alarms (major/minor)
- Chassis environment — power, cooling, temperature
- Routing table summary
Supports JunOS 18.x+. Works with both XML RPC and CLI (text) modes via
Netmiko's juniper / juniper_junos device type.
Usage::
python -m netops.check.juniper --host 10.0.0.1 --user netops \\
--threshold cpu=80,mem=85 --json
python -m netops.check.juniper --inventory inv.yaml --group juniper \\
--threshold cpu=80,mem=85 --fail-on-alert
Classes¶
Functions:¶
check_junos_re ¶
Return Routing Engine CPU and memory check result.
Queries show chassis routing-engine and returns:
routing_engines– list of per-RE dicts from the parsercpu_utilization– highest CPU % across all REs (float) orNonemem_utilization– highest memory % across all REs (float) orNonecpu_threshold– configured CPU alert thresholdmem_threshold– configured memory alert thresholdcpu_alert–Truewhen any RE CPU ≥ cpu_thresholdmem_alert–Truewhen any RE memory ≥ mem_thresholdalert–Truewhen either cpu_alert or mem_alert isTrueerror– error message on failure, elseNone
check_junos_fpc ¶
Return FPC slot status check result.
Queries show chassis fpc and returns:
fpcs– list of per-FPC dicts from the parsertotal– total FPC slots parsedonline– count of FPCs in Online stateoffline– count of FPCs in Offline state (excluding Empty/Spare)alert–Truewhen any non-empty FPC is not Onlineerror– error message on failure, elseNone
check_junos_interfaces ¶
Return interface error-counter check result.
Queries show interfaces extensive and returns:
interfaces– list of per-interface error dicts from the parsertotal– total interfaces parsedwith_errors– count of interfaces with at least one non-zero error counteralert–Truewhen any interface has errorserror– error message on failure, elseNone
check_junos_bgp ¶
Return BGP neighbour state check result.
Queries show bgp summary and returns:
peers– list of peer dicts from the parsertotal– total BGP peers parsedestablished– count of peers in Established statenot_established– count of peers not in Established statealert–Truewhen any peer is not Establishederror– error message on failure, elseNone
check_junos_ospf ¶
Return OSPF neighbour state check result.
Queries show ospf neighbor and returns:
neighbors– list of neighbour dicts from the parsertotal– total OSPF neighbours parsedfull– count of adjacencies in Full statenot_full– count of adjacencies not in Full statealert–Truewhen any adjacency is not Fullerror– error message on failure, elseNone
check_junos_alarms ¶
Return chassis alarm check result.
Queries show chassis alarms and returns:
alarms– list of alarm dicts from the parsermajor_count– number of Major alarmsminor_count– number of Minor alarmsalert–Truewhen any Major alarm is presenterror– error message on failure, elseNone
check_junos_environment ¶
Return chassis environment check result.
Queries show chassis environment and returns:
power_supplies– list of PSU status dictsfans– list of fan status dictstemperatures– list of temperature sensor dictsoverall_ok–Truewhen every component reports OKalert–Truewhenoverall_okisFalseerror– error message on failure, elseNone
check_junos_routes ¶
Return routing table summary check result (informational).
Queries show route summary and returns:
tables– list of routing-table summary dictsalert– alwaysFalse(informational only)error– error message on failure, elseNone
run_health_check ¶
run_health_check(params: ConnectionParams, cpu_threshold: float = DEFAULT_CPU_THRESHOLD, mem_threshold: float = DEFAULT_MEM_THRESHOLD, check_bgp: bool = True, check_ospf: bool = True) -> dict
Run all JunOS health checks against a single device.
Runs:
- RE – Routing Engine CPU and memory utilisation
- FPC – slot operational status
- interfaces – error counters
- BGP – neighbour session states (when check_bgp is
True) - OSPF – adjacency states (when check_ospf is
True) - alarms – chassis alarm summary
- environment – power supplies, fans and temperatures
- routes – routing table summary (informational)
Returns:
| Type | Description |
|---|---|
dict
|
Result dict with keys:
|
build_junos_health_report ¶
Build an aggregated health report from a list of per-device results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
list[dict]
|
List of dicts returned by :func: |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Summary dict with keys:
|
netops.check.paloalto¶
Palo Alto PAN-OS health checks and security policy audit.
paloalto ¶
Security policy audit and health checks for Palo Alto Networks PAN-OS devices.
Policy audit::
python -m netops.check.paloalto --host 10.0.0.1 --audit
Health checks::
python -m netops.check.paloalto --inventory inv.yaml --group firewalls \\
--health --json
Classes¶
Functions:¶
check_unused_rules ¶
Identify security rules that have never been matched.
Correlates policy (from :func:~netops.parsers.paloalto.parse_security_policy)
with stats (from
:func:~netops.parsers.paloalto.parse_security_policy_stats) and
returns those rules whose hit count is zero.
Each returned dict is the original rule dict augmented with a
hit_count key (int).
:param policy: parsed list of security rule dicts :param stats: parsed list of per-rule hit-count dicts :returns: list of unused rule dicts (hit count == 0)
check_shadowed_rules ¶
Identify security rules that are shadowed by an earlier, broader rule.
A rule R[i] is considered shadowed when there exists an earlier rule R[j] (j < i) such that:
- R[j]'s source zones cover all of R[i]'s source zones (or R[j] uses
any) - R[j]'s destination zones cover all of R[i]'s destination zones (or
any) - R[j]'s sources cover R[i]'s sources (or
any) - R[j]'s destinations cover R[i]'s destinations (or
any) - R[j]'s applications cover R[i]'s applications (or
any)
The action of the shadowing rule is noted but not required to match —
an allow above a deny shadows the deny just as much as two
deny rules would.
Each returned dict is the original rule dict augmented with:
shadowed_by– name of the first earlier rule that shadows this one
:param policy: parsed list of security rule dicts (ordered as on device) :returns: list of shadowed rule dicts
run_policy_audit ¶
Run a full security policy audit against a connected device.
Collects the security policy and per-rule hit counts, then runs:
- unused rules – rules with zero hits
- shadowed rules – rules obscured by a broader preceding rule
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
|
check_ha ¶
Return HA state check result.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
|
check_sessions ¶
Return session table utilization check result.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
|
check_threat_status ¶
Return threat and URL filtering content status.
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys:
|
run_health_check ¶
run_health_check(params: ConnectionParams, session_threshold: float = DEFAULT_SESSION_THRESHOLD) -> dict
Run all PAN-OS-specific health checks against a single device.
Runs:
- HA state – checks that the local unit is in a stable HA role
- Sessions – checks session-table utilization against session_threshold
- Threat status – reports content versions (informational)
Returns:
| Type | Description |
|---|---|
dict
|
Result dict with keys:
|