Excluding specific parts of configuration from comparison in the NCM
Configuration files store critical information like interface configurations, router configurations, ACLs, security configurations, QoS policies, VLAN configurations, infrastructure and application settings, and other device management settings that define a device's behavior within a network. They help manage various network parameters and customize your networks.
Site24x7's Network Configuration Manager (NCM) sends alerts if there is any change in the configuration file based on the threshold configuration. Additionally, you can also view if there are conflicts between any versions of the startup and running configurations.
However, some changes can be ignored based on your discretion. For instance, there might be commented lines or encrypted password strings (which may change for each configuration
version) that could be causing repeated alerts, even though there are no other changes in the configuration file.
To understand this, compare configurations or different versions to see all the differences between them.
Assume there's a change in the current running configuration. If there's a threshold profile that checks for any change in the running configurations, it can lead to alerts being generated and unexpected changes in the status of a device. Figure 1 illustrates such differences, which may result in the device's status being set to Down, Trouble, or Critical, depending on the settings specified in the threshold profile (an example is shown in Figure 2).
![](/help/images/compare-configuraions-image.png)
Figure 1. Configuration differences between startup and running versions.
Additionally, you will also be able to see conflicts on the Monitor Status screen.
To exclude differences from comparison, Site24x7's NCM uses regular expressions.
What are regular expressions?
A regular expression is used to check for matches in a search based on a sequence of patterns.
Here are some common expressions that you can use to create the regular expression that you require:
Expression | Explanation | Example |
^ | Start of string | ^abc |
$ | End of string | abc$ |
* | Zero or more occurrences of the preceding element | a* |
+ | One or more occurrences of the preceding element | a+ |
? | Zero or one occurrences of the preceding element | a? |
.(Period) | Any character, except new line (\n) | .a |
\s | Any whitespace character | hello\sworld |
\d | Any single digit | a\d |
\w | Any word character | a\w |
\ | Escapes a special character | a\. |
[ ] | Any characters present within the brackets |
[a-z] - for lowercase elements [A-Z] - for uppercase elements |
{ n } | n occurrences of the preceding element |
a{3} |
{n , x} | Between n and x occurrences of the preceding element |
a{2,4} |
[ ^ ] | Does not match with the single character present within the brackets |
[^a] |
The following table describes a few regular expressions with examples:
Regular expression | Explanation | Example |
^\s*!.* |
^ - Start of the line \s* - Space, zero or more instances ! - Contains ! after the previous checks .* - Any character, zero or more instances |
! Last configuration change at 09:29:02 UTC Thu Nov 16 2023 |
^\s*Current\sconfiguration\s:\s\d*\s*bytes\s* |
^ - Start of the line \s* - Space, zero or more instances Current - Matches with the word Current \s - Single space configuration - Matches with the word configuration \s - Single space : - Matches with the character : \s - Single space \d* - Any number (0-9), zero or more instances \s* - Space, zero or more instances bytes - Matches with the word bytes \s* - Space, zero or more instances |
Current configuration : 3215 bytes |
^\s*speed.* |
^ - Start of the line \s* - Space, zero or more instances speed - Matches with the word speed .* - Any character, zero or more instances |
speed 100 |
Other common regular expressions:
Regular expression | Exclude lines |
^\s*#.* | Beginning with # |
^\s*set\spassword.*$ | Beginning with set password |
^\s*set\spasswd\d\sENC.*$ | Beginning with set passwd followed by a single digit number followed by ENC |
^\s*Cryptochecksum:.* | Beginning with CryptoCheckSum |
^\s*usrpw\s.* | Beginning with usrpw |
.*Configuration\sdump\staken\s.* | Containing Configuration dump taken |
^\s*boot\ssystem\sflash\sflash:.* | Beginning with boot system flash: |
^\s*Current configuration\s:\s\d*\s*bytes\s* | Beginning with Current Configuration: |
^\s*Uncompressed configuration.* | Beginning with Uncompressed file content command |
^\s*!\s*.*Last\s*configuration.* | Beginning with ! followed by Last Configuration header |
^\s*ntp\s*clock-period.* | Beginning with ntp clock-period |
^Building\sconfiguration.* | Containing Building configuration |
^\s*system-uptime.*$ | Beginning with system-uptime |
^\s*shared-secret.*$ | Beginning with shared-secret |
^\s*authentication\ssha1.*$ | Beginning with authentication sha1 |
^\s*encryption\saes.*$ | Beginning with encryption aes |
^\s*checksum.*$ | Beginning with checksum |
^\s*[a-z\-\s]{0,20}password.*$ | Containing the word password after 0 to 20 elements |
^\s*time.*$ | Beginning with time |
^\s*date.*$ | Beginning with date |
^\s*authentication\smd5.*$ | Beginning with authentication md5 |
^\s*encryption\sdes.*$ | Beginning with encryption des |
^\s*radius\s\w{0,10}\sserver\d\ssecret.*$ | Beginning with radius followed by server and secret |
^\s*[a-z\-\s]{0,5}pass.*$ | Containing the word pass after 0 to 5 elements |
You can use our Regex Tester and Debugger Tool to validate regular expression patterns.
To modify the criteria to exclude specific content during configuration comparison
- Log in to your Site24x7 account.
- Navigate to Network > NCM > Device Templates.
- Click the device template for which you wish to set the exclude criteria to view the details.
Figure 2. Device Templates screen. - Click Exclude Criteria. You will see the default excluded criteria provided in the device template and custom criteria if it has been added already. Close the Exclude Criteria pop-up to go back to the Device Template details screen.
- To add, edit, or delete custom criteria, click Edit Device Template in the top-right of the screen. Alternatively, you can click the pencil icon
beside the appropriate device template in the third step (Figure 4, marked in blue).
- Then, click Exclude Criteria. You can edit any existing custom criteria here by modifying the details in the editable fields.
- Click the X icon beside the Description column to delete a previously added criterion.
To add a new criterion
- Click Exclude Criteria on the Edit Device Template screen.
- Enter the details in a row with blank fields. Or, to add more than one criterion, click the plus + icon.
- Provide a display name.
- Next, provide the regular expression pattern in the RegEx column. For example, if you wish to exclude the statements speed and Current configuration in Figure 1 from showing up in differences, you can provide the pattern to exclude it as shown in Figure 3.
Figure 3. Device Templates screen. - Provide details in the Description column.
- Click Save.
Figure 4. Comparing configurations after adding excluded criteria.