Skip to content

Diff Agent

The Diff Agent detects what changed between two snapshots. Compare any operational table β€” topology links, BGP neighbors, OSPF state, interface status, or raw configs.

Feature Claims

ID Claim Status
C-NE-26 diff_topology_drift detects link up/down state changes between snapshots πŸ”Ά Env-Blocked
C-NE-27 diff_sql_state compares any table between two snapshot IDs πŸ”Ά Env-Blocked

When to Use

  • "What changed in the network since yesterday?"
  • "Compare BGP neighbors between last two snapshots"
  • "Did any links go down since the maintenance window?"
  • "Show config differences on R1"

Tools

Tool Purpose
diff_sql_state Compare any table between two snapshot_ids using SQL EXCEPT
diff_topology_drift Physical link state changes (up β†’ down, down β†’ up)
diff_routing_drift Routing shifts: lost prefixes, next-hop changes, AS-PATH changes
diff_configs Raw config file comparison (unified diff)

How It Works

diff_sql_state

The most flexible tool β€” compares any table or view between two snapshots:

diff_sql_state(
    table: str,           # Table or view name
    snapshot_old: str,     # T1 snapshot_id (before)
    snapshot_new: str,     # T2 snapshot_id (after)
    key_columns: list[str] # Columns that identify a unique row
)

Internally uses EXCEPT to find rows added, removed, or changed:

-- Rows in T2 but not T1 (added or changed)
SELECT * FROM table WHERE snapshot_id = :t2
EXCEPT
SELECT * FROM table WHERE snapshot_id = :t1

diff_topology_drift

Specialized for topology changes:

  • Links that went down (present in T1, absent or down in T2)
  • Links that came up (absent or down in T1, present and up in T2)
  • Interface changes (speed, duplex, errors)

diff_routing_drift

Specialized for routing changes:

  • Lost prefixes β€” routes in T1 but not in T2
  • New prefixes β€” routes in T2 but not in T1
  • Next-hop shifts β€” same prefix, different next-hop
  • AS-PATH changes β€” BGP path attribute drift

diff_configs

Raw text comparison of show running-config output between snapshots. Produces unified diff output.


Example

olav --agent ops "What changed in BGP neighbors between the last two snapshots?"

The orchestrator:

  1. Routes to Diff agent
  2. Diff queries the two most recent snapshot IDs
  3. Runs diff_sql_state on v_bgp_neighbors_auto
  4. Returns a table of added/removed/changed BGP sessions