Community discussions

 
lebowski
Forum Guru
Forum Guru
Topic Author
Posts: 1616
Joined: Wed Aug 27, 2008 5:17 pm

that is not logical

Tue Nov 01, 2011 3:32 pm

neg1.png
You do not have the required permissions to view the files attached to this post.
 
lebowski
Forum Guru
Forum Guru
Topic Author
Posts: 1616
Joined: Wed Aug 27, 2008 5:17 pm

More crazy coding

Tue Nov 01, 2011 6:27 pm

I love that an if statement works inside an array and the first two elements of an array can be added together.
coding1.png
You do not have the required permissions to view the files attached to this post.
 
rodolfo
Long time Member
Long time Member
Posts: 543
Joined: Sat Jul 05, 2008 11:50 am

Re: that is not logical

Tue Nov 01, 2011 6:44 pm

=0 is false
<>0 is true
rodolfo
IZ0UQV
 
lebowski
Forum Guru
Forum Guru
Topic Author
Posts: 1616
Joined: Wed Aug 27, 2008 5:17 pm

Re: that is not logical

Tue Nov 01, 2011 7:29 pm

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.
You do not have the required permissions to view the files attached to this post.
Last edited by lebowski on Wed Nov 02, 2011 5:11 pm, edited 1 time in total.
 
lebowski
Forum Guru
Forum Guru
Topic Author
Posts: 1616
Joined: Wed Aug 27, 2008 5:17 pm

Re: that is not logical

Wed Nov 02, 2011 5:07 pm

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.
You do not have the required permissions to view the files attached to this post.

Who is online

Users browsing this forum: No registered users and 9 guests