AgentStatsMXBean API를 사용하여 솔루션에 있는 에이전트의 활동 및 이벤트를 모니터링하십시오. AgentStatsMXBean API는
솔루션에서 활성 상태인 에이전트, 에이전트에 의해 처리된 이벤트의 수 및 이벤트 처리 중에 경과된 시간에 대한 정보를 검색합니다.
이 태스크 정보
AgentStatsMXBean API의 메소드를 사용하여
에이전트가 이벤트를 수신하고 처리하는 동안의 솔루션 성능을 모니터링할 수 있습니다. 관리 인터페이스는
com.ibm.ia.runtime.management.AgentStatsMXBean입니다.
프로시저
- MBean 서버에 연결하고, Liberty 프로파일에서 실행 중인 애플리케이션 코드에 대한 MBeanServer 인스턴스를 작성하십시오.
MBean 서버 연결 코드의 예제는 MBean 서버에 연결 주제를 참조하십시오.
- MXBean을 사용하여 프록시 오브젝트를 가져오는
javax.management.JMX.newMXBeanProxy 메소드를 호출하여 MBean 인터페이스를 활성화하십시오. Liberty 문서의 Liberty 프로파일에서 JMX MBean 관련 작업을 참조하십시오.
- getAgentStats 메소드를 호출하고 솔루션 또는 서버에 대한 정보를 제공하여 성능 통계의 목록을 검색하십시오. 다음 예제에서는 AgentStatsMXBean API를 사용하여 서버 파티션에 대한 정보를 검색한 후 검색된 통계를 JSON 오브젝트에 저장합니다.
try
{
MBeanServerConnection mbsc = getMBeanServer(serverInfo, isCurrent);
Set partitionNames = mbsc.queryNames(new ObjectName("com.ibm.ia:type=AgentStats,name=" + partition + ",*"), null);
Iterator partitionIter = partitionNames.iterator();
while (partitionIter.hasNext())
{
ObjectName partitionON = (ObjectName) partitionIter.next();
Integer eventCount = (Integer) mbsc.getAttribute(partitionON, "EventCount");
Integer agentCount = (Integer) mbsc.getAttribute(partitionON, "AgentCount");
Long eventTime = (Long) mbsc.getAttribute(partitionON, "EventTime");
Long agentTime = (Long) mbsc.getAttribute(partitionON, "AgentTime");
JSONObject partitionJson = new JSONObject();
partitionJson.put("id", partition);
partitionJson.put("label", partition);
partitionJson.put("eventCount", eventCount);
partitionJson.put("agentCount", agentCount);
partitionJson.put("eventTime", eventTime);
partitionJson.put("agentTime", agentTime);
partitionJson.put("eventTimeSeconds", TimeUnit.NANOSECONDS.toSeconds(eventTime));
partitionJson.put("eventTimeMilliSeconds", TimeUnit.NANOSECONDS.toMillis(eventTime));
partitionJson.put("agentTimeSeconds", TimeUnit.NANOSECONDS.toSeconds(agentTime));
partitionJson.put("agentTimeMilliSeconds", TimeUnit.NANOSECONDS.toMillis(agentTime));
array.add(partitionJson);
}
}
catch (Exception exc)
{
exc.printStackTrace();
}