SNMP Operators with examples

SNMP OperatorApplicable TypeSyntaxReturn TypeExampleExample ResultDescription
"=" or "=="Numbera=b or a==bBoolean3=4 or 3==4FALSETo check the equality of two operands, return true if the two values are the same; otherwise, return false.
"!=" or "<>"Numbera!=b or a<>bBoolean3!=4 or 3 <> 4TRUETo check the not equal condition between two operands, return true if both values are not equal; otherwise, return false.
">"Numbera > bBoolean3 > 4FALSETo 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.
"<"Numbera < bBoolean3 < 4TRUETo check the less than condition between two operands, return true if the left-side values is less than right side value; otherwise, return false.
">="Numbera>=bBoolean3>=4FALSETo 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.
"<="Numbera<=bBoolean3<=4TRUETo 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.
"+"Numbera+bNumber3+47It will return the result after adding the two operands.
"-"Numbera-bNumber4-31It will return the result after subtracting the right side value from the left-side value.
"*"Numbera*bNumber3*412It will return the result after multiplying the two operands.
"/"Numbera/bNumber3/40Divides the first operand by the second and returns the result.
"%"Numbera%bNumber4%31Returns the remainder when the first operand is divided by the second.
">>"Numbera>>bNumber100>>220The right shift operator (>>) shifts the bits of the right operand to the right by the number of times specified by the right operand.
"<<"Numbera << bNumber100 << 2400The left shift operator (<<) shifts the bits of the left operand to the left by the number of times specified by the left operand.
"^"Numbera^bBoolean2^416The bitwise XOR (^) operator performs a binary XOR operation bit by bit on the operands.
"||"Numbera || bBoolean1 || 0TRUEThe symbol || denotes the OR operator. This operator will only return false when both conditions are false.
"&&"Numbera && bBoolean1 && 0FALSEThe symbol && denotes the AND operator. It evaluates two statements/conditions and returns true only when both statements/conditions are true.
eqStringa eq bBoolean'abc' eq 'xyz'FALSEEquality checking of two strings, return true if both Strings are the same.
neStringa ne bBoolean'abc' ne 'xyz'TRUEInequality checking of two strings, return false if both Strings are the same.
"=~"Stringa' =~ 'b'Boolean'abcd' =~ 'abc'TRUEIf the left-side String value contains the right-side String value, it will return true.
"!~"Stringa' !~ 'a'Boolean'abcd' !~ 'abc'FALSEIf the left-side String value does not contain the right side String value, it will return true.

SNMP Functions with examples

SNMP FunctionTypeSyntaxReturn TypeExampleExample ResultDescription
IFNumberif(a==b,c,d)NumberIF(3 == 4,-5,6)6For 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.
NOTNumberNOT(a>b)BooleanNOT(3>4)TRUEFor the NOT function, the parameter is a condition. It returns true if the condition is false; otherwise, it returns false.
SINNumberSIN(a)NumberSIN(45)0.7071067812Returns the closest double approximation of the sine of the argument.

Note: return value of Math.sin()
COSNumberCOS(a)NumberCOS(45)0.7071067812Returns the closest double approximation of the cosine of the argument.

Note: return value of Math.cos()
TANNumberTAN(a)NumberTAN(45)1Returns the closest double approximation of the tangent of the argument.

Note: return value of Math.tan()
SINHNumberSINH(a)NumberSINH(45)17467135528742547000Returns the closest double approximation of the hyperbolic sine of the argument.

Note: return value of Math.sinh()
COSHNumberCOSH(a)NumberCOSH(45)17467135528742547000Returns the closest double approximation of the hyperbolic cosine of the argument.

Note: return value of Math.cosh()
TANHNumberTANH(a)NumberTANH(45)1Returns 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()
MAXNumberMAX(q,b,c,d)NumberMAX(1,25,9,10)25Returns the biggest of given sets of long values.

Note: Uses the Math.max()
MINNumberMIN(a,b)NumberMIN(2,1)1Returns the smaller of two long values.

Note: return value of Math.min()
ABSNumberABS(-a)NumberABS(-10)10Returns the absolute value of a long value.

Note: return value of Math.abs()
LOGNumberLOG(a)NumberLOG(2)0.6931471806Returns the natural logarithm (base e) of a double value.

Note: return value of Math.log()
ROUNDNumberROUND(a,b)NumberROUND(2.8899999,2)2.89Returns the closest int to the argument.

Note: return value of Math.round()
SQRTNumberSQRT(a)NumberSQRT(16)4Returns the correctly rounded positive square root of a double value.

Note: return value of Math.sqrt()
MATCHERStringMATCHER('text to be searched','pattern')StringMATCHER(ibCPUTemperature, '(\\+|\\-){0,1}(\\d+\\.*\\d*)')

Note: Using java regular expression Pattern.compile("regular expression"); pattern.matcher("String to be searched");
schoolUsed to search for the pattern. If found then return matched string.
If not found then return the null.
PARSERStringPARSER('text to be searched','text to return if match found','regular expression')StringPARSER(sysVolumeTotalSize,'{0}','(\\d+(\\.\\d+)*)')w3If matching found for given pattern then return second parameter format as a result. Otherwise return null.
ELAPSE_TIME_FOR_DATEANDTIMENumberELAPSE_TIME_FOR_DATEANDTIME('DATE TIME')NumberExample 1:
ELAPSE_TIME_FOR_DATEANDTIME('2023-06-02 12:49:31:0893 UTC')

Example2:
LAPSE_TIME_FOR_DATEANDTIME( f10ChassisBootupTime )
348This 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"
ISDEFBooleanISDEF(value)Booleanif(isDef(cempMemPoolHCUsed),cempMemPoolHCUsed,cempMemPoolUsed)
Note: Here used ISDEF() under IF()
FALSEISDEF(value) will return true if given input is not equal to null. Otherwise will return false.