Ip address exists relevance syntax

(imported topic written by djorlett91)

I’ve done several searches for this and have not found a related one, so either this means that the solution very obvious, or I missed the post where this question was already asked. So I apologize for the redundancy that may or may not be there.

That said

My relevance query is data driven based on a couple of other more simple queries that gets me to a list of hosts that are contained in a group or set. I am looking for a result set related to a property on a host such that my query looks like this:

(name of it, ip address of it, values of results(it, bes property \
"netstat output\")) of bes computers whose (name of it = \"{0}\")

where the {0} is subbed out in the iterative loop on the aforementioned set or group. My problem is when I get a host who does not report their ip for whatever reason the query comes back with:

“Error: Singular expression refers to non-unique object”

Which I am interpreting to mean the ip is not there. Low and behold when I go and poke around in the database and on the host in general it is not there in my sample set because that host is hording its ip, cheeky thing that it is.

I thought using the exists keyword might get me there, something like

(name of it, (

if (exists ip address of it) then ip address of it 

else 
""), ...<the rest of the query>

but it does not match the ip4 return type off the request “ip address” which returns an ip4 object. so I am a bit stumped as to next steps.

any help on this would be greatly appreciated

-d

(imported comment written by Lee Wei)

Nice job, and you are very close.

(if (exists ip address of it) then ip address of it else "")

can be,

(if (exists ip address of it) then (ip addresses of it as string) else (""))

If there are 3 IP addresses, you are going to get 3 lines. To return only one line per computer, can you concatenate the IP addresses together.

(if (exists ip address of it) then (concatenation "; " of (ip addresses of it as string)) else (""))

Lee Wei

(imported comment written by djorlett91)

Right on, that makes sense. I was thinking that the as string would get in there somehow but it was getting away from me.

Thanks for the quick response

-D

(imported comment written by djorlett91)

is there a way to incorporate something like this into my results.

addresses of adapters whose (cidr string of it = wake on lan subnet cidr string) of network

I pulled this from another topic trying to get the primary IP off of a machine. one of the machines in my test environment is also a vm server and its returning 3 address. I know visually which of the three is the machine, however progromatically is there a method to determine the primary ip?