(→AHPSCRIPTS-100)
|
(→AHPSCRIPTS-106)
|
Line 1434: | |||
uow.commitAndClose();</pre> | uow.commitAndClose();</pre> | ||
+ | = Find All Agents With Incompatible Version = | ||
+ | *This script will return which agents the server is reporting as to having an invalid version associated with them. | ||
+ | ==== AHPSCRIPTS-135 ==== | ||
+ | <pre>import com.urbancode.anthill3.main.client.AnthillClient; | ||
+ | import com.urbancode.anthill3.persistence.UnitOfWork; | ||
+ | import com.urbancode.anthill3.domain.agent.*; | ||
+ | import com.urbancode.anthill3.services.agent.*; | ||
+ | //The following settings are for establishing a connection to the anthill server | ||
+ | //Please change accordingly to your anthillpro server configuration | ||
+ | String serverHost = "localhost"; | ||
+ | int serverPort = 4567; | ||
+ | String userName = "admin"; | ||
+ | String password = "admin"; | ||
+ | //---------------------------------------------------------------------------------------------------------------------- | ||
+ | // obtain connection to the Anthill server | ||
+ | AnthillClient anthill = AnthillClient.connect(serverHost, serverPort, userName, password); | ||
+ | // create a Unit of Work | ||
+ | UnitOfWork uow = anthill.createUnitOfWork(); | ||
+ | // get an instance of the AgentManager | ||
+ | AgentManager manager = AgentManager.getInstance(); | ||
+ | String[] invalidAgents = null; | ||
+ | // get the list of Agents | ||
+ | Agent[] agentArray = AgentFactory.getInstance().restoreAll(); | ||
+ | // get Agents that have an incorrect version associated with them | ||
+ | invalidAgents = manager.getVersionMismatchAgentNameArray(); | ||
+ | // this will be used to store total mismatches | ||
+ | invalidTotal = 0; | ||
+ | print("\n"); | ||
+ | print("|===AGENTS REPORTING INVALID STATUS===|\n"); | ||
+ | for (entry : invalidAgents){ // get each invalid Agent | ||
+ | for (thisAgent : agentArray){ // get each Agent | ||
+ | if(thisAgent.getName().equals(entry)){ | ||
+ | print(thisAgent); | ||
+ | print(manager.getAgentStatus(thisAgent)); | ||
+ | invalidTotal++; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | print("\n"); | ||
+ | print("|===MISMATCHES===|"); | ||
+ | print(" TOTAL: " + invalidTotal); | ||
+ | uow.commitAndClose();</pre> |