ACC - Distributing Monitoring of CIs by Proxy Policy between several AgentsIn all Agent Client Collector Framework versions (as of the time of writing this article, the current version is 2.8.2), policies which monitor CMDB CIs with proxy agents are distributing the monitoring of all CIs between all agents.This means that all CIs that are selected to be monitored by the proxy policy will be monitored by all selected proxy agents. As an example, let P be a proxy policy, C1 and C2 be the CMDB CIs monitored by it, A1 and A2 be the proxy agents selected in the policy and Ch1 and Ch2 be the checks executed as part of the policy. The current implementation will lead to a situation where A1 and A2 each will execute 4 checks each as part of P: Ch1 for C1 and C2 and Ch2 for C1 and C2. This behavior was implemented by design, but sometimes, it is expected that the monitoring of the CIs will be distributed evenly across the proxy agents. Until this behavior will be implemented in a future release of ACC-F, the following procedure can be applied: Import the attached XML file (ProxyPolicyDistributer.xml) to your ServiceNow instance. It includes a Script Include called ProxyPolicyDistributer which is in the sn_agent scope (ACC-F scope) and is accessible from all application scopes. The ProxyPolicyDistributer API in the Script Include can be used as follows to distribute the monitoring of CIs between proxy agents: LetC = {C1, ..., Cn} be a list of n CIs (records in the cmdb_ci table or any extending tables) which all have a name which is prefixed with "acc_"A = {A1, ..., Am} be a list of m agents (records in the sn_agent_cmdb_ci_agent table) which all have a name which is prefixed with "Agent_acc_"S = {S1, ..., Sk} be a list of k check definitions (more precisely their sys_ids in the sn_agent_check_def table). The sn_agent.ProxyPolicyDistributer. create method accepts 5 parameters in the following order: namePrefix - a string value which will serve as the prefix of the names of all policies which will be createdciTable - a string value which is the name of the CIs table you wish the policies to monitorciEncQuery - a string value which should be an encoded query on the above table to produce the set of CIs you wish your policies to monitorcheckDefs - an array of string values which should contain the sys_ids of check definitions you wish to be executed in order to monitor the selected CIsagentsEncQuery - a string value which should be an encoded query on the agents table (sn_agent_cmdb_ci_agent) which should produce the set of agents you want your generated policies to be executed by Using the values mentioned above, If you want the A group of Agents to monitor the C group of CIs by running the S group of checks, you should run the following line in scripts background after importing the Script Include XML: sn_agent.ProxyPolicyDistributer.create("policy_acc_", "cmdb_ci", "nameSTARTSWITHacc_", [S1, ..., Sk], "nameSTARTSWITHAgent_acc"); This call will return a list of policy sys_ids.All of those new policies are draft policies which have the "policy_acc" name prefix.They are created in draft mode so you can review them before you truly decide to publish them.All policies are created and are defined to run the group S of checks, but the above method tries to distribute the given group C of CIs evenly across the given agents group A.Each created policy monitors a subset of CIs from C using a single agent from A (roughly n/m CIs will be monitored by each agent). The create method returns an array of sys_ids of the draft policies created, so the return value can be used in any desired way by the customer. There's also another method in the ProxyPolicyDistributer API, which is the publish method, which can accept the list of policies returned by the create method and publish them: var draftPoliciesArr = sn_agent.ProxyPolicyDistributer.create("policy_acc_", "cmdb_ci", ""nameSTARTSWITHacc_", [S1, ..., Sk], "nameSTARTSWITHAgent_acc"); sn_agent. ProxyPolicyDistributer. publish(draftPoliciesArr); Alternatively, you may print the returned array and/or store the returned sys_ids for later use after reviewing the created draft policies.you can also use the name prefix you passed to construct this array later. If we use the above example after running the create method, the returned draft policies sys_ids array can be reconstructed by running the below script: var draftPoliciesArr = []; var gr = new GlideRecord("sn_agent_policy"); gr.addEncodedQuery("nameSTARTSWITHpolicy_acc_"); gr.query(); while (gr.next()) draftPoliciesArr.push(gr.getUniqueValue()); and then the publish method can be called to publish them: sn_agent.ProxyPolicyDistributer.publish(draftPoliciesArr);