SNMP Operators with examples
SNMP Operator | Applicable Type | Syntax | Return Type | Example | Example Result | Description |
---|---|---|---|---|---|---|
"=" or "==" | Number | a=b or a==b | Boolean | 3=4 or 3==4 | FALSE | To check the equality of two operands, return true if the two values are the same; otherwise, return false. |
"!=" or "<>" | Number | a!=b or a<>b | Boolean | 3!=4 or 3 <> 4 | TRUE | To check the not equal condition between two operands, return true if both values are not equal; otherwise, return false. |
">" | Number | a > b | Boolean | 3 > 4 | FALSE | To check the greater than condition between two operands, return true if the left-side value is greater than the right-side value; otherwise, return false. |
"<" | Number | a < b | Boolean | 3 < 4 | TRUE | To check the less than condition between two operands, return true if the left-side values is less than right side value; otherwise, return false. |
">=" | Number | a>=b | Boolean | 3>=4 | FALSE | To check the greater than or equal condition between two operands, return true if the left-side value is greater than or equal to the right-side value; otherwise, return false. |
"<=" | Number | a<=b | Boolean | 3<=4 | TRUE | To check the less than or equal condition between two operands, return true if the left-side value is less than or equal to the right-side value; otherwise, return false. |
"+" | Number | a+b | Number | 3+4 | 7 | It will return the result after adding the two operands. |
"-" | Number | a-b | Number | 4-3 | 1 | It will return the result after subtracting the right side value from the left-side value. |
"*" | Number | a*b | Number | 3*4 | 12 | It will return the result after multiplying the two operands. |
"/" | Number | a/b | Number | 3/4 | 0 | Divides the first operand by the second and returns the result. |
"%" | Number | a%b | Number | 4%3 | 1 | Returns the remainder when the first operand is divided by the second. |
">>" | Number | a>>b | Number | 100>>2 | 20 | The right shift operator (>>) shifts the bits of the right operand to the right by the number of times specified by the right operand. |
"<<" | Number | a << b | Number | 100 << 2 | 400 | The left shift operator (<<) shifts the bits of the left operand to the left by the number of times specified by the left operand. |
"^" | Number | a^b | Boolean | 2^4 | 16 | The bitwise XOR (^) operator performs a binary XOR operation bit by bit on the operands. |
"||" | Number | a || b | Boolean | 1 || 0 | TRUE | The symbol || denotes the OR operator. This operator will only return false when both conditions are false. |
"&&" | Number | a && b | Boolean | 1 && 0 | FALSE | The symbol && denotes the AND operator. It evaluates two statements/conditions and returns true only when both statements/conditions are true. |
eq | String | a eq b | Boolean | 'abc' eq 'xyz' | FALSE | Equality checking of two strings, return true if both Strings are the same. |
ne | String | a ne b | Boolean | 'abc' ne 'xyz' | TRUE | Inequality checking of two strings, return false if both Strings are the same. |
"=~" | String | a' =~ 'b' | Boolean | 'abcd' =~ 'abc' | TRUE | If the left-side String value contains the right-side String value, it will return true. |
"!~" | String | a' !~ 'a' | Boolean | 'abcd' !~ 'abc' | FALSE | If the left-side String value does not contain the right side String value, it will return true. |
SNMP Functions with examples
SNMP Function | Type | Syntax | Return Type | Example | Example Result | Description |
---|---|---|---|---|---|---|
IF | Number | if(a==b,c,d) | Number | IF(3 == 4,-5,6) | 6 | For the IF function, the first parameter is the condition. If the condition is true, the second parameter is returned as the result. Otherwise, the third parameter is returned as the result. |
NOT | Number | NOT(a>b) | Boolean | NOT(3>4) | TRUE | For the NOT function, the parameter is a condition. It returns true if the condition is false; otherwise, it returns false. |
SIN | Number | SIN(a) | Number | SIN(45) | 0.7071067812 | Returns the closest double approximation of the sine of the argument. Note: return value of Math.sin() |
COS | Number | COS(a) | Number | COS(45) | 0.7071067812 | Returns the closest double approximation of the cosine of the argument. Note: return value of Math.cos() |
TAN | Number | TAN(a) | Number | TAN(45) | 1 | Returns the closest double approximation of the tangent of the argument. Note: return value of Math.tan() |
SINH | Number | SINH(a) | Number | SINH(45) | 17467135528742547000 | Returns the closest double approximation of the hyperbolic sine of the argument. Note: return value of Math.sinh() |
COSH | Number | COSH(a) | Number | COSH(45) | 17467135528742547000 | Returns the closest double approximation of the hyperbolic cosine of the argument. Note: return value of Math.cosh() |
TANH | Number | TANH(a) | Number | TANH(45) | 1 | Returns the closest double approximation of the hyperbolic tangent of the argument. The absolute value is always less than 1. Note: return value of Math.tanh() |
MAX | Number | MAX(q,b,c,d) | Number | MAX(1,25,9,10) | 25 | Returns the biggest of given sets of long values. Note: Uses the Math.max() |
MIN | Number | MIN(a,b) | Number | MIN(2,1) | 1 | Returns the smaller of two long values. Note: return value of Math.min() |
ABS | Number | ABS(-a) | Number | ABS(-10) | 10 | Returns the absolute value of a long value. Note: return value of Math.abs() |
LOG | Number | LOG(a) | Number | LOG(2) | 0.6931471806 | Returns the natural logarithm (base e) of a double value. Note: return value of Math.log() |
ROUND | Number | ROUND(a,b) | Number | ROUND(2.8899999,2) | 2.89 | Returns the closest int to the argument. Note: return value of Math.round() |
SQRT | Number | SQRT(a) | Number | SQRT(16) | 4 | Returns the correctly rounded positive square root of a double value. Note: return value of Math.sqrt() |
MATCHER | String | MATCHER('text to be searched','pattern') | String | MATCHER(ibCPUTemperature, '(\\+|\\-){0,1}(\\d+\\.*\\d*)') Note: Using java regular expression Pattern.compile("regular expression"); pattern.matcher("String to be searched"); | school | Used to search for the pattern. If found then return matched string. If not found then return the null. |
PARSER | String | PARSER('text to be searched','text to return if match found','regular expression') | String | PARSER(sysVolumeTotalSize,'{0}','(\\d+(\\.\\d+)*)') | w3 | If matching found for given pattern then return second parameter format as a result. Otherwise return null. |
ELAPSE_TIME_FOR_DATEANDTIME | Number | ELAPSE_TIME_FOR_DATEANDTIME('DATE TIME') | Number | Example 1: ELAPSE_TIME_FOR_DATEANDTIME('2023-06-02 12:49:31:0893 UTC') Example2: LAPSE_TIME_FOR_DATEANDTIME( f10ChassisBootupTime ) | 348 | This function will calculate the time difference between given date and time after converting to UTC with current UTC date and time and return result in seconds. Note: Must give the date time in the below format: "yyyy-MM-dd HH:mm:ss:SSSS z" |
ISDEF | Boolean | ISDEF(value) | Boolean | if(isDef(cempMemPoolHCUsed),cempMemPoolHCUsed,cempMemPoolUsed) Note: Here used ISDEF() under IF() | FALSE | ISDEF(value) will return true if given input is not equal to null. Otherwise will return false. |