weblogic监控方案
- 格式:docx
- 大小:296.53 KB
- 文档页数:8
在Controller中配置WebSphere监控器一、WebSphere5.1配置步骤1.启动Websphere服务,具体步骤为:开始—>程序—>IBM Websphere—>Application Server v5.0—>启动服务器2.打开管理控制台,具体步骤为:开始—>程序—>IBM Websphere—>Application Server v5.0—>管理控制台,注:地址为:http://hostname:9090/admin3.用户标识可以不输入,即可登陆WebSphere管理控制台。
4.输入用户标识后,点“确定”按钮,进入管理控制台5.在窗口的左边菜单“应用程序”—>安装新的应用程序,打开右边的页面,在“本地路径”中选择应用程序源文件PerfServletApp.ear(路径为:C:\Program Files\WebSphere\AppServer\installableApps\PerfServletApp.ear), 在“上下文根”输入:/wasPerfTool6.点击“下一步”按钮,选中“生成缺省绑定”,其它按默认即可7.点“下一步”按钮,按默认即可8.点“继续”按钮,进入“提供用于执行安装的选项”窗口,在该窗口的“安装应用程序的目录”后面的文本框中输入:/ servlet/perfservlet,其它默认即可9.点“下一步”按钮,进入“映射 Web 模块的虚拟主机”窗口,在该窗口选中“Web模块”即可10.点“下一步”按钮,进入如下窗口,按默认设置即可11.点“下一步”按钮,进入如下窗口,按默认设置即可12.点“下一步”按钮,进入“摘要”窗口13.在“摘要”窗口点击“完成”按钮即可14.点击“保存到主配置”按钮即可15.点击“保存”按钮后,完成WebSphere的全部配置过程。
16.打开左边菜单,选择“应用程序”—>企业应用程序,在右边页面,选中新安装的应用程序(perfServletApp),然后点击“启动”按钮启动即可。
weblogic 实例健康状态监视实现原理文章标题:深度解析Weblogic实例健康状态监视实现原理一、引言Weblogic作为一种流行的Java应用服务器,在企业级应用中扮演着重要角色。
而实例健康状态监视是保证Weblogic平稳运行的关键机制之一。
本文将深入探讨Weblogic实例健康状态监视的原理和实现方式,并尝试从简到繁,由浅入深地解析这一话题。
二、Weblogic实例健康状态监视的意义和作用Weblogic实例健康状态监视是为了保障应用服务器的稳定性和可靠性而设计的。
它能够帮助系统管理员及时发现系统异常,预防系统故障,提高系统的可用性和安全性。
1. 实例健康状态监视基本概念Weblogic实例健康状态监视是指对服务器实例进行实时监控,通过记录和分析实例运行时的状态及参数来维护服务器的稳定性。
它通常包括对CPU利用率、内存消耗、线程状态、系统负载等指标的监控。
2. 实例健康状态监视的作用实例健康状态监视不仅可以帮助系统管理员及时发现潜在问题,还可以追踪问题发生的原因,提高问题排查的效率。
它还能够为系统的自动化运维提供基础数据和保障。
三、Weblogic实例健康状态监视的实现原理和方式Weblogic实例健康状态监视的实现原理主要包括以下几个方面:监控项的选择、数据收集和分析、告警和报警机制等。
1. 监控项的选择在进行实例健康状态监视时,需要选择适当的监控项来评估服务器实例的运行情况。
常见的监控项包括CPU利用率、内存消耗、线程状态、系统负载、响应时间等。
这些监控项能够全面反映服务器实例的运行状况,对于及时发现问题至关重要。
2. 数据收集和分析数据收集是实例健康状态监视的基础。
Weblogic通常会通过Agent或者JMX等方式来收集服务器实例的运行数据,然后通过数据分析来评估实例的健康状态。
这一过程需要借助一些监控工具或者自定义脚本来完成。
3. 告警和报警机制当服务器实例的健康状态出现异常时,需要及时通知系统管理员进行处理。
性能测试工作室,专注于性能测试技术研究(JMSRuntimeJMSServersCurrentCount 返回当前JMS服务的连接数ConnectionsCurrentCount 返回本JMS服务器上当前的连接数JMSServersHighCount 返回自服务器启动后JMS服务的最大连接数ConnectionsHighCount 返回本JMS服务器自上次重置后的最大连接数JVMRuntimeHeapSizeCurrent 返回当前JVM堆中内存数,单位时字节HeapFreeCurrent 返回当前JVM堆中空闲内存数,单位时字节ExecuteQueueRuntimeExecuteThreadCurrentIdleCount 返回队列中当前空闲线程数PendingRequestOldestTime 返回队列中最长的等待时间PendingRequestCurrentCount 返回队列中等待的请求数Queue Length 队列长度JDBCConnectionPoolRuntimeWaitingForConnectionHighCount返回本JDBCConnectionPoolRuntimeMBean 上最大等待连接数WaitingForConnectionCurrentCount 返回当前等待连接的总数MaxCapacity 返回JDBC池的最大能力WaitSecondsHighCount 返回等待连接中的最长时间等待者的秒数ActiveConnectionsCurrentCount 返回当前活动连接总数ActiveConnectionsHighCount 返回本JDBCConnectionPoolRuntimeMBean 上最大活动连接数注:weblogic通常监控JVM和执行队列,JDBC连接池,其中执行队列最关键的指标是Queue Length 队列长度weblogic一般来说监控jvm的使用、执行线程队列情况、和连接池的变化情况,还有一个很重要的检查weblogic的console日志这里经常能反映一些很重要到情况。
weblogic调优参数对Weblogic的调优主要从SEVER、ExecuteQueue、JDBC等几个方面的相关参数进行调优:一、SERVER在mydomain->Servers->myserver->Configuration->Tuning->“Enable Native IO”中: 1、Native IOEnabledTRUE,表示该Server使用本地I/O2、SocketReaders设置在执行线程中专用做Socket Readers的百分比3、Maximum Open Sockets最大打开Socket数4、Stuck Thread MaxTime堵塞线程时间,超过这个时间没有返回的执行线程,系统将认为是堵塞线程如果weblogic认为某个队列中的所有的线程全部堵塞的话,weblogic将会增加执行线程的数量。
注意:执行线程的数量一旦增加,目前weblogic不会去减少他,如果增加了一些线程以后再次出现overflow的警告,weblogic会继续增加执行线程的数量,一直到达到上限为止。
5、Stuck Thread Timer Interval系统检查堵塞线程的时间间隔6、Low Memory GC Threshold当可用内存小于该百分比时,垃圾回收启动7、Low Memory Granularity Level当两次检测的可用内存变化超过该百分比时,垃圾回收启动8、Low Memory Sample Size在一次检测中的取样次数9、Low Memory Time Interval检测间隔时间10、Accept Backlog等待队列中最多可以有多少TCP连接等待处理,如果在许多客户端连接被拒绝,而在服务器端没有错误显示,说明该值设得过低。
如果连接时收到connection refused消息,说明应提高该值,每次增加25%二、ExecuteQueue在mydomain->Servers->myserver ->Monitoring->Monitor all Active Queues... ->Configuration->weblogic.kernel.Default->1、ThreadCount服务器初始创建的执行线程的数量,设置原则:增大机器的最大并发线程数使处理器利用率达到最大。
weblogic的使用
WebLogic是一种常用的Java应用服务器,它能够提供高度可扩展的企业级应用程序运行环境。
使用WebLogic可以简化应用程序开发、部署和管理过程,提高应用程序的可靠性和性能。
以下是WebLogic 的使用方法:
1. 安装WebLogic服务器:在官方网站下载WebLogic服务器安装包,按照安装向导完成安装过程。
2. 创建WebLogic域:WebLogic域是WebLogic服务器的逻辑管理单元,通过创建域可以管理应用程序、配置服务器等。
使用配置向导创建域。
3. 部署应用程序:将应用程序的WAR或EAR文件部署到WebLogic 服务器中,可以使用WebLogic控制台或命令行工具进行部署。
4. 配置服务器:通过WebLogic控制台或命令行工具可以配置WebLogic服务器,如配置JDBC数据源、安全设置、JMS等。
5. 启动和停止服务器:可以使用WebLogic控制台或命令行工具启动和停止WebLogic服务器。
6. 监控服务器:通过WebLogic控制台可以实时监控WebLogic 服务器的运行状态、应用程序状态、日志等信息。
7. 优化服务器性能:WebLogic服务器提供了多种性能优化选项,如配置缓存、调整线程池大小等。
8. 备份和恢复服务器:通过备份WebLogic域和应用程序,可以实现服务器数据的备份和恢复。
WebLogic的使用需要一定的Java和Web应用程序开发基础,但是通过学习官方文档和示例,可以快速掌握WebLogic的使用方法。
1 WEBLOGIC服务器管理概述10域、管理服务器与受管服务器10启动管理控制台12运行时对象与配置对象12日志消息的集中访问14W EB L OGIC管理服务器与W EB L OGIC受管服务器15启动时的错误消息15启动W EB L OGIC管理服务器15WebLogic服务器启动时的口令使用16从Start菜单启动WebLogic管理服务器16启动与终止Windows服务形式的WebLogic服务器16从命令行启动WebLogic管理服务器17用脚本启动管理服务器20在受管服务器运行时重启管理服务器 20在同台机器上重启管理服务器21在其它机器上重启管理服务器21将W EB L OGIC受管服务器加入到域22启动W EB L OGIC受管服务器22通过脚本启动W EB L OGIC受管服务器 24从老版本W EB L OGIC服务器升级 25从管理控制台终止W EB L OGIC服务器 25从命令行停止服务器25暂停和恢复受管服务器26将W EB L OGIC服务器设置为W INDOWS服务26删除W INDOWS服务形式的W EB L OGIC服务器27更改安装成Windows服务的服务器口令27注册启动与终止类282 节点管理器 29节点管理器概述29配置与启动节点管理器30启动节点管理器31启动管理服务器323 配置WEBLOGIC服务器与集群35服务器与集群配置概述35管理服务器的角色35启动管理控制台37动态配置的工作原理38集群配置规划38- 1 -服务器配置任务列表39集群配置列表41新建一个域42概述43监控服务器44终止或暂停服务器45性能45集群数据46服务器安全46JMS 47JTA 47监控JDBC连接池 47管理控制台的M ONITORING页面一览表484 用日志消息管理WEBLOGIC服务器51日志子系统概述51本地服务器的日志文件53启动日志53客户端日志54日志文件的格式54消息属性54消息目录55消息的严重级别55消息调试56浏览日志文件56查看日志56创建域日志过滤器575 分发应用58分发格式58用管理控制台分发应用58步骤1:配置与分发应用59步骤2:分发应用组件 59分发顺序61自动分发62启用或禁用自动部署62动态分发64启用与禁用自动分发64自动分发展开目录格式的应用64卸载或重新分发被自动分发的应用656 配置WEBLOGIC服务器的WEB组件66- 2 -概述66HTTP参数66配置监听端口67W EB应用68Web应用与集群68指定缺省的Web应用68配置虚拟主机70虚拟主机与缺省Web应用70设置虚拟主机71W EB L OGIC服务器如何解析HTTP请求72设置HTTP访问日志73日志回旋(Log Rotation)73使用管理控制台设置HTTP访问日志 73普通日志格式74使用扩展日志格式75防止“POST拒绝服务”攻击80设置W EB L OGIC服务器的HTTP隧道 81配置HTTP隧道连接81建立客户端与WebLogic服务器之间的连接82用本地I/O提供静态文件服务(只适用于W INDOWS)827 代理对另一个HTTP服务器的请求 84概述84设置从服务器的代理84代理S ERVLET的分发描述符示例858 代理对WEBLOGIC集群的请求87概述87设置H TTP C LUSTER S ERVLET 87H TTP C LUSTER S ERVLET的分发描述符示例889 91配置W EB应用的安全性91设置对Web应用的授权91多Web应用、Cookies与身份验证92限制对Web应用资源的访问92在servlet中使用用户和角色94配置W EB应用的外部资源96在W EB应用中引用EJB S97配置会话管理98HTTP会话属性98- 3 -会话超时98配置会话Cookies 99使用长效cookies 99配置持久化会话100通用属性100使用基于内存的、单服务器的、非复制的持久存储 101使用基于文件的持久存储101使用基于数据库的持久存储 102使用URL重写103URL重写的编码指南104URL重写与无线访问协议(WAP) 104使用字符集与POST数据10410 配置APACHE-WEBLOGIC服务器插件106概述106平台支持107安装库107配置HTTPD.CONF文件109通过URL代理109通过MIME文件类型代理110A PACHE-W EB L OGIC S ERVER插件的参数110使用SSL协议112与SSL-A PACHE配置有关的问题 113H TTPD.CONF文件示例114配置文件示例115使用WebLogic集群的例子115不使用WebLogic集群的例子115配置虚拟主机的例子116分发A PACHE-W EB L OGIC S ERVER插件11611 配置MICROSOFT-IIS插件117概述117连接池以及保持活动状态117安装库118更新IIS设置使请求转给W EB L OGIC118创建IIS P ROXY.INI文件119文件扩展名方式的请求代理 122路径方式的请求代理123.ini文件示例123使用SSL 124将SERVLETS请求转交给W EB L OGIC服务器处理125- 4 -安装测试12612 配置NETSCAPE插件127概述127连接池和保持激活127插件的配置128步骤1:复制库128步骤2:设置obj.conf文件128步骤3:更改MIME.types文件132步骤4:分发与测试NSAPI插件 132参数132使用SSL协议135有关W EB L OGIC服务器集群失败转移的注意事项1360BJ.CONF文件示例(不使用W EB L OGIC集群的情况)136OBJ.CONF文件(使用W EB L OGIC集群的情况) 13813 安全管理141安全配置概述141改变系统口令143指定一个安全域143配置缓存域144配置LDAP安全域147配置Windows NT安全域151配置UNIX安全域 153配置RDBMS安全域154安装一个定制安全域155测试代用安全域与定制安全域156迁移安全域157定义用户157定义用户组159定义虚拟机的用户组159定义ACL 160配置SSL协议161获得私钥与数字证书162保存私钥与数字签名164定义可靠的证书管理机构165定义SSL协议的配置字段165配置双向验证167C ONFIGURING RMI OVER IIOP OVER SSL(TBD)168口令的保护168安装审计提供者170- 5 -安装连接过滤器170设置J AVA安全管理器171配置安全上下文传播17314 管理事务176事务管理概述176配置事务177事务的监控与日志记录178将服务器迁移到另一台机器中17815 管理JDBC连接180用管理控制台管理JDBC 180JDBC配置指南180JDBC配置概述181配置JDBC驱动程序182连接池187设置连接池187管理连接池188多池188创建多池188管理多池188数据源189创建数据源189数据源管理18916 管理JMS 191配置JMS 191配置连接工厂192配置模板193配置收信方主键193配置备份库194配置JMS服务器195配置收信方195配置会话池196配置连接使用者197监控JMS 197恢复失败的W EB L OGIC服务器198重启或替换WebLogic服务器198编程考虑19917 管理JNDI 200- 6 -将对象装载到JNDI树200查看JNDI树20018 管理WEBLOGIC J2EE连接器构架201W EB L OGIC J2EE连接器构架概述201安装资源适配器202配置与部署资源适配器202配置与部署资源适配器202查看已部署的资源适配器203卸载已部署的资源适配器203删除一个资源适配器204查看元素与属性205监控连接池与参数205编辑资源适配器分发描述符 20519 管理WEBLOGIC服务器许可证208安装W EB L OGIC许可证208更新许可证208A 使用WEBLOGIC JAVA工具210A PPLET A RCHIVER210语法211C ONVERSION211D ER2PEM211例子212DBPING212语法212D EPLOY212参数212Actions(从下表中选一个) 213其它参数213选项213例子213GET P ROPERTY 215语法215例子215LOG T O Z IP216语法216例子217M ULTICAST T EST217语法218例子218- 7 -MYIP219语法219例子219P EM2DER 219语法219例子220S CHEMA220语法220例子220SHOW L ICENSES221语法221SYSTEM221语法221例子221T3DBPING222语法222VERBOSE T O Z IP222语法223UNIX上的例子223NT上的例子223VERSION223语法223例子223WRITE L IENSE224语法224例子224B WEBLOGIC服务器的命令行接口参考226命令行接口简介226Before You Begin 226使用W EB L OGIC服务器命令227语法227参数227W EB L OGIC服务器管理命令参考228CONNECT 229HELP 229LICENSES 230LIST 230LOCK 231PING 231SERVERLOG 232SHUTDOWN 233THR EAD_DUMP 233- 8 -unlock 234VERSION 234M BEAN管理命令参考235CREATE命令 235DELETE命令 236GET命令237INVOKE命令 238SET命令239配置及管理连接池的命令240命令的名字240WEB服务器插件的参数241概述241W EB SERVER插件的一般参数241W EB SERVER插件的SSL参数245- 9 -1WebLogic服务器管理概述本章将介绍WebLogic服务器的管理工具,内容如下:✓域、管理服务器以及受管理的服务器✓启动管理控制台✓运行时对象与配置对象✓对日志消息的集中访问BEA WebLogic Server™包含了许多互相关联的资源。
微服务监控方案随着微服务架构的流行,微服务监控也越来越重要。
由于微服务架构通常由大量的服务组成,每个服务都可以独立地扩展和更新,因此单一的监控系统往往无法满足对各个微服务的监控需求。
为了解决这个问题,我们需要采用一种综合性的微服务监控方案。
一、监控目标微服务监控的目标是实时、准确地获取微服务的运行状态,包括服务的可用性、性能指标、错误日志等,并对这些信息进行分析和展示,以便及时发现问题并进行故障排查和性能优化。
二、监控方案1. 服务注册与发现:微服务架构中的服务通常采用注册与发现的方式进行调用,因此首先需要将所有服务注册到一个注册中心,并通过注册中心动态地获取服务信息。
2. 数据采集与存储:对于每个微服务,需要在其内部集成监控采集组件,用于定期收集各种监控数据。
这些数据可以包括服务接口的响应时间、吞吐量、错误次数等。
收集的监控数据可以保存到指定的数据存储中,如关系型数据库、NoSQL数据库、时序数据库等。
3. 数据分析与报警:通过对采集的监控数据进行分析,可以获得服务的性能指标、趋势分析、异常检测等信息。
通过设置阈值和规则,对异常情况进行自动报警,以便及时发现和解决问题。
4. 可视化与分布式追踪:将采集的监控数据进行可视化展示,以便更直观地了解服务的状态和性能。
同时,还可以通过分布式追踪工具对服务之间的调用进行追踪和监控,以便及时发现调用链的问题。
5. 日志管理与分析:微服务架构中的服务通常会产生大量的日志,因此需要对日志进行集中管理和分析。
可以使用日志集中管理工具,如ELK(Elasticsearch、Logstash、Kibana)来收集、存储和展示日志信息。
三、技术选型1. 服务注册与发现:可以选择使用开源的服务注册与发现组件,如Consul、Eureka等。
2. 数据采集与存储:可以选择使用开源的监控采集组件,如Prometheus、StatsD等。
数据存储可以选择使用关系型数据库、NoSQL数据库或时序数据库,如MySQL、MongoDB、InfluxDB等。
通过JMX获取weblogic的监控指标通过JMX获取weblogic的监控数据,包括JDBC,SESSION,SERVERLET,JVM等信息。
主要⽤到weblogic⾃⼰的t3协议,所以要⽤到weblogic的jar包:wlfullclient.jar和wlclient.jar。
这两个jar包怎么获取我专门在另外⼀篇⽂章中讲。
下⾯贴⼀些获取监控指标的代码,做个备份只⽤吧。
1、对JDBC的监控,只取了最重要的监控指标:package test;import java.io.IOException;import .MalformedURLException;import java.util.Hashtable;import javax.management.MBeanServerConnection;import javax.management.MalformedObjectNameException;import javax.management.ObjectName;import javax.management.remote.JMXConnector;import javax.management.remote.JMXConnectorFactory;import javax.management.remote.JMXServiceURL;import javax.naming.Context;public class PrintJdbc {private static MBeanServerConnection connection;private static JMXConnector connector;private static final ObjectName service;static {try {service = new ObjectName("com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean");}catch (MalformedObjectNameException e) {throw new AssertionError(e.getMessage());}}public static void initConnection(String hostname, String portString,String username, String password) throws IOException,MalformedURLException {String protocol = "t3";Integer portInteger = Integer.valueOf(portString);int port = portInteger.intValue();String jndiroot = "/jndi/";String mserver = "weblogic.management.mbeanservers.runtime";JMXServiceURL serviceURL = new JMXServiceURL(protocol, hostname,port, jndiroot + mserver);Hashtable h = new Hashtable();h.put(Context.SECURITY_PRINCIPAL, username);h.put(Context.SECURITY_CREDENTIALS, password);h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,"weblogic.management.remote");connector = JMXConnectorFactory.connect(serviceURL, h);connection = connector.getMBeanServerConnection();}public static ObjectName getServerRuntimes() throws Exception {return (ObjectName)connection.getAttribute(service,"ServerRuntime");}public ObjectName getJDBCServer() throws Exception {ObjectName dc = getServerRuntimes();ObjectName jdbcService = (ObjectName)connection.getAttribute(dc,"JDBCServiceRuntime");return jdbcService;}public ObjectName[] getJDBCDataSourceRuntime() throws Exception {ObjectName[] jdbcDataSourceRTMB = (ObjectName[]) connection.getAttribute(getJDBCServer(), "JDBCDataSourceRuntimeMBeans");return jdbcDataSourceRTMB;}public void printJdbc() throws Exception {ObjectName[] objectList = getJDBCDataSourceRuntime();if(objectList != null && objectList.length > 0){for(ObjectName obj : objectList){int connectionsTotalCount = (int) connection.getAttribute(obj, "ConnectionsTotalCount");int activeConnectionsCurrentCount = (int)connection.getAttribute(obj, "ActiveConnectionsCurrentCount");int activeConnectionsAverageCount = (int)connection.getAttribute(obj,"ActiveConnectionsAverageCount");int failuresToReconnectCount = (int)connection.getAttribute(obj, "FailuresToReconnectCount");String name = (String)connection.getAttribute(obj, "Name");int waitingForConnectionCurrentCount = (int)connection.getAttribute(obj, "WaitingForConnectionCurrentCount");long waitingForConnectionFailureTotal = (long)connection.getAttribute(obj, "WaitingForConnectionFailureTotal");int waitSecondsHighCount = (int)connection.getAttribute(obj, "WaitSecondsHighCount");int connectionDelayTime = (int)connection.getAttribute(obj, "ConnectionDelayTime");int activeConnectionsHighCount = (int)connection.getAttribute(obj, "ActiveConnectionsHighCount");int currCapacity = (int)connection.getAttribute(obj, "CurrCapacity");System.out.println("currCapacity==" + currCapacity);System.out.println("activeConnectionsHighCount==" + activeConnectionsHighCount);System.out.println("connectionDelayTime==" + connectionDelayTime);System.out.println("connectionsTotalCount==" + connectionsTotalCount);System.out.println("activeConnectionsCurrentCount==" + activeConnectionsCurrentCount);System.out.println("activeConnectionsAverageCount==" + activeConnectionsAverageCount);System.out.println("failuresToReconnectCount==" + failuresToReconnectCount);System.out.println("name==" + name);System.out.println("waitingForConnectionCurrentCount==" +waitingForConnectionCurrentCount );System.out.println("waitingForConnectionFailureTotal==" + waitingForConnectionFailureTotal);System.out.println("waitSecondsHighCount==" + waitSecondsHighCount);}}}public static void main(String[] args) throws Exception {String hostname = "10.111.131.50";String portString = "7001";String username = "weblogic";String password = "weblogic123";PrintJdbc s = new PrintJdbc();initConnection(hostname, portString, username, password);s.printJdbc();connector.close();}} 2、有关thread的监控:package test;import java.io.IOException;import .MalformedURLException;import java.util.Hashtable;import javax.management.MBeanServerConnection;import javax.management.MalformedObjectNameException;import javax.management.ObjectName;import javax.management.remote.JMXConnector;import javax.management.remote.JMXConnectorFactory;import javax.management.remote.JMXServiceURL;import javax.naming.Context;public class PrintThread {private static MBeanServerConnection connection;private static JMXConnector connector;private static final ObjectName service;static {try {service = new ObjectName("com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean"); }catch (MalformedObjectNameException e) {throw new AssertionError(e.getMessage());}}public static void initConnection(String hostname, String portString,String username, String password) throws IOException,MalformedURLException {String protocol = "t3";Integer portInteger = Integer.valueOf(portString);int port = portInteger.intValue();String jndiroot = "/jndi/";String mserver = "weblogic.management.mbeanservers.runtime";JMXServiceURL serviceURL = new JMXServiceURL(protocol, hostname,port, jndiroot + mserver);Hashtable h = new Hashtable();h.put(Context.SECURITY_PRINCIPAL, username);h.put(Context.SECURITY_CREDENTIALS, password);h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,"weblogic.management.remote");connector = JMXConnectorFactory.connect(serviceURL, h);connection = connector.getMBeanServerConnection();}public static ObjectName getServerRuntimes() throws Exception {return (ObjectName)connection.getAttribute(service,"ServerRuntime");}public void printInfo() throws Exception{ObjectName objThreadPool = null;ObjectName serverRT = getServerRuntimes();objThreadPool = (ObjectName) connection.getAttribute(serverRT, "ThreadPoolRuntime");double throughput = Double.parseDouble(String.valueOf(connection.getAttribute(objThreadPool,"Throughput")));System.out.println("throughput:" + throughput);int executeThreadTotalCount = Integer.parseInt(String.valueOf(connection.getAttribute(objThreadPool, "ExecuteThreadTotalCount"))); System.out.println("executeThreadTotalCount:" + executeThreadTotalCount);int executeThreadIdleCount = Integer.parseInt(String.valueOf(connection.getAttribute(objThreadPool, "ExecuteThreadIdleCount"))); System.out.println("executeThreadIdleCount:" + executeThreadIdleCount);int StandbyThreadCount = Integer.parseInt(String.valueOf(connection.getAttribute(objThreadPool, "StandbyThreadCount")));System.out.println("StandbyThreadCount:" + StandbyThreadCount);long timestamp = System.currentTimeMillis() / 1000;String metricJson = "";String jsonFormat = "{\"name\": \"weblogic_threadpool_metric_demo\", " +"\"command\":\"weblogic_threadpool_metric\"," +"\"type\": \"metric\"," +"\"handlers\": [\"influxdb\"],"+"\"output\": \"%s %.5f %d\\n%s %d %d\\n%s %d %d\\n\"," +"\"status\": 0}";metricJson = String.format(jsonFormat,".weblogic.threadpool.throughput", (double)throughput, timestamp,".weblogic.threadpool.executeThreadTotalCount", (int)executeThreadTotalCount, timestamp,".weblogic.threadpool.executeThreadIdleCount", (int)executeThreadIdleCount, timestamp);System.out.println("metricJson==" + metricJson);}public static void main(String args[]) throws Exception {String hostname = "10.111.131.50";String portString = "7001";String username = "weblogic";String password = "weblogic123";PrintThread s = new PrintThread();initConnection(hostname, portString, username, password);s.printInfo();connector.close();}} 3、有关session的监控:package test;import java.io.IOException;import .MalformedURLException;import java.util.Hashtable;import javax.management.MBeanServerConnection;import javax.management.MalformedObjectNameException;import javax.management.ObjectName;import javax.management.remote.JMXConnector;import javax.management.remote.JMXConnectorFactory;import javax.management.remote.JMXServiceURL;import javax.naming.Context;public class PrintServerState {private static MBeanServerConnection connection;private static JMXConnector connector;private static final ObjectName service;static {try {service = new ObjectName("com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean"); }catch (MalformedObjectNameException e) {throw new AssertionError(e.getMessage());}}public static void initConnection(String hostname, String portString,String username, String password) throws IOException,MalformedURLException {String protocol = "t3";Integer portInteger = Integer.valueOf(portString);int port = portInteger.intValue();String jndiroot = "/jndi/";String mserver = "weblogic.management.mbeanservers.domainruntime";JMXServiceURL serviceURL = new JMXServiceURL(protocol, hostname,port, jndiroot + mserver);Hashtable h = new Hashtable();h.put(Context.SECURITY_PRINCIPAL, username);h.put(Context.SECURITY_CREDENTIALS, password);h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,"weblogic.management.remote");connector = JMXConnectorFactory.connect(serviceURL, h);connection = connector.getMBeanServerConnection();}public static ObjectName[] getServerRuntimes() throws Exception {return (ObjectName[]) connection.getAttribute(service,"ServerRuntimes");}public static ObjectName[] getApplicationRuntimes(ObjectName serverRuntime) throws Exception {return (ObjectName[])connection.getAttribute(serverRuntime, "ApplicationRuntimes");}public static ObjectName[] getComponentRuntimes(ObjectName componentRutime) throws Exception {return (ObjectName[]) connection.getAttribute(componentRutime, "ComponentRuntimes");}public void printSessionState() throws Exception {ObjectName[] serverRT = getServerRuntimes();int length = (int) serverRT.length;for(int i = 0;i<length;i++){ObjectName[] applicationRT = getApplicationRuntimes(serverRT[i]);int length_app = (int)applicationRT.length;for(int y = 0;y<length_app;y++){String applicationName = (String)connection.getAttribute(applicationRT[y], "ApplicationName");if(applicationName.equals("helloworld")){ObjectName[] componentRuntime = getComponentRuntimes(applicationRT[y]);int length_component = (int)componentRuntime.length;System.out.println("length_component==" + length_component);for(int z = 0;z<length_component;z++){String type = (String)connection.getAttribute(componentRuntime[z], "Type");if(type.equals("WebAppComponentRuntime")){int SessionsOpenedTotalCount = (int)connection.getAttribute(componentRuntime[z], "SessionsOpenedTotalCount");System.out.println("SessionsOpenedTotalCount==" + SessionsOpenedTotalCount);int openSessionsHighCount = (int)connection.getAttribute(componentRuntime[z], "OpenSessionsHighCount");System.out.println("openSessionsHighCount==" + openSessionsHighCount);int openSessionsCurrentCount = (int)connection.getAttribute(componentRuntime[z], "OpenSessionsCurrentCount");System.out.println("openSessionsCurrentCount==" + openSessionsCurrentCount);break;}}break;}}}}public void printNameAndState() throws Exception {ObjectName[] serverRT = getServerRuntimes();System.out.println("got server runtimes");int length = (int) serverRT.length;for (int i = 0; i < length; i++) {String name = (String) connection.getAttribute(serverRT[i],"Name");String state = (String) connection.getAttribute(serverRT[i],"State");long activationTime = (Long)connection.getAttribute(serverRT[i], "ActivationTime");System.out.println("Server name: " + name);System.out.println("Server state:" + state);System.out.println("Server activationTime:" + activationTime);String weblogicVersion = (String) connection.getAttribute(serverRT[i], "WeblogicVersion");System.out.println("Server weblogicVersion:" + weblogicVersion);String weblogicHome = (String) connection.getAttribute(serverRT[i], "WeblogicHome");System.out.println("Server WeblogicHome:" +weblogicHome );}}public static void main(String[] args) throws Exception {String hostname = "10.111.131.50";String portString = "7001";String username = "weblogic";String password = "weblogic123";PrintServerState s = new PrintServerState();initConnection(hostname, portString, username, password);s.printNameAndState();s.printSessionState();connector.close();}} 4、有关serverlet的监控:package test;import java.io.IOException;import .MalformedURLException;import java.util.Hashtable;import javax.management.MBeanServerConnection;import javax.management.MalformedObjectNameException;import javax.management.ObjectName;import javax.management.remote.JMXConnector;import javax.management.remote.JMXConnectorFactory;import javax.management.remote.JMXServiceURL;import javax.naming.Context;public class PrintServerlet {private static MBeanServerConnection connection;private static JMXConnector connector;private static final ObjectName service;private final String applicationName_app="helloworld";private final String serverletName1="index.jsp";private final String serverletName2="helloworld.jsp";static {try {service = new ObjectName("com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean"); }catch (MalformedObjectNameException e) {throw new AssertionError(e.getMessage());}}public static void initConnection(String hostname, String portString,String username, String password) throws IOException,MalformedURLException {String protocol = "t3";Integer portInteger = Integer.valueOf(portString);int port = portInteger.intValue();String jndiroot = "/jndi/";String mserver = "weblogic.management.mbeanservers.domainruntime";JMXServiceURL serviceURL = new JMXServiceURL(protocol, hostname,port, jndiroot + mserver);Hashtable h = new Hashtable();h.put(Context.SECURITY_PRINCIPAL, username);h.put(Context.SECURITY_CREDENTIALS, password);h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,"weblogic.management.remote");connector = JMXConnectorFactory.connect(serviceURL, h);connection = connector.getMBeanServerConnection();}public static ObjectName[] getServerRuntimes() throws Exception {return (ObjectName[]) connection.getAttribute(service,"ServerRuntimes");}public String getApplicationName(ObjectName objectName) throws Exception {return (String)connection.getAttribute(objectName, "Name");}public String getServletName(ObjectName objectName) throws Exception {return (String)connection.getAttribute(objectName,"Name");}public void getServletData() throws Exception {ObjectName[] serverRT = getServerRuntimes();int length = (int) serverRT.length;for (int i = 0; i < length; i++) {ObjectName[] appRT =(ObjectName[]) connection.getAttribute(serverRT[i],"ApplicationRuntimes");int appLength = (int) appRT.length;for (int x = 0; x < appLength; x++) {String applicationName = getApplicationName(appRT[x]);if(applicationName_app.equals(applicationName)){System.out.println("Application name: " + applicationName);ObjectName[] compRT =(ObjectName[]) connection.getAttribute(appRT[x],"ComponentRuntimes");int compLength = (int) compRT.length;for (int y = 0; y < compLength; y++) {printValue("Component name",(String)connection.getAttribute(compRT[y], "Name"));String componentType =(String) connection.getAttribute(compRT[y], "Type");System.out.println(componentType.toString());if (componentType.toString().equals("WebAppComponentRuntime")){ObjectName[] servletRTs = (ObjectName[])connection.getAttribute(compRT[y], "Servlets");int servletLength = (int) servletRTs.length;for (int z = 0; z < servletLength; z++) {String servletName = getServletName(servletRTs[z]);if (servletName.contains(serverletName1) || servletName.contains(serverletName2)){ printValue("Servlet name",servletName);printValue("Servlet context path" ,(String)connection.getAttribute(servletRTs[z],"ContextPath"));printValue("Invocation Total Count" ,(Object)connection.getAttribute(servletRTs[z],"InvocationTotalCount"));printValue("ExecutionTimeHigh",(Object)connection.getAttribute(servletRTs[z],"ExecutionTimeHigh"));printValue("ExecutionTimeTotal",(Object)connection.getAttribute(servletRTs[z],"ExecutionTimeTotal"));printValue("ExecutionTimeAverage",(Object)connection.getAttribute(servletRTs[z], "ExecutionTimeAverage"));}}}}}}}}private void printValue(String key,Object value){System.out.println(" " + key + " : " + value);}public static void main(String[] args) throws Exception {String hostname = "10.111.131.50";String portString = "7001";String username = "weblogic";String password = "weblogic123";PrintServerlet s = new PrintServerlet();initConnection(hostname, portString, username, password); s.getServletData();connector.close();}}。
电力营销系统WEBLOGIC 监控方案
SNMP 是标准的网络管理协议,所有的标准厂商的设备(硬件、应用中间件)都支持这 个协议标准,提供了各种设备的 MIB 信息库,以便于监控系统软件通过设备 MIB 库直接
获取底层性能数据, 达到实时监控的目的。
目前支持SNMP 监控采集的第三方软件很多,
但大都需要购买,而且有被管机的数量限制。
基于这种现状,我们实现采用 ORACLE 开发JAVA 过程(完全支持SNMP ),通过SNMP 协议直接获取 WEBLOGIC 的实时性能数据,进而入库,然后通过开源报表工具
iReport 展
示图形报表(可以开发成图形报表展示系统)。
以及通过实时分析 WEBLOGIC 的性能数据、 设定相应的阀值,短信告警给相应人员及时处理的监控方案。
经过详细测试,这种监控方案具有高性能处理能力、不需要在被监控设备部署 AGENT
代理、被监控设备无性能损耗、设备及指标配置灵活、安装配置简单、稳定安全等优点。
1、WEBLOGIC 控制台开启SNMP 协议
监控的WEBLOGIC!要开启SNMF 协、议,其中配置相当简单,只需要在相应的控制台中, 将SNMF 协议选中打勾即可,如下图示:
U«;i= F 旳 5;y tofr-i'- P &nd 7^-ry fr 仪 511.MP 比咔r 才 t 箕汁F r /rerr dwg 匚 Ser.-^ itr- -
WEBLOGIC 以使配置生效(注意需要在无应用的情况下重启
^eaiilFn Real™ 會 DiB^nOWCt Sfl 刊旺
:冷旷韦和;淞J
■=$ 划呼帼Cr-R£M^ i AW l
wen [n 力
Context
□ $11 MP Afent
Frci^fi
Momt&r5 輕 Menren ■^iranig Me n grii o^intsr tur-G : -tint ji#
口电亚nmid 血 How dm L_ 'Ti*« I ~ LlldNudl
rhi-,WKi ur-
声
MJ
、
•■, Merit Infta.. The T^-imitrn ■■ -mber cf se- smcE that the SNMP t:
£JU -> ■苗*JJ Ohti ・#叱 jiJnianL Inf 口 TA :~I 託iw (M ・;. Mfim
E 著 i*u ~ pl 丄 Md u eaikuKvti?
吨肝.nl M kW-' Th* Ji •&
dll..
!-=■•■ eis M L ■■? JJ-^?
TM pnw^srd i
rjHi# tt"驕 怦u — ‘谒卜 T.rir i -jpr ;
:nfn rHLrr art* fffl
l”」g r*
Adm * car hwi « Simsle fteb - srk PreiatBi (SUM* . 枠n that b 曲p “谥三昌U 的!! Io SlMf
激活更改后,需要重启
WEBLOGI 以免影响生产)
■- ■ I ■ ■; -J ' • F h • J
1
c
J
Dufiwai StruCLurK
.'ahf >iiii
-£rMTQinrntnt
V*M
翱吗 Sg FWil
2、JDBC性能数据实时监控报表2.1、JDBC当前等待连接数
2.2、JDBC当前连接数
2.3、JDBC活动连接数
1 -
0 ---------------------------------------------------------------------------------------------------------------------------------------
00 01 UQ 03 04 U5 06 GT oa 09 10 11 12 13 14 17 1B 19
JDBC加i.泄詁」」宫扭如numbei询m即
从图中可以看到,昨天每小时的JDBC活动连接数有波动,可以看到在
连接数较高,可能是有定时任务在这个时间点执行。
2.4、JDBC可用连接数
1) ------------------------------------------------------------------------------------------------------------------------------------------------------
DO D1 02 03 W 05 06 07 09 10 11 12 13 14 15 17 16 19
■
JDfiCii^池町川辻按樹mmh初tin曰
从图中可以看到,昨天每小时的JDBC可用连接数有波动,可以看到在可用连接
数最高。
2 •
2f 22 23
1点的时候活动
21 23
9点到10点间的
2.5、JDBC连接平均等待时间
«- JDBCA f 14II-. ilimsline)
从图中可以看到,昨天每小时的JDBC连接平均等待时间有波动,可以看到在11点的时候业务处理等待时间较高。
2.6、JDBC失败请求连接数
2.7、JDBC有效连接数
0 J-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
OO 01 02 M 04 05 0* 07 (W OS 10 11 12 1J 14 15 仃16 19 20 21 22 23
-• JD6C连啜剋听性准症規〔number川me)
从图中可以看到,昨天每小时的JDBC有效连接数有波动,可以看到在9点业务最繁忙的时候有效连接数最高。
2.8、JDBC总连接数
oo oi 02 oa <M os oe o? DS oa 10 n 12 13 H15 17 16 19 20 21 22 23
■■ JDBC 生氓ilL.J连按駐〔numteiAm对
325
300
275 -
250
225
200
175-
ISO
125
1 (JO-
75
50
25
0-
从图中可以看到,昨天每小时的JDBC总连接数有波动,可以看到在9点的时候总的连接数最高。
2.9、JDBC最大活动连接数
从图中可以看到,昨天每小时的JDBC最大活动连接数有波动,可以看到在11点到15点间活动连接数处于较低水平,说明这个时间业务处理并不繁忙。
3、总结。