Compute Expressions

You use compute expressions to calculate the value of a metric column based on mathematical or logical operations performed on other metric columns.

Compute expressions require at least one other metric column to be defined first, and can only include those metric columns that are listed before this metric column in order. You can use the up and down arrows to re-order metric columns. The value of the column is calculated using the given compute expression.

The following table shows operators which can be used while defining compute expression.

Operator Example Explanation
+ Column1 + Column2 Returns the sum of the values of Column1 and Column2.
- (Column1 + Column2) - Column3 First add Column1 and Column2 values, then subtract Column3 value and return the result.
* (Column1*Column2) + Column3 First multiply Column1 and Column2 values, then add Column3 value and return the result.
/ (Column1 + Column2) /2 Returns the average of Column1 and Column2 values.
__ceil __ceil Column1 Returns the value of Column1 rounded off to the largest integer.
__floor __floor Column1 Returns the value of Column1 rounded off to the lowest integer.
__round __round Column1 This expression will round the value of Column1 to the nearest integer, away from zero.
== Column1 == 1 Returns true if the value of Column1 is 1, else returns false.
!= Column1 != 1 Returns false if the value of Column1 is 1, else returns true.
() ? : ; (Status == 1) ? "UP": "DOWN" This operator is equivalent to if then else statement. This expression will return "UP" if Status value is 1 otherwise it will return "DOWN"
__is_null __is_null Column1 Returns true if the value of Column1 is NULL, else returns false.
__delta __delta Column1 Returns the difference between the current value and the previous value of Column1.
__contains Column1 __contains "ORA-" Returns true if the value of Column1 contains the string "ORA-", else returns false.
__beginswith Column1 __beginswith "ORA-" Returns true if the value of Column1 starts with the string "ORA-", else returns false.
__matches Column1 __matches "UP" Returns true if the value of Column1 is equal to "UP", else returns false.
__length __length Column1 Returns the length of string value of Column1.
__to_upper __to_upper Column1 Returns the upper case of string value of Column1
__to_lower __to_lower Column1 Returns the lower case of string value of Column1.
__interval Column1 / __interval Returns the Column1 value divided by the collection interval.

Refer to the examples for details about the expression grammar and usage.

Value Definition
__interval Collect interval.
__sysdate Current system time.
__GMTdate Current GMT time.
__contains Tests a given string expression for presence of a string expression.
__beginswith Tests whether a given string expression begins with a specified string expression.
__endswith Tests whether a given string expression ends with the specified string expression.
__matches Tests whether a given string expression matches a specified string expression.
__delta Computes the difference between the current value and the previous value.
__leadingchars Returns the leading characters in the specified string.
__trailingchars Returns the trailing characters in the specified string.
__substringpos Returns the position of the occurrence of the pattern within a specified string.
__is_null Tests whether the expression is NULL
__length Returns the length of the string expression.
__to_upper Converts the string to upper case.
__to_lower Converts the string to lowercase.
__ceil Returns the smallest integral value not less than identifier.
__floor Returns the largest integral value not greater than the identifier.
__round Rounds to nearest integer, away from zero.

Examples:

  • The value of the column is the average of the columns Column1 and Column2.

    NAME="Average" COMPUTE_EXPR="(Column1 + Column2 )/ 2" 
  • The value of the column Version is computed as 7.X if column Column1 contains the String NetApp Release 7..

    NAME="Version" COMPUTE_EXPR="(Column1 __contains 'NetApp Release 7.') ? '7.X':'6.X'"
  • The value of the column Column1 is the difference of the columns Column2 and Column3.

    NAME="Column1" COMPUTE_EXPR="(Column2 - Column3)"
  • The value of the column Status is 1 if the value of column State matches the String STARTED and 0 otherwise.

    NAME="Status" COMPUTE_EXPR="State __matches 'STARTED'" 
  • The value of the column Column1 is yes if the value of column Column2 is null and no otherwise.

    NAME="Column1" COMPUTE_EXPR="(__is_null Column2)?'yes':'no'" 
  • The value of the column Source is lanplus if the length of string value of column result is 0; el e it is the value of the column result.

    NAME="Source" COMPUTE_EXPR="((__length result) == 0) ? 'lanplus' : result" 
  • The value of the column Rate is the value of column Column1 divided by the collection interval, rounded up to the largest integer.

    NAME="Rate" COMPUTE_EXPR="(__ceil (Column1/__interval))"
  • The value of the column is the Column1 when Column2 and Column3 are existing metric columns.

    NAME="Column1" COMPUTE_EXPR="((Column2 == 0) ? 0 : ((Column3 / (Column2 / 8)) * 100.0))"
  • The value of the column is the total percentage of disk available where Column1 and Column2 are existing metric columns

    NAME="PERCENTAGE_VALUE" COMPUTE_EXPR="(Column1 != 0) ? 100.0*(Column2/Column1) : 0"