SOLVED: Session Relevance: Extracting action results from multiple computers in an efficient way

Hello everyone!

I’ve created a patch site to which all ‘new’ machines do subscribe in order to install the needed patches.
I wanted to display in an easy to understand way the advancement of the installation of the (many) patches.
The following relevance do work, but it is very inefficient, because it has to fetch the action results 4 times instead of just once as it would be ideal. (see @jgstew post here about how writing relevance DOES matter).

To make a long story short, the following relevance does list:

  • the names of the computers subscribed to the patching site

  • the relay from wich the computers will download the patches (its relay)

  • the number of actions each computer has executed

  • the total number of actions it will have to execute

  • the downloaded (prefetch-ed) size (again, thanks to @jgstew for this code!, you can find it here) of relevant actions

  • the total prefetch size of relevant actions.

    (
    name of it,
    (it as uppercase) of (preceding text of first “:” of it|it) of (preceding text of first “.” of it|it) of relay server of it,
    number of it whose (status of it = bes action status fixed) of results (bes actions whose (name of issuer of it =“patch_robot”),it),
    number of results (bes actions whose (name of issuer of it =“patch_robot”),it),
    sum of (((parenthesized parts of matches (regex " size:= ") of it) as integer) of action scripts of actions of (results (bes actions whose (name of issuer of it =“patch_robot”),it)) whose (status of it != bes action status pending downloads)) / 1048576,
    sum of ((parenthesized parts of matches (regex " size:= ") of it) as integer) of action scripts of actions of results (bes actions whose (name of issuer of it =“patch_robot”),it) / 1048576
    ) of subscribed computers of action site of bes user whose (name of it = “patch_robot”)
    the result looks like this:

    computer name - Relay Name - Installed/Total - DownloadedMB/TotalMB
    ( Computer1000 ), ( Relay001 ), ( 50 ), ( 54 ), ( 676 ), ( 1702 )
    ( Computer1001 ), ( Relay001 ), ( 19 ), ( 22 ), ( 143 ), ( 417 )
    ( Computer1002 ), ( Relay002 ), ( 13 ), ( 50 ), ( 1121 ), ( 1451 )
    ( Computer1003 ), ( Relay001 ), ( 1 ), ( 19 ), ( 415 ), ( 415 )

I’ve tried to move the results in the outer part of the cycle…

(
 name of computer of it,

 (it as uppercase) of (preceding text of first ":" of it|it) 
   of (preceding text of first "." of it|it) 
    of relay server of computer of it,

  number of it whose (status of it = bes action status fixed) of it,

  number of it,

  sum of (((parenthesized parts of matches (regex " size[:=](\d+) ") of it) as integer) 
   of action scripts of actions of it 
    whose (status of it != bes action status pending downloads)) / 1048576,

 sum of ((parenthesized parts of matches (regex " size[:=](\d+) ") of it) as integer) 
  of action scripts of actions of it / 1048576

) of results (
   bes actions whose (name of issuer of it ="patch_robot"),
   subscribed computers of action site of bes user whose (name of it = "patch_robot")
)

but doing so (of course) multiplies the number of rows by a factor of (number of computers*number of results)
I’m surely missing something … please help a young relevance-r :slight_smile:

Sorry for the bump… I’m really banging my head at it… I feel I’m getting closer, by correctly iterating separately for the computers vs the results (simplified relevance, just to show the concept):

(
 name of it,
 (it as uppercase) of (preceding text of first ":" of it|it) of (preceding text of first "." of it|it) of relay server of it,
(
  number of it whose (status of it = bes action status fixed) of it,
  number of it,
  sum of ((parenthesized parts of matches (regex " size[:=](\d+) ") of it) as integer) of action scripts of actions of it
 ) of results (bes actions whose (name of issuer of it ="patch_robot"),it) 
) of subscribed computers of action site of bes user whose (name of it = "patch_robot")

…but, I’m getting this kind of results:

(Computer001),(Relay01),(BigFix_Session_Relevance_Tester.WebReports80Service.ResultList)
(Computer001),(Relay01),(BigFix_Session_Relevance_Tester.WebReports80Service.ResultList)
(Computer001),(Relay01),(BigFix_Session_Relevance_Tester.WebReports80Service.ResultList)
(Computer002),(Relay01),(BigFix_Session_Relevance_Tester.WebReports80Service.ResultList)
(Computer002),(Relay01),(BigFix_Session_Relevance_Tester.WebReports80Service.ResultList)
(Computer002),(Relay01),(BigFix_Session_Relevance_Tester.WebReports80Service.ResultList)

…I.E. I still get (Computers * Results) rows, this time tho because it seems to me that I’m being unable to ‘aggregate’ the 3 integer tuple result… any idea?
Many thanks!

I solved my problem… I’ll post the solution, hoping to help someone else :slight_smile:
The ‘trick’ here is to remember to keep objects as singular as possible until needed (to avoid a geometric explosion of data).
In this specific scenario, the key was to use a “SET OF ACTIONS” to avoid the “computers x actions” issue.

Long story short:

 (
  name of item 0 of it,
   
  (preceding text of first "." of it|it) of preceding text of first ":" of relay server of item 0 of it as uppercase,

  number of (results (item 0 of it,elements of item 1 of it) whose (status of it != bes action status fixed)),

  number of  results (item 0 of it,elements of item 1 of it),

  (it / 1048576) of sum of ((parenthesized parts of matches (regex " size[:=](\d+) ") of it) as integer) 
    of action scripts of actions of (results (item 0 of it,elements of item 1 of it) whose (status of it != bes action status pending downloads)),

  (it / 1048576) of sum of ((parenthesized parts of matches (regex " size[:=](\d+) ") of it) as integer) 
    of action scripts of actions of results (item 0 of it,elements of item 1 of it)
)
of
(
 subscribed computers of it,
 set of actions of it
) 
 of action site of bes user whose (name of  it ="patch_robot")

not only does it works, but it is blazingly fast :smile:

2 Likes

This is exactly right. You want to create just 1 tuple if possible from the sets rather than computer * action number of tuples because constructing the tuples takes time, and then it becomes hard to collapse it back down into a sensible result.

Glad you figured it out.

I actually forgot about this: https://bigfix.me/relevance/details/2999273

I wish searching google for things on BigFix.Me or searching BigFix.Me was a lot better. It is surprising how often I go looking for my own work.

@jgstew - as for googling bigfix.me, have you tried limiting your search scope with google like so:

site:bigfix.me set download size property

That actually returns your link within the first few results.

1 Like

Yes, I do google with site:bigfix.me when looking for content on there, but then I have to remember what keywords to search for to bring up what I am looking for, which can be the more significant challenge as the number of items on BigFix.Me grows.

I don’t think it applies to your specific use case, but I just wrote this that also involves optimizing relevance: Use `unique values` to collapse duplicate results to make expensive queries more efficient