/
Trigger-Template

Trigger-Template

A text snippet that defines the command syntax to match against the output from the device. You can call values from variables in a Trigger-Template to flexibly match multiple instances or to detect a particular value.

When NetMRI's CCS scripting engine receives the output from the executed command sequence, CCS references the first output trigger to process the command output. Within the trigger, a segment of command output, using variables and wildcards if necessary, ranges over the output stream and executes an associated set of Trigger-Commands if necessary (see following section).

Example

Trigger-Template:

username $username password 0 .*

This example shows Cisco but can be for any vendor supported by NetMRI.

The Trigger-Template provides a pattern matching window that is applied across the most recent CLI command output stream. The template matches characters in the command output zero to possibly many times. If no matches occur, the script stops the execution of the trigger. If one or more template matches is found, the trigger continues processing the Trigger-Filter for each match.

Example

Consider the following Trigger-Template which uses declared Trigger-Variables ($ifName and $ifDuplex); note the use of the “+” operator, which matches against 1 to n instances of a set of characters:

Trigger-Template:

[[$ifName]] is.+, line protocol is.+

...

Keepalive.+

[[$ifDuplex]]-duplex.+

and the following output stream:

0 lost carrier, 0 no carrier

0 output buffer failures, 0 output buffers swapped out

FastEthernet0/1 is up, line protocol is up

Hardware is Fast Ethernet, address is 0002.b9fc.b701

MTU 1500 bytes, BW 10000 Kbit, DLY 1000 usec,

reliability 255/255, txload 1/255, rxload 1/255

Encapsulation ARPA, loopback not set

Keepalive not set

Auto-duplex (Half), Auto Speed (10), 100BaseTX/FX

ARP type: ARPA, ARP Timeout 04:00:00

Last input 00:00:00, output 00:00:00, output hang never

Last clearing of "show interface" counters never

The Trigger-Template matches the previous command output stream, because the Template contains several regular expressions and fixed patterns.

Because the Trigger-Template matches at least once, the processing of the Trigger continues. Because the Template uses previously defined Trigger-Variables (within double-brackets “[[ ]]”), the script extracts corresponding values from the command output stream for use in the Trigger-Filter. For example, $ifName now contains the value FastEthernet0/1 and $ifDuplex contains the value Auto.

The pattern matching notation “...” appearing in the above Trigger-Template means “match 0 or more lines” and is used to skip over multiple lines of text while scanning for the next occurrence of a pattern (e.g., the text Keepalive).

Related content