Forum Discussion

ianf's avatar
2 years ago

Add device to a Collector Group

Hi Guys

Is it possible to add a device to a Collector Group directly?

I've been testing code to find a set of collectors that match a name and add to one of the specific collectors retrieved. Currently it grabs all with LON in the name and matches the device name.  I'm then randomly picking one of them and adding the device). However, my understanding is its then tied to this collector and not the grrup?

PLease correct me if I'm wrong here.

So, can I add directly to a group with JSON as below 

 $newdeviceobj= @{ 
                    'name' = "$device" - name of the device
                    'displayName' = "$device" - name of the device
                    'preferredCollectorId' = "0"
                    "autoBalancedCollectorGroupId" = $id - (this is the ID of the collector group)
                    'description' = "$device" - name of the device
                    }

I'm using a POST to device/devices and i receive

 @{data=; errmsg=Collector(id=0) does not exist; status=1404}

I've got 'preferredCollectorId' = "0" as clearly i dont want to define it at this point.

 

Thanks

 

3 Replies

  • Devices cannot be added to Collector groups, only collectors can. Devices (including the device the collector is hosted on) can be added to resource/device groups.

    When I add a device through the API, i find the collector group and just assign the preferredCollectorId to the first collector in that group. I don't define any collectors on resource groups.

    This might be of interest: https://github.com/sweenig/lm/tree/main/LMAutomation/Devices_by_Collector_Auto_Groups

  • Pretty much. By setting the preferred collector id, you're telling LM which collector the device is assigned to. The collector being a member of an ABCG will mean that overload will be rebalanced.

    Also, don't confuse ABCGs with load balancing. It's not load balancing. It's overload rebalancing. In an ABCG, one collector could be 99% loaded and the other could be 3% loaded and this is normal/expected behavior. It's only when the load goes above 100% that rebalancing happens, and only enough to get it down below 100%. Definition of load is a specific number of instances. Not actually based on real performance stats.