that is not logical

neg1.png

I love that an if statement works inside an array and the first two elements of an array can be added together.
coding1.png

=0 is false
<>0 is true

Right but when you build a probe based on array find, array find returns -1 when it doesn’t find anything, resulting in a true when you expect false…
Here is the syntax for array_find.
returns array index from element that match criteria or -1. First parameter - array, second - item to search for
So you have to be careful when using if and array find together. I think the intention was for -1 to be false??
arrayfind.png
Also when building a probe using -1 as false will cause the probe to not function correctly.

ups1.png
[oid(“1.3.6.1.4.1.318.1.1.1.1.1.1.0”)]
[if(oid(“1.3.6.1.4.1.318.1.1.1.1.1.1.0”)<>0, “True”,“False”)]
[if(oid(“1.3.6.1.4.1.318.1.1.1.1.1.1.0”)=0, “True”,“False”)]
[if(oid(“1.3.6.1.4.1.318.1.1.1.1.1.1.0”)<>“”, “True”,“False”)]
[if(oid(“1.3.6.1.4.1.318.1.1.1.1.1.1.0”)=“Smart-UPS 1500”,“True”,“False”)]

Why would ‘if oid <> “”’ be false, it is obviously not an empty string. I tried oid_raw as well. I am working on a new probe to determine the basic state of APC ups. The first thing I want to do is determine if the device is an APC device. So here is a solution…

[if(string_size(oid(“1.3.6.1.4.1.318.1.1.1.1.1.1.0”))<>0, “True”,“False”)]

So it seems if an oid is type octet string can’t be compared to interger or an empty string, where I would have thought if you have a string and it is being compared to an empty string or an integer the “value” would get compared but it seems like it doesn’t.

I wonder if “if” could adopt the type sent to it dynamically? At least these things are not very hard to work around.