Broken session relevance

(imported topic written by cstoneba)

For months, I had a report that worked that showed me OS counts within our environment. Today I looked at the report and it just shows “0” as the counts for each OS. The report wasn’t modified, so I’m confused as to what broke.

<?Relevance tr of ( td of (number of bes computers whose( exist (value of result(bes property "OS",it)) whose (it contains "WinNT")) as string) & td of (number of bes computers whose( exist (value of result(bes property "OS",it)) whose (it contains "2000")) as string) & td of (number of bes computers whose( exist (value of result(bes property "OS",it)) whose (it contains "WinXP")) as string) & td of (number of bes computers whose( exist (value of result(bes property "OS",it)) whose (it contains "2003")) as string) & td of (number of bes computers whose( exist (value of result(bes property "OS",it)) whose (it contains "Vista")) as string) & td of (number of bes computers whose( exist (value of result(bes property "OS",it)) whose (it contains "2008")) as string) & td of (number of bes computers whose( exist (value of result(bes property "OS",it)) whose (it contains "Win7")) as string) & td of (number of bes computers whose( exist (value of result(bes property "OS",it)) whose (it contains "AIX")) as string) & td of (number of bes computers whose( exist (value of result(bes property "OS",it)) whose (it contains "SunOS")) as string) & td of (number of bes computers whose( exist (value of result(bes property "OS",it)) whose (it contains "SuSE")) as string) & td of (number of bes computers whose( exist (value of result(bes property "OS",it)) whose (it contains "Red Hat")) as string) & td of (number of bes computers as string)) ?>

(imported comment written by BenKus)

Maybe corrupted web reports cache?

Ben

(imported comment written by cstoneba)

the session relevance also fails within the Console Presentation Debugger, so that would make me think that it isn’t a webreports cache issue. For somereason, “bigfix” no longer likes the code.

(imported comment written by SystemAdmin)

cstoneba - I ran the relevance (minues the web reports formatting commands) through the Session Relevance Tester and it spit out the correct results. So it looks like something to do with the web reports wrapper commands. Perhaps this is what you were referring to already, either way, I hope my results help you figure it out.

(imported comment written by cstoneba)

mine has results, but they are all “0” (except for the last entry with is total number of computers). jspanitz, what was the relevance you tested (without the reports formatting commands) ?

(imported comment written by SystemAdmin)

Relevance:

(number of bes computers whose( exist (value of result(bes property “OS”,it)) whose (it contains “WinNT”)) as string) &

(number of bes computers whose( exist (value of result(bes property “OS”,it)) whose (it contains “2000”)) as string) &

(number of bes computers whose( exist (value of result(bes property “OS”,it)) whose (it contains “WinXP”)) as string) &

(number of bes computers whose( exist (value of result(bes property “OS”,it)) whose (it contains “2003”)) as string) &

(number of bes computers whose( exist (value of result(bes property “OS”,it)) whose (it contains “Vista”)) as string) &

(number of bes computers whose( exist (value of result(bes property “OS”,it)) whose (it contains “2008”)) as string) &

(number of bes computers whose( exist (value of result(bes property “OS”,it)) whose (it contains “Win7”)) as string) &

(number of bes computers whose( exist (value of result(bes property “OS”,it)) whose (it contains “AIX”)) as string) &

(number of bes computers whose( exist (value of result(bes property “OS”,it)) whose (it contains “SunOS”)) as string) &

(number of bes computers whose( exist (value of result(bes property “OS”,it)) whose (it contains “SuSE”)) as string) &

(number of bes computers whose( exist (value of result(bes property “OS”,it)) whose (it contains “Red Hat”)) as string) &

(number of bes computers as string)

Result:

0025533114900001317

FWIW - We are on BES version 8

(imported comment written by cstoneba)

we are on 7.2, and here are my results. As you can see, something is not right.

000000000006964

(imported comment written by cstoneba)

echo

(imported comment written by BenKus)

I bet you have two properties named “OS”? You should either remove one or change the exerpt:

bes property “OS” --> operating system

Ben

(imported comment written by cstoneba)

yup, one is for for site ‘reserved’, the other is in the site ‘patches for aix’. Which one is better to remove?

(imported comment written by cstoneba)

I resolved the issue by replacing “( exist (value of result(bes property “OS”,it)) whose (it contains “xxx”))” with "(operating system of it as lowercase contains “xxx”). I just don’t understand why it broke.

(imported comment written by BenKus)

Glad it is fixed…

The inspector ‘bes property “”’ will pick the first property that it finds with the name… If you have multiple properties with the same name, the behavior is not defined… Due to this reason, you shouldn’t generally use this form (bes property “”) unless you know you only have one property with this name and instead use something like (bes property whose (id of it = )) or something like that…

