Running into a problem when trying to create sets

Hello all,

I am trying to create a custom report to determine which AD Sites have ‘gone dark’, meaning the vast majority of endpoints at any given AD site have not reported in 1 day+.

Right now, my approach to this problem is creating 2 sets of data which contain 2 items. Item 1 being unique values of AD sites and Item 2 being the multiplicity for the AD site (meaning the number of endpoints).

The pseudo code I am attempting to apply to this is as follows:

if (AD site from set 2 exists in set 1) then
if (Number of ‘Offline Endpoints’ / Number of ‘Total endpoints’ >= 90% then
value of AD Site + "has gone dark"
elseif (Number of ‘Offline Endpoints’ / Number of ‘Total endpoints’ >= #% then
value of AD Site + "is potentially a problem"
else
nothing

Data Group 1 - Number of Offline Endpoints per AD Site value: AD sites and the number of machines at each site that have not reported in 1 day or more. This is accomplished with the following:

(multiplicity of it, it) of unique values of values of results from (bes property "AD Site") of bes computers whose (now - last report time of it >= 1*day) 

Data Group 2 - Total Number of Endpoints per AD Site value: A list of all AD sites and the number of endpoints at each location.

(multiplicity of it, it) of unique values of values of results from (bes property "AD Site") of bes computers 

Now this is where I’m getting stuck. The stand alone groups work as expected. However, when I try to plug this information into sets so I can do the math, the fact I have more than 1 item being returned seems to be giving me fits.Examples below.

Singling out return values works:

elements of (set of (it) of unique values of values of results from (bes property "AD Site") of bes computers)

and

elements of (set of (multiplicity of it) of unique values of values of results from (bes property "AD Site") of bes computers)

However, combining return values does not. The following errors out with operator “set” is not defined when trying to execute.

elements of (set of (multiplicity of it, it) of unique values of values of results from (bes property "AD Site") of bes computers)

Any help would be greatly appreciated.

1 Like

Okay, well… I incorporated javascript into the mix and was able to accomplish the end goal of my report. However, I am finding that in my environment the report is taking about 10-15 minutes to return the results.

Below is my code block for the report:

<script type="text/javascript">

//A session relevance query that incorporates JS to make an array of all AD sites with 1 or more endpoints not reporting for a day.
<?relevance javascript array "allADSites" of it of unique values of values of results from (bes property "AD Site") of bes computers whose (now - last report time of it >= 1*day) ?>

//Start of loop for all items in the array
for (var i in allADSites) {

//Line 1 of the following creates the actual relevance statement
//Line 2 runs the query and stores the percentage of dark endpoints
var adSiteMath = '(multiplicity of it of unique values whose (it = "' + allADSites[i] + '") of values of results from (bes property "AD Site") of bes computers whose (now - last report time of it >= 1*day) as floating point)/(multiplicity of it of unique values whose (it = "' + allADSites[i] +'") of values of results from (bes property "AD Site") of bes computers as floating point)*100';
var darkPCT = Relevance(adSiteMath);

//checks if percent returned above exceeds the 90% or 70% thresholds and acts accordingly. Otherwise no output is provided. 
   if ( darkPCT > 90) {
      document.write(allADSites[i] + " :: has gone dark. <br/>")
   }else if ( darkPCT > 70) {
      document.write(allADSites[i] + " :: is potentially a problem. <br/>")
   };
 };
</script>

The problem with this script seems to be the sheer number of AD sites its having to loop through. The array that gets created at the top of the script is around 1000 items, a little under 1/3 of the total AD sites in my environment.

Is there a more efficient way to pull the data with javascript?

I don’t have an AD Site property in my environment but I did this in session relevance to calculate a % using OS property.

((item 0 of item 0 of it / item 0 of item 1 of it)*100, item 1 of item 0 of it)
of
(it whose (item 1 of item 0 of it = item 1 of item 1 of it) 
of
((multiplicity of it, it) of unique values of (item 1 of it) 
  of 
  it whose (value of results (item 0 of it,bes property("OS")) = item 1 of it)
  of
 (bes computers whose (day <= now - it of last report time of it), unique values of values of results of bes property ("OS")),
 (multiplicity of it, it) of unique values of(item 1 of it) 
  of
  it whose (value of results (item 0 of it,bes property("OS")) = item 1 of it)
  of
 (bes computers, unique values of values of results of bes property ("OS"))))

Yes.

I’m not exactly sure of the best method, but my guess is you should be calculating the total number of endpoints per AD site separately. The 2nd relevance call is probably expensive.


I just tested this, and it is very slow. It hasn’t actually returned a result after a few minutes. Probably doesn’t scale well to a large number of endpoints.

This should be more efficient:

(multiplicity of it, it) of unique values of values of results of bes properties "AD Site"

This is part way:

(item 0 of it, multiplicity of item 0 of it, multiplicity of item 1 of it) of ( unique values of values of results from (bes property "AD Site") of bes computers whose (now - last report time of it >= 3*day) , unique values of values of results of bes properties "AD Site" ) whose(item 0 of it = item 1 of it)

This seems to be exactly what you want:

(item 0 of it, (100 as floating point) * item 1 of it / item 2 of it) whose(item 1 of it > 70) of (item 0 of it, multiplicity of item 0 of it, multiplicity of item 1 of it) of ( unique values of values of results from (bes property "AD Site") of bes computers whose (now - last report time of it >= 3*day) , unique values of values of results of bes properties "AD Site" ) whose(item 0 of it = item 1 of it)

Thank you very much for the responses.

@jgstew - I have been asked to steer clear of testing new stuff in production for a bit. I will test your code and let you know the results when I’m given the green light again.

Was there an issue?

You should test it in “not” production then. If you don’t have a non production environment you can use yourself, then set up an Eval Server in a VM to play with.

Assuming WebReports is not running on the root server, which it shouldn’t be, then unless there was an issue with Web Reports itself, I don’t think anything you do in WebReports generally affects the root server, which is usually what I worry about when it comes to testing in production is what impact will I have on the root server.

Also, Generating a WebReport only affects anything when it is actually being accessed, or when it is running on a schedule.

1 Like