Question
Siemens
Last activity: 18 Jan 2017 2:14 EST
Trigger mail on Agent status
I want to trigger a mail when agent is going down or disable due to exception is occur in agent activity.
Error message in log file "disabled due to execution errors ErrorMsg: com/pega/apache/log4j/spi/ThrowableInformation".
Agent Mode - Advanced
***13/10/2016: Updated by moderator: Lochan to update post with original body text that was lost due to a PDN bug; Apologies for the inconvenience caused***
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Pegasystems Inc.
IN
Hi Devendra,
The agent status JMX method that SMA uses is accessible to third party applications.Refer link -->https://community.pega.com/support/support-articles/how-monitor-prpc-agent-status-using-query-or-java-api
1) Monitor agent status from an external application that use appropriate remote JMX protocol for your platform to call PRPC, execute the agent status mbean and interpret the xml results.The command line jmxterm will work as an example.
2) Monitor agent status from an external application that calls a PRPC SOAP or HTTP service. In the publicAPI there is an agentUtils object can provide you with access to current agent status. See step 1 of activity pzCheckSearchAgentStatus (below)
3) Monitor agent status from an external application that calls a PRPC SOAP or HTTP service that uses the pega api method to call the agentStatus mbean methods. In the AESRemote ruleset there is an executeMbean service and activity. In PegaAES ruleset there are activities to SOAP to a node to call mbean com.pega.pegarules.management.AgentManagement operation AgentStatusAdvanced (then apply a parse-xml to interpet the results).
code sample for agentStatus:
Hi Devendra,
The agent status JMX method that SMA uses is accessible to third party applications.Refer link -->https://community.pega.com/support/support-articles/how-monitor-prpc-agent-status-using-query-or-java-api
1) Monitor agent status from an external application that use appropriate remote JMX protocol for your platform to call PRPC, execute the agent status mbean and interpret the xml results.The command line jmxterm will work as an example.
2) Monitor agent status from an external application that calls a PRPC SOAP or HTTP service. In the publicAPI there is an agentUtils object can provide you with access to current agent status. See step 1 of activity pzCheckSearchAgentStatus (below)
3) Monitor agent status from an external application that calls a PRPC SOAP or HTTP service that uses the pega api method to call the agentStatus mbean methods. In the AESRemote ruleset there is an executeMbean service and activity. In PegaAES ruleset there are activities to SOAP to a node to call mbean com.pega.pegarules.management.AgentManagement operation AgentStatusAdvanced (then apply a parse-xml to interpet the results).
code sample for agentStatus:
com.pega.pegarules.pub.context.AgentUtils agentUtils = tools.getAgentUtils();
com.pega.pegarules.pub.util.StringMap systemPulse = agentUtils.getQueue("Pega-RULES", 1);
com.pega.pegarules.pub.util.StringMap systemIndexer = agentUtils.getQueue("Pega-RULES", 2);
com.pega.pegarules.pub.util.StringMap systemWorkIndexer = agentUtils.getQueue("Pega-RULES", 5);
agentError = systemPulse == null || !Boolean.valueOf(systemPulse.getString("IsEnabled")).booleanValue() || !"".equals(systemPulse.getString("LastExceptionData"));
agentError = agentError || systemIndexer == null || !Boolean.valueOf(systemIndexer.getString("IsEnabled")).booleanValue() || !"".equals(systemIndexer.getString("LastExceptionData"));
agentError = agentError || systemWorkIndexer == null || !Boolean.valueOf(systemWorkIndexer.getString("IsEnabled")).booleanValue() || !"".equals(systemWorkIndexer.getString("LastExceptionData"));
Also,sample code attached for your reference.
Regards,
Sudhish OP
Areteans Technology Solutions
AU
Hi devendra,
You can try to have the last step of your agent activity to trigger an email where the precondition can check for a stepstatusfail.
Do an activity-clear-status and then call that activity to trigger a mail chain.
Also you can make the error message as the content of the email using the getPageMessage() method.
Regards,
Ratan Balaji.
Accepted Solution
Pegasystems Inc.
IN
Hi Devendra,
The agent status JMX method that SMA uses is accessible to third party applications.Refer link -->https://community.pega.com/support/support-articles/how-monitor-prpc-agent-status-using-query-or-java-api
1) Monitor agent status from an external application that use appropriate remote JMX protocol for your platform to call PRPC, execute the agent status mbean and interpret the xml results.The command line jmxterm will work as an example.
2) Monitor agent status from an external application that calls a PRPC SOAP or HTTP service. In the publicAPI there is an agentUtils object can provide you with access to current agent status. See step 1 of activity pzCheckSearchAgentStatus (below)
3) Monitor agent status from an external application that calls a PRPC SOAP or HTTP service that uses the pega api method to call the agentStatus mbean methods. In the AESRemote ruleset there is an executeMbean service and activity. In PegaAES ruleset there are activities to SOAP to a node to call mbean com.pega.pegarules.management.AgentManagement operation AgentStatusAdvanced (then apply a parse-xml to interpet the results).
code sample for agentStatus:
Hi Devendra,
The agent status JMX method that SMA uses is accessible to third party applications.Refer link -->https://community.pega.com/support/support-articles/how-monitor-prpc-agent-status-using-query-or-java-api
1) Monitor agent status from an external application that use appropriate remote JMX protocol for your platform to call PRPC, execute the agent status mbean and interpret the xml results.The command line jmxterm will work as an example.
2) Monitor agent status from an external application that calls a PRPC SOAP or HTTP service. In the publicAPI there is an agentUtils object can provide you with access to current agent status. See step 1 of activity pzCheckSearchAgentStatus (below)
3) Monitor agent status from an external application that calls a PRPC SOAP or HTTP service that uses the pega api method to call the agentStatus mbean methods. In the AESRemote ruleset there is an executeMbean service and activity. In PegaAES ruleset there are activities to SOAP to a node to call mbean com.pega.pegarules.management.AgentManagement operation AgentStatusAdvanced (then apply a parse-xml to interpet the results).
code sample for agentStatus:
com.pega.pegarules.pub.context.AgentUtils agentUtils = tools.getAgentUtils();
com.pega.pegarules.pub.util.StringMap systemPulse = agentUtils.getQueue("Pega-RULES", 1);
com.pega.pegarules.pub.util.StringMap systemIndexer = agentUtils.getQueue("Pega-RULES", 2);
com.pega.pegarules.pub.util.StringMap systemWorkIndexer = agentUtils.getQueue("Pega-RULES", 5);
agentError = systemPulse == null || !Boolean.valueOf(systemPulse.getString("IsEnabled")).booleanValue() || !"".equals(systemPulse.getString("LastExceptionData"));
agentError = agentError || systemIndexer == null || !Boolean.valueOf(systemIndexer.getString("IsEnabled")).booleanValue() || !"".equals(systemIndexer.getString("LastExceptionData"));
agentError = agentError || systemWorkIndexer == null || !Boolean.valueOf(systemWorkIndexer.getString("IsEnabled")).booleanValue() || !"".equals(systemWorkIndexer.getString("LastExceptionData"));
Also,sample code attached for your reference.
Regards,
Sudhish OP
Siemens
Hi Sudhish..thanks for reply. I have got the agent status from SMA but need to trigger alert whenever agent is going down. do you have any idea ?
we can do it by another agent but I am looking for some other solution.
.
Pegasystems Inc.
IN
Hi Devendra,
You can dump the status into external/internal table or file. Write a shell script to check the status/condition from table or file and send email to notify the set of users.If you are ready to go ahead with shell script , I can provide you the sample code for the same.
OR
If you are using AES then AES will trigger "Agent Disabled" scorecard email by PEGA0010, but client is not using AES yet.
OR
Java program monitoring PEGA0010 in alert log and send email to users.
Regards,
Sudhish OP
Siemens
Thanks Sudhish,1 and 3 option is good as AES not using.
Pegasystems Inc.
IN
Yes
Pegasystems Inc.
IN
Hello Devendra,
Please go through below Articles
https://collaborate.pega.com/question/need-send-outbound-email-when-agent-goes-down-production
https://collaborate.pega.com/question/send-notification-when-agent-gets-disabled
Thanks,
Arun
Siemens
Thanks Arun for reply.
Incessant Technologies
IN
Create a service Http when triggered, use the Service activity to loop through all the agents and identify the required agents which needs to be monitored. The below code will build a pagelist with name and status of agents. Loop through all the agents and verify if the status is enabled or disabled. You can use this agent name and other info to send an email or log the details.
AgentUtils au = tools.getAgentUtils();
ClipboardPage aListPage = tools.createPage("Code-Pega-List", "AgentsStatusList");
List auList = null;
try{
auList = au.getAgentNames();
}catch(Exception ex){
System.out.println("Exception: "+ex);
}
if(auList != null)
{
for(int i=0;i<auList.size();i++)
{
String name = (String)auList.get(i);
List auQueue = au.getQueues(name);
for(int j=0;j<auQueue.size();j++)
{
boolean enabled = au.isQueueEnabled(name, j);
StringMap qMap = (StringMap)au.getQueue(name, j);
String agentName = qMap.getString("Description");
String index = String.valueOf(j);
Create a service Http when triggered, use the Service activity to loop through all the agents and identify the required agents which needs to be monitored. The below code will build a pagelist with name and status of agents. Loop through all the agents and verify if the status is enabled or disabled. You can use this agent name and other info to send an email or log the details.
AgentUtils au = tools.getAgentUtils();
ClipboardPage aListPage = tools.createPage("Code-Pega-List", "AgentsStatusList");
List auList = null;
try{
auList = au.getAgentNames();
}catch(Exception ex){
System.out.println("Exception: "+ex);
}
if(auList != null)
{
for(int i=0;i<auList.size();i++)
{
String name = (String)auList.get(i);
List auQueue = au.getQueues(name);
for(int j=0;j<auQueue.size();j++)
{
boolean enabled = au.isQueueEnabled(name, j);
StringMap qMap = (StringMap)au.getQueue(name, j);
String agentName = qMap.getString("Description");
String index = String.valueOf(j);
ClipboardProperty cpAgent = aListPage.getProperty(".pxResults");
ClipboardPage cPage = tools.createPage("", "AgentInstance");
ClipboardProperty cpName = cPage.getProperty("pxName");
ClipboardProperty cpIndex = cPage.getProperty("pxIndex");
ClipboardProperty cpStatus = cPage.getProperty("pxStatus");
ClipboardProperty cpDescription = cPage.getProperty("pyDescription");
cpName.setValue(name);
cpIndex.setValue(index);
cpDescription.setValue(agentName);
if(enabled)
cpStatus.setValue("Enabled");
else cpStatus.setValue("Disabled");
cpAgent.add(cPage);
}
}
}