Question & Answer
Question
What is the Tivoli Netcool Performance Manager (Wireless Component) loader expressions language ?
Answer
The Tivoli Netcool Performance Manager (Wireless Component) Loader expressions language is used to calculate arithmetic and string expressions defined in the loader loadmap. It is required when it is not possible to get a column value directly from the input source. Typically, expressions are used for date and time conversion and arithmetic operations on counters, however the language should allow the user to define more complex expressions by using a set of mathematical and string-manipulating operations and pre-defined functions as well as conditional expressions.
Expression Language BNF
The following set of rules defines formal expression language grammar:
<expression> ::= <simple expression> |
<unary operation> |
<binary operation> |
<ternary operation> |
<assignment operation>
(
<delimiter> ::= tab character
space character
carriage return character
<simple expression> ::= <constant> | <variable> | <function>
<constant> ::= <string constant> | <numeric constant>
<string constant> ::= “[character...]”
<numeric constant> ::= <digit>...
<user variable> ::= <letter>
<letter> ::= A | B | C | D | E | F | G | H | I | J | K | L | M |
N | O | P | Q | R | S | T | U | V | W | X | Y | Z |
a | b | c | d | e | f | g | h | i | j | k | l | m |
n | o | p | q | r | s | t | u | v | w | x | y | z | _
<function> ::= <function identifier> (
)
<function identifier> ::= abs | sign | pow | exp | ln | round | truncate |
len | strstr | leftstr | rightstr | substr | lower |
upper | utime | date | now | lookup | round
<parameter list> ::=
<unary operation> ::= <unary operator> <simple expression> |
<unary operator> (
<unary operator> ::= - | +
<binary operation> ::= <expression>
<binary operator>
<binary operator> ::= + | - | * | / | > | >= | = | < | <= | !=
& | <delimiter> and <delimiter> |
<delimiter> or <delimiter> |
<delimiter> not <delimiter>
<ternary operation> ::= <conditional expression>
<conditional expression> ::= if <delimiter> <expression> <delimiter>
then <delimiter> <expression> <delimiter>
else <delimiter> <expression>
<assignment operation> ::= <variable>
Notes.
1. Words in bold are terminating symbols of the grammar, i.e. they can only appear on the right side of the rules. Words in bold italic are either non-printable or character set/NLS dependent characters:
· tab character is ‘\t’ in C language,
· space character is the space in the current character set,
· carriage return character is one or more symbols interpreted as a carriage return.
· character is any symbol from the current character set.
2. Although according to the above rules some grammar symbols can have variable length, maximum length of variable names and the maximum length of numerical and string constants are currently limited to 256 characters.
3. The expression language is case insensitive. However variable names ARE case sensitive.
4. Variable name cannot be one of the reserved words such as ‘if’, ‘and’ and so on. It also cannot be the same as a predefined function name (for example, ‘abs’, ‘strstr’, date, time).
5. The Loader Expressions language is not typified. For example, if v1 equals "2" and v2 equals "3.14", then v1 * v2 evaluates to "6.28" and v1 & v2 evaluates to "23.14". All the type casts are performed automatically and a run time error is returned if the type conversion is not possible (e.g. "abc" + a).
Operators
The following operators are available in the expression language:
| Unary operators | |
| - | Unary minus, specifies negative values. |
| + | Unary plus, specifies positive values. |
| Not | Logical operator |
| Binary operators | |
| + - * / | Numeric addition, subtraction, multiplication and division. |
| & | String concatenation. |
| > >= = <= < != | Numeric and string relational operators. |
| and or | Logical operators |
| := | Assignment operator |
| Ternary operators | |
| if … then … else … | Conditional expression |
Predefined Functions
The following functions are available to users of the expression language
| Mathematical | |
| exp(a) | The exponential function, returns ea. |
| ln(a) | The log function, returns the natural log of a |
| abs(a) | The absolute function, returns the absolute value of a. |
| pow(a, b) | The power function, returns ab. |
| sign(a) | Returns –1 if a is negative and 1 if a is positive or 0. |
| round(a, n) | Rounds a up to n digits after the point. |
| truncate(a, n) | Truncates a up to n digits after the point. |
| String | |
| len(s) | Returns length of string s. |
| strstr(s1, s2) | Returns the position in the string s1 where string s2 first occurs. Return –1 if s2 is not found in s1. |
| leftstr(s, n) | Returns sub-string of string s containing the n left most characters. |
| rightstr(s, n) | Returns sub-string of string s containing the n right most characters. |
| substr(s, n, m) | Returns sub-string of string s containing the n characters (or the rest of the string if n is negative) starting from position m. |
| upper(s) | Return string s in uppercase. |
| lower(s) | Returns string s in lowercase. |
| Other functions | |
| utime(date_str, format) | Converts date and time specified by string date_str into UNIX datetime format (number of seconds since 1st January 1970 midnight).
The second parameter specifies the format string. See strptime() C library function description for a list of allowed field descriptors. Here is the list of valid specifiers on SunOS 5.8: %% Same as %. %a Day of week, using the locale's weekday names; either the abbreviated or full name may be specified. %A Same as %a. %b Month, using the locale's month names; either the abbreviated or full name may be specified. %B Same as %b. %c Locale's appropriate date and time representation. %C Century number %d Day of month [1,31]; leading zero is permitted but not required. %D Date as %m/%d/%y. %e Same as %d. %h Same as %b. %H Hour (24-hour clock) [0,23]; leading zero is permitted but not required. %I Hour (12-hour clock) [1,12]; leading zero is permitted but not required. %j Day number of the year [1,366]; leading zeros arepermitted but not required. %m Month number [1,12]; leading zero is permitted but notrequired. %M Minute [0-59]; leading zero is permitted but not required. %n Any white space. %p Locale's equivalent of either a.m. or p.m. %r Appropriate time representation in the 12-hour format with %p. %R Time as %H:%M. %S Seconds [0,61]; leading zero is permitted but not required. %t Any white space. %T Time as %H:%M:%S. %U Week number of the year as a decimal number [0,53], with Sunday as the first day of the week; leading zeros are permitted but not required. %w Weekday as a decimal number [0,6], with 0 representing Sunday. %W Week number of the year as a decimal number [0,53], with Monday as the first day of the week; leading zero is permitted but not required. %x Locale's appropriate date representation. %X Locale's appropriate time representation. %y The year within century. When a century is not otherwise specified, values in the range 69-99 refer to years in the twentieth century (1969 to 1999 inclusive); values in the range 00-68 refer to years in the twenty-first century (2000 to 2068 inclusive). Leading zeros are permitted but not required. %Y Year, including the century (for example, 1993) [1-9999]. |
| date(date_utc ,format) | Converts date/time in form of UTC into its string representation.
Optionally, the format string containing the same qualifiers as in previous function can be specified. See strftime() C library function description for a list of allowed field descriptors. |
| now() | Returns current date and time in UTC format. |
| Lookup(tab, col, date, key) | Lookup a value of column specified by string col in a hierarchy table specified by string tab. The table is accessed by key (integer) and date (in UTC format). |
Expression Language Syntax Examples
· lookup
| Lookup(tab, col, date, key) | Lookup a value of column specified by string col in a hierarchy table specified by string tab. The table is accessed by key (integer) and date (in UTC format). |
The lookup function works as follows:
It tries to find a column value (‘col’ – argument 2) in the nc table (‘tab’ – argument 1) with a timestamp earlier than or equal to the timestamp supplied in the lookup call(‘date’, argument 3). The ‘key’ value, argument 4, is used to compare against the access_key (specified in lc_relations) for the nc_table.
The lookup is translated into a retrieval statement by the loader and the result returned by the expression. For example, the following lookup
lookup("nc_cell","bts_id",utime(STARTDATE,"%d %b %Y"),CELLID)
is translated into
Select bts_id
From nc_cell
Where cell_id = <CELLID value>
And timestamp <= <STARTDATE value>
· the timestamp in nc_cell does not have to match the date value in the call to lookup. As long as the timestamp in nc_cell is earlier than or equal to the value supplied in the lookup, it will return a value.
· the lookup function accesses data stored in the NC Cache not the NC database tables.
· the nc table used in a lookup must be configured in lc_relations. The lookup function needs to find the access key of the nc table. Also, the lookup function interrogates NC cache and the NC data does not get loaded into shared memory unless it is configured in lc_relations.
Note : Lookup Functions may have performance implications depending on expression , nesting used .
Product Synonym
TNPMW TNPM
Was this topic helpful?
Document Information
Modified date:
23 June 2018
UID
swg21469833