一、JMX简介
JMX是一种JAVA的正式规范,它主要目的是让程序有被管理的功能,那么怎么理解所谓的“被管理”呢?试想你开发了一个软件(如WEB网站),它是在24小时不间断运行的,那么你可能会想要“监控”这个软件的运行情况,比如收到了多少数据,有多少人登录等等。或者你又想“配置”这个软件,比如现在访问人数比较多,你想把数据连接池设置得大一些。
当然,你也许会专门为这些管理来开发软件,但如果你借助JMX,则会发现创建这样的管理程序是如此简单。因为你无需为管理程序来开发界面,已经有通用的JMX管理软件,如MC4J,或者是用一般都附带提供的HTML网页来管理,你要做的仅仅是将自己要被管理和监控类的按照JMX规范修改一下即可。
中间件软件WebLogic的管理页面就是基于JMX开发的,而JBoss则整个系统都基于JMX构架。
二、监控Weblogic
下面介绍下如何通过jmx获取监控信息。
1、服务基本信息信息
/** * 构造函数 */ public WebLogicMiddlewareAdapter(JMXSession jmxSession) { currentTime = CommonUtils.getCurrentTime(); this.jmxSession = jmxSession; serverRuntime = (ObjectName) jmxSession.getAttribute(runtimeService, "ServerRuntime"); applicationRuntimes = (ObjectName[]) jmxSession.getAttribute(serverRuntime, "ApplicationRuntimes"); } /** * @see com.comtop.numen.monitor.collection.appservice.middleware.adapter.MiddlewareAdapter#getMiddleWareBaseInfomation() */ @Override public MiddleWareBaseInfoVO getMiddleWareBaseInfomation() { MiddleWareBaseInfoVO objWebLogic = new MiddleWareBaseInfoVO(); try { objWebLogic.setMiddlewareId(CommonUtils.getUUID()); objWebLogic.setWebContext(this.getWebConext()); if (JMXConstonts.JMX_COLLECT_EXTENDS.equals(jmxSession.getNodeInfoVO().getIsJmxExtends())) { // 获取进程ID objWebLogic.setMiddleWarePid(getMiddlewarePID()); } // 服务名称 objWebLogic.setServerName(jmxSession.getStringAttribute(runtimeService, "ServerName")); // Domain名称 ObjectName objConfig = (ObjectName) jmxSession.getAttribute(runtimeService, "DomainConfiguration"); objWebLogic.setDomainName(jmxSession.getStringAttribute(objConfig, "Name")); String strWLVersion=jmxSession.getStringAttribute(serverRuntime, "WeblogicVersion"); strWLVersion=strWLVersion.substring(strWLVersion.lastIndexOf("WebLogic"), strWLVersion.length()-1); objWebLogic.setRunnningState(jmxSession.getStringAttribute(serverRuntime, "State")); objWebLogic.setListenAddress(jmxSession.getStringAttribute(serverRuntime, "ListenAddress")); objWebLogic.setListenPort(jmxSession.getStringAttribute(serverRuntime, "ListenPort")); objWebLogic.setAdminServerHost(jmxSession.getStringAttribute(serverRuntime, "AdminServerHost")); objWebLogic.setAdminServerListenPort(jmxSession.getStringAttribute(serverRuntime, "AdminServerListenPort")); objWebLogic.setAdministrationPort(jmxSession.getStringAttribute(serverRuntime, "AdministrationPort")); objWebLogic .setOpenSocketsCurrentCount(jmxSession.getIntAttribute(serverRuntime, "OpenSocketsCurrentCount")); objWebLogic .setSocketsOpenedTotalCount(jmxSession.getIntAttribute(serverRuntime, "SocketsOpenedTotalCount")); objWebLogic.setRestartsTotalCount(jmxSession.getIntAttribute(serverRuntime, "RestartsTotalCount")); objWebLogic.setSSLListenAddress(jmxSession.getStringAttribute(serverRuntime, "SSLListenAddress")); long lTime = (Long) jmxSession.getAttribute(serverRuntime, "ActivationTime"); } catch (Exception e) { LOGGER.error("采集WebLogic信息出错" + e.getMessage()); return null; } return objWebLogic; }
2、JDBC信息
public JDBCInformationVO getJDBCInfomation() { JDBCInformationVO objJDBC = new JDBCInformationVO(); try { List<JDBCDetailVO> lstJdbcDetail = new ArrayList<JDBCDetailVO>(); List<JDBCInformationVO> lstJdbc = new ArrayList<JDBCInformationVO>(); String strJdbcId = CommonUtils.getUUID(); // 获取域配置对象 ObjectName domainConfig = (ObjectName) jmxSession.getAttribute(runtimeService, "DomainConfiguration"); ObjectName[] objJDBCSystemResources = (ObjectName[]) jmxSession.getAttribute(domainConfig, "JDBCSystemResources"); ObjectName jdbcSRName = (ObjectName) jmxSession.getAttribute(serverRuntime, "JDBCServiceRuntime"); ObjectName[] objJDBCDataSource = (ObjectName[]) jmxSession.getAttribute(jdbcSRName, "JDBCDataSourceRuntimeMBeans"); // 定义jdbcUtils对象 JDBCDetailVO objJDBCdetail = null; ObjectName objJdbcResource = null; ObjectName objPoolPrms = null; for (int i = 0; i < objJDBCDataSource.length; i++) { objJDBCdetail = new JDBCDetailVO(); objJDBCdetail.setDetailId(CommonUtils.getUUID()); objJDBCdetail.setJdbcId(strJdbcId); // 判断JDBCSystemResources对象是否为null if (objJDBCSystemResources[i] != null) { objJdbcResource = (ObjectName) jmxSession.getAttribute(objJDBCSystemResources[i], "JDBCResource"); objPoolPrms = (ObjectName) jmxSession.getAttribute(objJdbcResource, "JDBCConnectionPoolParams"); // 总的连接数 objJDBCdetail.setMaxCapacity(jmxSession.getIntAttribute(objPoolPrms, "MaxCapacity")); objJDBCdetail.setIncreseCapacity(jmxSession.getIntAttribute(objPoolPrms, "CapacityIncrement")); objJDBCdetail.setInitCapacity(jmxSession.getIntAttribute(objPoolPrms, "InitialCapacity")); // 数据源名称 String objDataSourceName = this.getJndiName(objJdbcResource); if (objDataSourceName == null) { break; } objJDBCdetail.setDataSourceName(objDataSourceName); } // 最大历史的连接数 objJDBCdetail.setHisMaxConn(jmxSession.getIntAttribute(objJDBCDataSource[i], "ActiveConnectionsHighCount")); // 驱动版本 objJDBCdetail.setDriverName(jmxSession.getStringAttribute(objJDBCDataSource[i], "VersionJDBCDriver")); // 数据源状态 objJDBCdetail.setDataSourceState(jmxSession.getStringAttribute(objJDBCDataSource[i], "State")); // 当前容量 objJDBCdetail.setCurrCapacity(jmxSession.getIntAttribute(objJDBCDataSource[i], "CurrCapacity")); // 当前活动的连接数 objJDBCdetail.setCurrConnection(jmxSession.getIntAttribute(objJDBCDataSource[i], "ActiveConnectionsCurrentCount")); // 数据源泄漏的连接数 objJDBCdetail.setLeakConn(jmxSession.getIntAttribute(objJDBCDataSource[i], "LeakedConnectionCount")); // 当前等待连接数 objJDBCdetail.setCurrWaitConn(jmxSession.getIntAttribute(objJDBCDataSource[i], "WaitingForConnectionCurrentCount")); // 历史等待连接数 objJDBCdetail.setHisMaxWaitConn(jmxSession.getIntAttribute(objJDBCDataSource[i], "WaitingForConnectionTotal")); // 当前可用连接数 objJDBCdetail.setCurrVailableConn(jmxSession.getIntAttribute(objJDBCDataSource[i], "NumAvailable")); // 失败重连数 objJDBCdetail.setFailReConn(jmxSession .getIntAttribute(objJDBCDataSource[i], "FailuresToReconnectCount")); } objJDBC.setDetail(lstJdbcDetail); objJDBC.setJdbcInfo(lstJdbc); } catch (Exception e) { LOGGER.error("采集JDBC信息出错" + e.getMessage()); return null; } return objJDBC; }
3、JVM内存信息以及GC信息
public JVMInformationVO getJVMInfomation() { JVMInformationVO objJVM = new JVMInformationVO(); try { objJVM.setJvmId(CommonUtils.getUUID()); ObjectName objName = (ObjectName) jmxSession.getAttribute(serverRuntime, "JVMRuntime"); // jvm 内存使用情况 double memoryMaxSize = Double.parseDouble(String.valueOf(jmxSession.getAttribute(objName, "HeapSizeCurrent"))); double memoryFreeSize = Double.parseDouble(String.valueOf(jmxSession.getAttribute(objName, "HeapFreeCurrent"))); // double memoryPer = (memoryMaxSize - memoryFreeSize) / memoryMaxSize * 100; objJVM.setJvmHeapTotalSize(String.valueOf(CommonUtils.getDoubleToPattern(memoryMaxSize, 2))); objJVM.setJvmHeapUsedSize(String.valueOf(CommonUtils .getDoubleToPattern((memoryMaxSize - memoryFreeSize), 2))); objJVM.setCreateDate(currentTime); objJVM.setNodeId(jmxSession.getNodeInfoVO().getNodeInfoId()); objName = (ObjectName) jmxSession.getAttribute(serverRuntime, "JVMRuntime"); objJVM.setJavaVersion(jmxSession.getStringAttribute(objName, "JavaVersion")); objJVM.setRunningState(jmxSession.getStringAttribute(serverRuntime, "State")); objJVM.setNodeInfoVO(jmxSession.getNodeInfoVO()); /************************************** * 采集扩展信息 ************************************/ if (JMXConstonts.JMX_COLLECT_EXTENDS.equals(jmxSession.getNodeInfoVO().getIsJmxExtends())) { this.getJVMExtendsInfo(objJVM); } } catch (Exception e) { LOGGER.error("采集JVM内存信息时出错" + e.getMessage()); return null; } return objJVM; } /** * 获取GC信息 * * @param strName * @param session * @param objVO * @return */ public Map<String, String[]> getGCInfo(String[] strName, JMXSession session, JVMInformationVO objVO) { Map<String, String[]> objGCMap = new HashMap<String, String[]>(5); ObjectName objGc = null; try { objGc = new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",*"); Set<ObjectName> mbeans = session.getConnection().queryNames(objGc, null); ObjectName objName = null; StringBuffer strGcCount = new StringBuffer(512); if (mbeans != null) { Iterator<ObjectName> iterator = mbeans.iterator(); while (iterator.hasNext()) { objName = (ObjectName) iterator.next(); String objGCName = session.getStringAttribute(objName, "Name"); String objGCCount = session.getStringAttribute(objName, "CollectionCount"); String objGCTime = session.getStringAttribute(objName, "CollectionTime"); strGcCount.append(objGCName).append(":").append(objGCCount).append(","); Object[] objGC = (Object[]) session.getAttribute(objName, "MemoryPoolNames"); for (int i = 0; i < objGC.length; i++) { if (objGCMap.get(objGC[i].toString()) == null) { objGCMap.put(objGC[i].toString(), new String[] { objGCName, objGCTime }); } else { String strTempName = objGCMap.get(objGC[i].toString())[0] + "," + objGCName; String strTempTime = objGCMap.get(objGC[i].toString())[1] + "," + objGCCount; objGCMap.put(objGC[i].toString(), new String[] { strTempName, strTempTime }); } } } if (strGcCount.length() > 0) { strGcCount.deleteCharAt(strGcCount.length() - 1); } objVO.setJvmMemGcCount(strGcCount.toString()); } } catch (Exception e) { LOGGER.error("获取GC信息时出错" + e.getMessage()); return null; } return objGCMap; }
/** * 获取JVM扩展信息 * * @param objJVM */ public void getJVMExtendsInfo(JVMInformationVO objJVM) { List<JVMDetailVO> lstJVMDetail = new ArrayList<JVMDetailVO>(10); try { /***************** JVM版本 ****************/ ObjectName objName = new ObjectName("java.lang:type=Runtime"); String strVMName = jmxSession.getStringAttribute(objName, "VmName"); String strVMVersion = jmxSession.getStringAttribute(objName, "VmVersion"); objJVM.setJvmVersion(strVMName + strVMVersion); String strJVMArg = JMXTransformHelp.transformArrayToString(jmxSession.getAttribute(objName, "InputArguments")); strJVMArg = strJVMArg != null && strJVMArg.length() > 2000 ? strJVMArg.substring(0, 1999) : strJVMArg; objJVM.setJvmArguments(strJVMArg); /***************** 内存回收情况 ****************/ Map<String, String[]> objGCMap = this.getGCInfo(JMXConstonts.GC_STRATEGY, jmxSession, objJVM); /***************** 内存分区情况 ****************/ ObjectName poolName = null; try { poolName = new ObjectName(MEMORY_POOL_MXBEAN_DOMAIN_TYPE + ",*"); } catch (MalformedObjectNameException e) { } Set<ObjectName> mbeans = jmxSession.getConnection().queryNames(poolName, null); if (mbeans != null) { Iterator<ObjectName> iterator = mbeans.iterator(); JVMDetailVO objDetailVO = null; while (iterator.hasNext()) { objDetailVO = new JVMDetailVO(); objName = (ObjectName) iterator.next(); MemoryUsage objUsage = MemoryUsage.from((CompositeDataSupport) jmxSession.getAttribute(objName, "Usage")); objDetailVO.setJvmDetailId(CommonUtils.getUUID()); objDetailVO.setJvmId(objJVM.getJvmId()); if (objUsage != null) { objDetailVO.setJvmMemCommitted(objUsage.getCommitted()); objDetailVO.setJvmMemInit(objUsage.getInit()); objDetailVO.setJvmMemMax(objUsage.getMax()); objDetailVO.setJvmMemUsed(objUsage.getUsed()); } objDetailVO.setJvmMemName(jmxSession.getStringAttribute(objName, "Name")); objDetailVO.setJvmMemType(jmxSession.getStringAttribute(objName, "Type")); if (objGCMap.get(objDetailVO.getJvmMemName()) != null) { objDetailVO.setJvmMemGcStrategy(objGCMap.get(objDetailVO.getJvmMemName())[0]); objDetailVO.setJvmMemGcTime(objGCMap.get(objDetailVO.getJvmMemName())[1]); } lstJVMDetail.add(objDetailVO); } } objJVM.setDetail(lstJVMDetail); } catch (Exception e) { LOGGER.error("获取JVM扩展信息出错" + e.getMessage()); } }
4、线程队列信息
public ThreadInformationVO getThreadQueueInfomation() { ThreadInformationVO objThreadQueue = new ThreadInformationVO(); // 线程对象 ObjectName objThreadPool = null; try { String strThreadId = CommonUtils.getUUID(); objThreadPool = (ObjectName) jmxSession.getAttribute(serverRuntime, "ThreadPoolRuntime"); // 线程吞吐量 objThreadQueue.setThroughput(jmxSession.getStringAttribute(objThreadPool, "Throughput")); // 队列长度 objThreadQueue.setQueueLength(jmxSession.getIntAttribute(objThreadPool, "QueueLength")); // 执行线程总数 objThreadQueue.setExeThreadTotalCount(jmxSession.getIntAttribute(objThreadPool, "ExecuteThreadTotalCount")); // 待命的线程数 objThreadQueue.setStandbyThreadCount(jmxSession.getIntAttribute(objThreadPool, "StandbyThreadCount")); // 活动线程数 objThreadQueue.setActiveExeThreadCount(objThreadQueue.getExeThreadTotalCount() - objThreadQueue.getStandbyThreadCount()); HealthState objState = (HealthState) jmxSession.getAttribute(objThreadPool, "HealthState"); objThreadQueue.setHealth(String.valueOf(objState.getState())); // 等待的用户请求数 objThreadQueue.setPendingRequestCount(jmxSession.getIntAttribute(objThreadPool, "PendingUserRequestCount")); // 占用的线程数 objThreadQueue.setHoggingThreadsCount(jmxSession.getIntAttribute(objThreadPool, "HoggingThreadCount")); objThreadQueue.setCreateDate(currentTime); objThreadQueue.setNodeId(jmxSession.getNodeInfoVO().getNodeInfoId()); objThreadQueue.setThreadId(strThreadId); /**************** get stuck threads ******/ ExecuteThread[] objExecuteThreadsList = (ExecuteThread[]) jmxSession.getAttribute(objThreadPool, "ExecuteThreads"); if (objExecuteThreadsList == null || objExecuteThreadsList.length == 0) { objThreadQueue.setStuckThreadsCount(0); return objThreadQueue; } List<ThreadDetailVO> lstStuckDetail = getStuckThreadList(objExecuteThreadsList, strThreadId); objThreadQueue.setDetail(lstStuckDetail); objThreadQueue.setStuckThreadsCount(lstStuckDetail.size()); } catch (Exception e) { LOGGER.error("采集线程队列时出错" + e.getMessage()); return null; } return objThreadQueue; } /** * 获取进程ID * * @return strPID */ /** * 获取stuck线程 * * @param objExecuteThreadsList * @param threadId * @return List<ThreadDetailVO> */ private List<ThreadDetailVO> getStuckThreadList(ExecuteThread[] objExecuteThreadsList, String threadId) { List<ThreadDetailVO> lstDetail = new ArrayList<ThreadDetailVO>(); ExecuteThread objThread = null; String strName = null; // 线程名称 // 当前请求的request内容 String strCurrentRequest = ""; String strIsStuck = null; // 是否阻塞 boolean bIsStuck = false; ThreadDetailVO objDetail = null; StackTraceElement[] strThreadInfo = null; StringBuilder strStackTrace = null; for (int i = 0; i < objExecuteThreadsList.length; i++) { objThread = objExecuteThreadsList[i]; strIsStuck = String.valueOf(objThread.isStuck()); bIsStuck = strIsStuck != null ? Boolean.parseBoolean(strIsStuck) : false; if (bIsStuck) { strName = objThread.getName(); objDetail = new ThreadDetailVO(); objDetail.setThreadName(strName != null ? strName : ""); strCurrentRequest = objThread.getCurrentRequest(); if (strCurrentRequest != null && strCurrentRequest.length() > 4000) { strCurrentRequest = strCurrentRequest.substring(0, 4000); } objDetail.setCurrentRequest(strCurrentRequest); objDetail.setCurrentRequestUri(JMXTransformHelp.getCurrentRequestUrlFromThread(strCurrentRequest)); objDetail.setThreadExeTime(System.currentTimeMillis() - objThread.getCurrentRequestStartTime()); // 线程堆栈信息 if (objThread.getExecuteThread() != null) { strThreadInfo = objThread.getExecuteThread().getStackTrace(); } strStackTrace = new StringBuilder(1024); if (strThreadInfo != null) { for (final StackTraceElement stackTraceElement : strThreadInfo) { strStackTrace.append(JMXTransformHelp.htmlEncode(stackTraceElement.toString(), true)).append( "<br/>"); } } objDetail.setStackInfo(strStackTrace.toString()); objDetail.setDetailId(CommonUtils.getUUID()); objDetail.setThreadId(threadId); lstDetail.add(objDetail); } } return lstDetail; }
5、JMS信息
public JmsInformationVO getJmsInfomation() { JmsInformationVO objJmsInfo = new JmsInformationVO(); ObjectName objName = (ObjectName) jmxSession.getAttribute(serverRuntime, "JMSRuntime"); objJmsInfo.setJmsId(CommonUtils.getUUID()); objJmsInfo.setServiceNodeId(jmxSession.getNodeInfoVO().getNodeInfoId()); objJmsInfo.setCreateDate(currentTime); objJmsInfo.setConnectionsCurrentCount(jmxSession.getIntAttribute(objName, "ConnectionsCurrentCount")); objJmsInfo.setConnectionsHighCount(jmxSession.getIntAttribute(objName, "ConnectionsHighCount")); objJmsInfo.setConnectionsTotalCount(jmxSession.getIntAttribute(objName, "ConnectionsTotalCount")); objJmsInfo.setServersCurrentCount(jmxSession.getIntAttribute(objName, "JMSServersCurrentCount")); objJmsInfo.setServersHighCount(jmxSession.getIntAttribute(objName, "JMSServersHighCount")); objJmsInfo.setServersTotalCount(jmxSession.getIntAttribute(objName, "JMSServersTotalCount")); HealthState objState = (HealthState) jmxSession.getAttribute(objName, "HealthState"); objJmsInfo.setHealthState(String.valueOf(objState.getState())); ObjectName[] objServers = (ObjectName[]) jmxSession.getAttribute(objName, "JMSServers"); if (objServers != null) { List<JmsDetailVO> lstJmsDetailVO = new ArrayList<JmsDetailVO>(); JmsDetailVO objDetail = null; for (int i = 0; i < objServers.length; i++) { objDetail = new JmsDetailVO(); objDetail.setJmsId(objJmsInfo.getJmsId()); objDetail.setJmsDetailId(CommonUtils.getUUID()); objDetail.setJmsName(jmxSession.getStringAttribute(objServers[i], "Name")); objDetail.setBytesCurrentCount(jmxSession.getIntAttribute(objServers[i], "BytesCurrentCount")); objDetail.setBytesHighCount(jmxSession.getIntAttribute(objServers[i], "BytesHighCount")); objDetail.setBytesPendingCount(jmxSession.getIntAttribute(objServers[i], "BytesPendingCount")); objDetail.setBytesReceivedCount(jmxSession.getIntAttribute(objServers[i], "BytesReceivedCount")); objDetail.setDestinationsCurrentCount(jmxSession.getIntAttribute(objServers[i], "DestinationsCurrentCount")); objDetail.setDestinationsHighCount(jmxSession.getIntAttribute(objServers[i], "DestinationsHighCount")); objDetail .setDestinationsTotalCount(jmxSession.getIntAttribute(objServers[i], "DestinationsTotalCount")); objDetail.setMessagesCurrentCount(jmxSession.getIntAttribute(objServers[i], "MessagesCurrentCount")); objDetail.setMessagesHighCount(jmxSession.getIntAttribute(objServers[i], "MessagesHighCount")); objDetail.setMessagesPendingCount(jmxSession.getIntAttribute(objServers[i], "MessagesPendingCount")); objDetail.setMessagesReceivedCount(jmxSession.getIntAttribute(objServers[i], "MessagesReceivedCount")); objDetail.setSessionPoolsCurrentCount(jmxSession.getIntAttribute(objServers[i], "SessionPoolsCurrentCount")); objDetail.setSessionPoolsHighCount(jmxSession.getIntAttribute(objServers[i], "SessionPoolsHighCount")); objDetail .setSessionPoolsTotalCount(jmxSession.getIntAttribute(objServers[i], "SessionPoolsTotalCount")); objState = (HealthState) jmxSession.getAttribute(objName, "HealthState"); objDetail.setHealthState(String.valueOf(objState.getState())); lstJmsDetailVO.add(objDetail); } objJmsInfo.setLstDetail(lstJmsDetailVO); } return objJmsInfo; }
6、获取EJB信息
public List<EjbInformationVO> getEjbInformation() { List<EjbInformationVO> lstEjb = new ArrayList<EjbInformationVO>(); for (int i = 4; i < applicationRuntimes.length; i++) { ObjectName[] objComponent = (ObjectName[]) jmxSession.getAttribute(applicationRuntimes[i], "ComponentRuntimes"); if (objComponent == null) { continue; } for (int j = 0; j < objComponent.length; j++) { if (objComponent[j] == null || !objComponent[j].getKeyPropertyListString().contains("EJB")) { continue; } ObjectName[] objEjbRuntime = (ObjectName[]) jmxSession.getAttribute(objComponent[j], "EJBRuntimes"); if (objEjbRuntime == null) { continue; } for (int k = 0; k < objEjbRuntime.length; k++) { EjbInformationVO objEjbVO = new EjbInformationVO(); objEjbVO.setServiceNodeId(jmxSession.getNodeInfoVO().getNodeInfoId()); objEjbVO.setStatus(jmxSession.getStringAttribute(objEjbRuntime[k], "DeploymentState")); objEjbVO.setEjbId(CommonUtils.getUUID()); objEjbVO.setCreateDate(currentTime); objEjbVO.setEjbName(jmxSession.getStringAttribute(objEjbRuntime[k], "EJBName")); ObjectName objEntry = objEjbRuntime[k]; ObjectName objRuntime = (ObjectName) jmxSession.getAttribute(objEntry, "PoolRuntime"); if (objRuntime == null) { continue; } double dDestroyedTotalCount = jmxSession.getDoubleAttribute(objRuntime, "DestroyedTotalCount"); double dMissTotalCount = jmxSession.getDoubleAttribute(objRuntime, "MissTotalCount"); double dAccessTotalCount = jmxSession.getDoubleAttribute(objRuntime, "AccessTotalCount"); double dTimeoutTotalCount = jmxSession.getDoubleAttribute(objRuntime, "TimeoutTotalCount"); // 已破坏 Bean 比率 objEjbVO.setDestroyedBeanRatio(CommonUtils.divideDataToString(dDestroyedTotalCount, dAccessTotalCount, 2)); // 缓冲池丢失比率 objEjbVO.setCachePoolMissRatio(CommonUtils .divideDataToString(dMissTotalCount, dAccessTotalCount, 2)); // 缓冲池超时比率 objEjbVO.setCachePoolTimeoutRatio(CommonUtils.divideDataToString(dTimeoutTotalCount, dAccessTotalCount, 2)); // objRuntime = (ObjectName) jmxSession.getAttribute(objEntry, "CacheRuntime"); // // 缓存丢失比率 =(缓存丢失总数/缓存访问总数)* 100 // double dCacheMissCount = jmxSession.getDoubleAttribute(objRuntime, "CacheMissCount"); // double dActivationCount = jmxSession.getDoubleAttribute(objRuntime, "ActivationCount"); // objEjbVO.setCachedMissRatio(CommonUtils.divideDataToString(dCacheMissCount, dActivationCount, // 2)); // objRuntime = (ObjectName) jmxSession.getAttribute(objEntry, "LockingRuntime"); // // 锁定等待程序比率 // // Lock Timeout Ratio =(Lock Manager Timeout Total Count / Lock Manager Total Access Count) * 100 // double dWaiterCurrentCount = jmxSession.getDoubleAttribute(objRuntime, "WaiterCurrentCount"); // double dLockCurrentCount = jmxSession.getDoubleAttribute(objRuntime, "LockEntriesCurrentCount"); // objEjbVO.setLockWaitRatio(CommonUtils.divideDataToString(dWaiterCurrentCount, dLockCurrentCount, // 2)); // // Lock Timeout Ratio =(Lock Manager Timeout Total Count / Lock Manager Total Access Count) * 100 // // 锁定超时比率 // double dLockManagerAccessCount = jmxSession.getDoubleAttribute(objRuntime, // "LockManagerAccessCount"); // dTimeoutTotalCount = jmxSession.getDoubleAttribute(objRuntime, "TimeoutTotalCount"); // objEjbVO.setLockTimeoutRatio(CommonUtils.divideDataToString(dTimeoutTotalCount, // dLockManagerAccessCount, 2)); // objRuntime = (ObjectName) jmxSession.getAttribute(objEntry, "TransactionRuntime"); double dTranCommTotalCount = jmxSession.getDoubleAttribute(objRuntime, "TransactionsCommittedTotalCount"); double dTranRollBackCount = jmxSession.getDoubleAttribute(objRuntime, "TransactionsRolledBackTotalCount"); double dTranTimeOutTotalCount = jmxSession.getDoubleAttribute(objRuntime, "TransactionsTimedOutTotalCount"); // 事务回滚比率 objEjbVO.setTransactionRollBackRatio(CommonUtils.divideDataToString(dTranRollBackCount, dTranCommTotalCount, 2)); // 事务超时比率 objEjbVO.setTransactionTimeoutRatio(CommonUtils.divideDataToString(dTranTimeOutTotalCount, dTranCommTotalCount, 2)); lstEjb.add(objEjbVO); } } } return lstEjb; }
如果还有其他需求可以查看http://edocs.weblogicfans.net/wls/docs92/jmx/index.html
相关推荐
java项目,自己做的项目利用jmx监控weblogic,tomcat,websphere源码
Java版 jmx 监控weblogic 生成html
BEA WebLogic Server实现了JMX大部分的API,并且提供了一个完全兼容JMX的控制台来管理各种资源。OPEN SOURCE的应用服务器JBoss也是基于JMX来实现。并且对之评价很高,认为是目前为止最好的软件集成工具。JBoss的成功...
网络逻辑JMX这是一个正在进行的工作,将经常更新,直到完成一组用于 9.X 及更高版本的 Weblogic 服务器的 JMX 服务器实用程序。 目前实时给出一些监控统计,后续会更新更多功能特征目前可以使用以下功能: JVM 监控...
JMX监控weblogic入门教程,基于weblogic自带的JMX,环境:weblogic8,jmx1.0,jdk1.4
这个插件通过管理控制台通过 JMX 监控 weblogic。 与其他 weblogic 插件不同,它会查询所有信息 1 次,然后使用 XPATH 识别您希望监控的信息。 这允许最大的灵活性。
利用spring来管理控制自己的应用程序 俞黎敏 议程 软件监控与管理的简要介绍 什么是jmx以及如何使用jmx jmx相关实现 spring给jmx使用带来的便利 jmx具体用用示例
监控原始Java Zabbix Java网关 描述 这是Zabbix Java Gateway的源代码,已更新为允许 jmx.discovery项(使用Mbeans自动发现) JBoss JMX Weblogic T3协议 它是如何工作的 您必须在JMX项目中指定一个用户名,例如“ ...
WebLogic Server 提供了一组 MBean,可用于通过 JMX 配置、监视和管理 WebLogic Server 资源。 Ruby 版本 - 仅在 JRuby 1.7.13 上测试过 配置 - 需要为 wlfullclient.jar 设置 CLASSPATH,除非您想使用 Trinidad,...
scylla数据库导出,用于抓取jmx的信息,可应用与zabbix下java进程(例如tomcat或者weblogic)的监控
基于JMX的监控和管理 xiv. 35. 测试 Spring Boot参考指南 4 i. 35.1. 测试作用域依赖 ii. 35.2. 测试Spring应用 iii. 35.3. 测试Spring Boot应用 i. 35.3.1. 使用Spock测试Spring Boot应用 iv. 35.4. 测试工具 i. ...
5个目标文件,演示Address EJB的实现,创建一个EJB测试客户端,得到名字上下文,查询jndi名,通过强制转型得到Home接口,getInitialContext()函数返回一个经过初始化的上下文,用client的getHome()函数调用Home接口...
5个目标文件,演示Address EJB的实现,创建一个EJB测试客户端,得到名字上下文,查询jndi名,通过强制转型得到Home接口,getInitialContext()函数返回一个经过初始化的上下文,用client的getHome()函数调用Home接口...