> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.itential.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.itential.com/_mcp/server.

# Comparison rule examples

> Worked examples for configuring rules, comparison operators, and operands in a command template.

These examples demonstrate how to configure `#comparison` rules and their operands. Examples 1 and 2 use the same device command and top operand — they differ only in how the bottom operand is defined: Example 1 uses a static value, Example 2 uses a variable. Example 3 is an independent scenario that uses the `%` operator to compare two values both extracted from the device response.

## Example 1: Verify device memory (static threshold)

This example verifies that a Cisco CSR has at least 3000 MB of installed memory. The IOS command `show platform software vmemory info` returns memory statistics including total system memory.

#### Create a command template

Create a new command template and select a device for testing.

#### Enter the command

Type `show platform software vmemory info` in the **Command #1** field. Under **Rules**, keep the default `contains` operator.

#### Test the command

Click **Test This Command** to confirm the command runs. Example **Test Results** output:

```
Memory Upgrade Limits:
    Total System Memory:        3890 MB
    Memory From Upgrade Licenses:   0 MB
    Memory From Feature Licenses:   0 MB
Memory Available For Upgrade:
    Available System Memory:    0 MB
    Available Upgrade Licensed Memory:  0 MB
    Available Feature Licensed Memory:  0 MB
Current Memory Allocation:
    IOSD:   2354 MB (default) + 0 MB upgrade
    Data Plane: 1536 MB (default) + 0 MB upgrade
```

### Build the top operand

#### Select RegEx

Change the operator to **RegEx**.

#### Enter a regular expression

Type `Total System Memory:\s+\d+ MB` in the rule field to match the line containing the memory value.

#### Test

Click **Test This Command**. A green check confirms the expression matches. A red dash indicates an error in the expression.

#### Switch to comparison

Change the operator to `#comparison`.

#### Add slashes and a capture group

Wrap the expression in `/` characters, then add parentheses around the numeric value to create a capture group:

```
/Total System Memory:\s+(\d+) MB/
```

#### Set the comparison operator

Select **>=**.

### Build the bottom operand

#### Enter the threshold

Type `3000` in the **Compare with** field.

#### Test

Click **Test This Command**. A green check confirms the installed memory meets the threshold.

## Example 2: Verify device memory (variable threshold)

This example extends Example 1. Instead of comparing against a hardcoded value, the threshold is passed in as a variable, allowing the same template to be reused with different thresholds at runtime.

### Bottom operand

Type `<!MEM-THRESH!>` in the **Compare with** field. The variable `MEM-THRESH` is passed to the template at execution time.

## Example 3: Verify BGP prefix count against warning threshold

This example verifies that the number of accepted BGP prefixes from a neighbor has not exceeded the configured warning threshold. The adjacency allows a maximum of 10 prefixes and logs a warning at 80%.

The IOS command `show ip bgp neighbor X.X.X.X` returns the accepted prefix count, the maximum prefix limit, and the warning threshold.

#### Create a command template

Create a new command template and select a device for testing.

#### Enter the command

Type `show ip bgp neighbor X.X.X.X` in the Command 1 field, replacing `X.X.X.X` with a valid EBGP neighbor router ID. Keep the default `contains` operator.

#### Test the command

Click **Test This Command**. Example output:

```
Router_B#show ip bgp neighbor 10.0.0.1
BGP neighbor is 10.0.0.1,  remote AS 200, external link
BGP version 4, remote router ID 10.0.0.1
BGP state = Established, up for 00:13:22
Last read 00:00:21, hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
    Route refresh: advertised and received(old & new)
    Address family IPv4 Unicast: advertised and received
    IPv4 MPLS Label capability:
Received 930 messages, 0 notifications, 0 in queue
Sent 919 messages, 1 notifications, 0 in queue
Default minimum time between advertisement runs is 30 seconds

For address family: IPv4 Unicast
BGP table version 30, neighbor version 30
Index 1, Offset 0, Mask 0x2
Route refresh request: received 0, sent 0
9 accepted prefixes consume 432 bytes
Prefix advertised 0, suppressed 0, withdrawn 0, maximum limit 10 (warning-only)
Threshold for warning message 80%

Connections established 2; dropped 1
Last reset 00:29:13, due to BGP Notification sent, update malformed
...
```

#### Configure the comparison rule

Set the following:

* Operator: `#comparison`
* **Rule** field: `/maximum limit\s(\d+)/`
* Comparison operator: `%`
* **Max accepted %** field: `80`
* **Compare with** field: `/(\d+) accepted prefixes/`