Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Junos Snapshot Administrator Configuration File

 

Understanding the Junos Snapshot Administrator Configuration File

The Junos Snapshot Administrator configuration file defines the scope of a snapshot and the evaluation criteria for either a single snapshot or a comparison of two snapshots. You provide the location of the Junos Snapshot Administrator configuration file as an argument to the jsnap command.

In the Junos Snapshot Administrator configuration file, curly braces delimit code blocks, and semicolons signal the end of a statement or command. You can insert comments into the configuration file by using either a hash (#) or a semicolon (;) at the start of a line.

The Junos Snapshot Administrator configuration file consists of a required do code block placed at the beginning of the configuration file followed by any number of user-defined test sections. Details of the individual configuration file components are described in the following sections:

do Section

The do code block lists the name of each test section that will be used in the snapshot. This section is mandatory and must be placed at the start of the configuration file. You can define as many test sections as desired, but you must include the test section name in the do code block in order to execute that test. The syntax of the do code block is:

For example, the following do code block lists five test sections. When Junos Snapshot Administrator references the configuration file, although the configuration file might define more than five test sections, the tool only executes the five test sections listed in the do code block.

Test Sections

Within the configuration file, you define one or more test sections. The test sections, which are placed in any order after the do code block, define the scope of a snapshot and the evaluation criteria for a single snapshot or a comparison of two snapshots.

Each test section consists of a unique configuration stanza, which contains:

  • The section name—Unique, user-defined string that should describe the check being performed.

  • One command statement—Specifies the Junos OS operational mode command that is executed to collect the data.

  • One or more item or iterate content section declarations—Defines the test cases used to evaluate the data.

The general syntax of the test section code block is:

For example:

The test section components are described in detail in the following sections:

Test Section Name

Test section names are unique, user-defined strings that should describe the check being performed. You add the names of the test sections that you want to execute to the do code block at the start of the configuration file. When Junos Snapshot Administrator references the configuration file, the tool executes any test sections that are listed in the do code block.

Ideally, you should create descriptive test section names so that you or anyone else working with the configuration file can quickly discern the scope and purpose of each test section long after the configuration file is created. For example, you might use active-chassis-alarm-check for a test section that checks whether there are any active chassis alarms, as shown here:

Test Section Command Statement

Each test section consists of a single command identifier followed by the Junos OS operational mode command that is executed to collect the desired data for that check. For example, if you want to collect and evaluate data about the OSPF neighbors for an interface, you would include the command identifier followed by the show ospf neighbor operational mode command, as shown here:

Provided the ospf-neighbor-check section name is included in the do code block, the resulting snapshot will include the XML data from the show ospf neighbor command output. For more information about Junos OS operational mode commands, see the Junos XML API Operational Reference. A sample of the show ospf neighbor output is shown here:

You can evaluate specific elements in the snapshot output or compare elements across multiple snapshots by defining test cases.

Test Section Evaluation Criteria

The test section command statement can be followed by either an item or iterate content section declaration, within which you define one or more test cases for evaluating the captured snapshot data. You use the item statement to uniquely identify a specific element, and the iterate statement to iterate over multiple elements.

The general syntax for the content section declaration is:

Each test case is defined by a test operator followed by any required parameters. For more information about available test operators see Understanding Junos Snapshot Administrator Test Operators and Junos Snapshot Administrator Test Operators Summary. Within the test-case code block you define an info statement to provide information about the test case and expected operating conditions. You also define one or more err statements, which are generated when the content fails the specific test case.

The following example has a test case that checks the XML output of the show chassis routing-engine command to determine if the Routing Engine in slot 0 is the primary Routing Engine. If the mastership-state of the Routing Engine in slot 0 is not equal to "master", the code generates two err statements.

When using certain test operators to compare element values across two snapshots, in order to map the first snapshot data item to a second snapshot data item, you must select elements of the data that create a unique ID. To create a unique ID for a test case, you include the id statement followed by an XPath expression that references the unique element. To create a unique ID based on multiple element values, you define multiple id statements. You can also construct ID values relative to the content value. For detailed information about creating ID values, see Understanding Junos Snapshot Administrator Test Operators.

Example: Creating the Junos Snapshot Administrator Configuration File

This example creates a basic sample Junos Snapshot Administrator configuration file.

Requirements

  • Junos Snapshot Administrator Release 1.0 is installed on the server.

Overview

This example creates a Junos Snapshot Administrator configuration file with one test section named re0-master. The re0-master test section retrieves and parses the XML output from the Junos OS operational mode command show chassis routing-engine. A sample of the XML output from a dual Routing Engine device is shown here:

For a dual Routing Engine device, the test case checks the XML output to determine if the Routing Engine in slot 0 is the primary Routing Engine. The test section uses the item route-engine[slot = '0'] expression to select the route-engine element that has the child element slot value of "0". The test case uses the is-equal test operator to compare the value of the mastership-state child element with the string value "master". If the test case returns true, the Routing Engine in slot 0 is the primary Routing Engine. If the test case returns false, the code reports two error statements.

The mandatory do section includes the names of all test sections that should be executed when Junos Snapshot Administrator references this configuration file. For this example, the do section contains only re0-master.

Configuration

The Junos Snapshot Administrator configuration consists of a mandatory do section and one or more test sections.

Configuring Test Sections

Step-by-Step Procedure

The Junos Snapshot Administrator configuration consists of test sections that define the commands and evaluation criteria that are used in a snapshot or snapshot comparison. To configure a test section:

  1. Name the test section using a unique and descriptive string.
  2. Add the command statement, and specify the Junos OS operational mode command that the code executes to retrieve the desired XML data.
  3. Add the iterate or item statement followed by the XPath expression that selects the desired elements.
  4. If the test section compares elements from two snapshots, add the id statement specifying a unique ID to map the first snapshot data item to the second snapshot data element.

    This example does not require an id statement.

  5. Create the test case condition used during the check.
  6. Within the test case code block, add the info statement describing the test case or normal operating conditions.
  7. Within the test case code block, add one or more err statements, which are executed if the test case fails.

Configuring the "do" Section

Step-by-Step Procedure

The Junos Snapshot Administrator configuration file must begin with a do code block that defines the test sections to be used in the snapshot.

  1. At the beginning of the configuration file, add the do code block.
  2. Add the name of each test section that will be used in the snapshot.

Results