Get computers by hostname - Relevance not working as expected

Hello, I’m trying to get the IBM::Asset::Owner from Bigfix given a list of hostnames. Right now I am just testing for one, but for all servers it returns 0 results, although I’m pretty sure the hostname exists.

values of results from ( bes properties “Computer Name” ) of bes computers whose( name of it = “some hostname here”)

Please let me know if there’s anyplace I’m going wrong here. Thanks, Seb

I’ve been working on this all day. I was able to get a list of matching hostnames, however it takes awhile. This is the query I use, is there anyway to make it faster?

query = f"values of results from ( bes properties \"IBM::Asset::Owner\" ) of bes computers whose(name of it = \"{name}\")"
This is in python.

I also want to include the hostname in the result.

Try this:

(name of it, (value of result from (bes property "IBM::Asset::Owner") of it) ) of bes computer whose (name of it = "SOMECOMPUTER")
1 Like

Closer –

I’m getting “Singular expression refers to nonexistent object.” I’m assuming we just pluralize it?

The error means one of two things:

  1. the computer doesn’t exist with that name
  2. the property with that name doesn’t exist that computer.
1 Like

Thank you for your help.

I should explain more - I’m actually querying for a list of hostnames, some of which may or may not exist.

Anyway, I tried it out with
query = "(name of it, (value of result from (bes property \"IBM::Asset::Owner\") of it) ) of bes computers whose " where after whose is a query for each of the hostnames, and it works like a charm. Thank you so much.

1 Like

In that case, you may not have been matching on the correct uppercase/lowercase for the computer name earlier.

We’d usually use something like
... of bes computers whose (name of it as lowercase = "somename" as lowercase)
That way the comparison is not case-sensitive.

1 Like

Thanks Jason, good catch.

I’m getting results now, but also an error “singular expression refers to non-unique object”

Does this mean bigfix only returns the first match? I need to return all matches even for duplicate hostnames.

Did you pluralize the relevance expression? Is it possible to have more than one value for the IBM::Asset::Owner property?

(names of it, (values of results from (bes property "IBM::Asset::Owner") of it) ) of bes computers whose (name of it as lowercase = "SOMECOMPUTER" as lowercase)

are you asking for the data one hostname at a time?

I only pluralized computer to computers.
I don’t think its possible to have more than one value for IBM::Asset::Owner.

No, I am putting many hostnames at once using ‘OR’ statements.

Just a note: it is possible to have multiple properties with the same name based on the analysis or site the property is a part of just like you could have the same value for a fixlet ID across your whole deployment if those fixlet IDs are in separate sites. For example, in my deployment there are 4 different properties called “Computer Type” because each of those property names are part of a different site or different analysis.

This works in my environment, whether the duplicated names are real or bogus:

(names of it, (values of results from (bes property "IBM::Asset::Owner") of it) ) of bes computers whose (name of it as lowercase = "somecomputer" as lowercase or name of it as lowercase = "SOMEOTHERCOMPUTER" as lowercase or name of it as lowercase = "SOMECOMPUTER" as lowercase)

Thanks! But what I meant was, if a name appears multiple times in BigFix itself (for example if there are 3 computers named “test_computer”), I want to ensure I’m getting them all.

Using plural relevance should get all the computers that have the same name. You may want to add the ID property to the output so you can determine which is which.

(ids of it, names of it, (values of results from (bes property "IBM::Asset::Owner") of it) ) of bes computers whose (name of it as lowercase = "somecomputer" as lowercase or name of it as lowercase = "SOMEOTHERCOMPUTER" as lowercase or name of it as lowercase = "SOMECOMPUTER" as lowercase)
1 Like