USD Dynamic Groups - IP Range Queries

Document ID : KB000028225
Last Modified Date : 14/02/2018
Show Technical Document Details

Introduction: 

It is impossible to document every query for every possible result set that is needed. The purpose of USD (Unicenter Software Delivery) help examples is not to produce the specific result for every case, but to illustrate the principles of using the POSIX compliant regular expressions used in USD. This document provides insight into those principles to assist new users.

 

Background:  

Most UNIX users may already be familiar with the syntax and principles. The example result sets included using only the USD online help (from the USD query GUI simply click the "Help" button and search the topic "Regular Expressions in Conditions).

 

Environment:  

CA Client Automation - All versions

 

Instructions: 

Let's assume the result sought is the set of target computers with IP addresses between 175.25.0.1 and 175.25.0.10 inclusive. IP addresses are stored as strings and not values so the use of arithmetic operators (i.e., ">", "=", "<") can return unexpected results. The correct way to define criteria for strings is with pattern matching expressions. So to get the result for this example use ...

    Target.Address MATCHES '175[.]25[.]0[.][1-9]$'
              OR

                     Target.Address MATCHES '175[.]25[.]0[.]10$'

       

      Remember, dots (".") represent a single character wildcard so dots that are to be taken literally (like the dots between IP octets) must be enclosed in brackets. The "$" specifies that the pattern must be found at the end of the string. The expressions will be evaluated right to left. If the IP in the first record to be tested is "175.25.0.10, the first condition tested (Target.Address MATCHES '175[.]25[.]0[.]10$') is true, the record is added to the result set and the next record is checked. If the IP address in the next record is "175.25.0.4," it will also be added since, although the right most condition is not met, the "OR" operator is used and the next expression will be tested. Using "175.25.0.4" the expression Target.Address MATCHES '175[.]25[.]0[.][1-9]$' is true because the first three octets are an exact match and the last character (the last octet) contains a character in the range 1 through 9 [1-9]. Keep in mind the range when referring to strings as a set of characters and not a numeric value. Using the range of characters 1 through 10 ("[1-10]") will not return the expected results because the lexical compare precedes one character at a time and stops on the first non-match. When ordering strings, "2" is larger than "1*".

      For a more complex example, let's try for IP addresses between 175.25.0.30 and 175.25.0.150 inclusive. Other expressions may produce the same results, but the example below is straightforward and builds on the previous version...

      Target.Address MATCHES '175[.]25[.]0[.][3-9][ 0 -9]$'
      OR
      Target.Address MATCHES '175[.]25[.]0[.]1[0 -4][ 0 -9]$'
      OR
      Target.Address MATCHES '175[.]25[.]0[.]150$'

      The same type pattern matching expressions are used. The last (right most) expression will obviously only return true if the IP address is "175.25.0.150". The first (left most) expression will return true if the last character is in the set of characters 1 through 9 (remember, IP addresses are strings so it is not a numeric comparison) and the second to last character is in the set 3 through 9. Finally, the middle expression will return true if the last character is in the set 1 thru 9, the second to last character is in the set 1 thru 4 and the third character from the end is a "1".

      By studying the online help and with some practice, it should be possible to build queries that can return very specific results quickly and easily.