Ben

(imported comment written by SystemAdmin)

Ben,

This is a technical issue I ran into myself a short while ago and I must admit that I wasn’t completely comfortable with the final explanation, very similar to what you stated above.

From what you’ve said, and from the description in the v7.2 session inspector document for Bes Property - “Returns the first property whose name matches the given string. Note that it is not safe to assume that there is only one property with a given name.”, I understand what you’re saying.

However, I’m not sure that the statement ‘not safe to assume’ means quite the same thing as ‘undefined behaviour’. If you refer to the first line, which states: ‘…picks the first property it finds with the name…’, then although I cannot guarantee exactly which property it might be pulling it from, this infers that it should still work. This should especially be true if both properties have working relevances that return good results (of the same type). That doesn’t seem to be the case.

It would make more sense to me (althought it doesn’t clear up the problem), to use a description closer to what you stated above and mention that it will NOT work properly if there is another with the same name. I would certainly prefer that the property throws an error in the case where there is more than one property (such as when a result is plural and you’ve specified a singular result) and I have to actively resolve the problem, rather than trying to figure out why.

The knock on affect of this error condition is that it is almost always the case (as often stated in examples and on the forum) that most people will not put in any unique ID property information, but only use the property name. But because of this potential problem, it is very easy to create a second property with the same name as one that already exists and stop a report from working. This is exactly what happened with me.

An alternative solution might be that if an error is thrown that is more explcit “Property name is not unique.”, then it will be much easier to understand what the problem is and to modify the code to explicity deal with the non-unique property. I might not even mind if the property had an optional way available to pass the ID along, such as a tuple format for it:

General -> bes property “OS”

Specific-> bes property (“OS”,“214797580-5-1”)

Otherwise, the only correct (safe) way to do it in future is to use the correct relevance every time:

bes property whose (name of it = “OS” AND id of it = “214797580-5-1”)

or

bes property “OS” whose (id of it = “214797580-5-1”)

The code really isn’t that much more, but combined with the fact you can’t copy/paste from the managed properties dialog means that we should just get used to typing in the ID’s. :wink:

-Jim

Update:

  • In the 7.1.1315 console, it doesnt even show the ID in the managed properties dialog.

  • I couldn’t get the code below to work in the console presentation debugger, even though I was able to use a relevance statement to get the ID’s (due to issue above).

  • Relevance used in v8: values of (results from (bes property “OS” whose (id of it = (2147497580, 5, 1))) of it) of bes computers

(imported comment written by BenKus)

Hey Jim,

You mentioned that the bes property inspector will not work at all if there are two properties… I don’t believe this is true (or at least this is not a known issue).

But the bottom line here is that we essentially made a mistake when we implemented a named inspector ‘bes property “”’ when it there could be multiple properties with the same name. I agree that there could be better behavior (like returning multiple results), but in the meantime, you you always use “safe” bes property methods… By ID works well or you can also do queries like this:

bes property whose (name of it = “OS” and reserved flag of it = true)

bes property whose (name of it = “BES Client Version” and name of source analysis of it = “BES Component Versions”)

Ben

(imported comment written by SystemAdmin)

Ben - I’m sure you guys have had many a discussion on this, but I’d like to suggest that in some future version, property names be required to be unique when they are created.

(imported comment written by Lee Wei)

Jim,

In a report that I have that deals a lot of BES Properties, I do use the unique IDs to retrieve the properties.

http://forum.bigfix.com/viewtopic.php?id=5082

First I find and save the property ID, then I use a query with this form:

bes property whose (item 0 of id of it = 2147497463 and item 1 of id of it = 5 and item 2 of id of it = 1)

Lee Wei

(imported comment written by SystemAdmin)

Ben,

In my case, the two properties had equivalent relevance code, but the session query refused to return any data for the property after the second one had been created. This is why it was such an issue, because it didn’t actually fail/stop working, but just returned a null result for it. A much more dangerious issue. Definitely confirmed for me on version 7.1.1.315.

Lee,

After all the good work I’ve seen you produce, I’m not surprised that you have thought ahead and used an ID to check it is exactly the right property that will be targeted. But, I think my equivalence check against the tuple is easier on the eye.

bes property whose (id of it = (2147497463,5,1))

jspanitz,

Yes, I generally agree. Or perhaps I would prefer a warning to appear to let me know I’ve created a condition that could cause problems.

The reason I don’t mind duplicates is that I use Ver or Version all the time in my analyses, so that I can always tell what data has been returned from my most recent update. In those cases, I would be happy to click on an accept button to allow the duplicate to occurr.

-Jim