Forum Discussion

Cole_McDonald's avatar
Icon for Professor rankProfessor
5 years ago

API params

I'm trying to get a subset of devices, but my filter isn't filtering... here's my path and query, anything obvious that I'm doing wrong here?

$resourcePath    = "/device/devices"
$queryParam      = "?size=1000&filter=CollectorId:'$($'"

$collector is previously gathered and the '$($' resolves the way I expect it to ... '12' in one case.  But it's getting every device (first 1000) rather than pre-filtering to members of a specific collector.

4 Replies

Replies have been turned off for this discussion
  • try:

    $resourcePath    = "/device/devices"
    $queryParam      = "?size=1000&filter=preferredCollectorId:`"$($`""

    I don't think CollectorId is a valid property for devices and APIv2 docs say to use double quotes with filters.

  • Ultimately, the goal is to get a count of all of the instance per device per collector group so I can sort them and have a script manually re-balance the "auto-balancing" collector groups (ABCG) in our environment.  I intend to run this either once a day or once a week, then let the normal ABCG algorithms handle the load in-between.  As it sits, all of our VM Hosts have migrated to once collector, and all of our VMs to the other in the group, leading to massive CPU and port availability problems when batchscripts are run against WMI counters.

    I have to figure out how to get those per device instance counts next.

  • Can you think of a quick and dirty way to get a count of instances per device?  That's my last step before writing the logic to perform the device redistribution across an ABCG.

  • I think my approach is going to be to walk from the instances up to build out a dataset.

    1. Instances
      1. - InstanceID
      2. - DeviceID
      3. - PrefCollectorID
    2. Collector
      1. - ID
      2. - CollectorGroupID

    So each object in my data set will contain the info to relate the instance to the Device and the Collector Group.  That will allow me to gather the # of instance / device, sort by that, then distribute to the collectors in the group in a round robin fashion.  Just have to figure out how to gather the next 1000 instances :)/emoticons/smile@2x.png 2x" title=":)" width="20">  I have that code somewhere laying around.  Nearly there.