欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    2022年LoadRunner监控Tomcat的几种方法 .pdf

    • 资源ID:35292703       资源大小:129.10KB        全文页数:16页
    • 资源格式: PDF        下载积分:4.3金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要4.3金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    2022年LoadRunner监控Tomcat的几种方法 .pdf

    LoadRunner监控 Tomcat的几种方法通过 JConsole监控 Tomcat1、打开 tomcat5 的 bin 目录中的 catalina.bat文件,在头部注释部分的后面加上:set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=8999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false 2、修改 JMX 远程访问授权。进入JAVA安装目录的 jre6libmanagement目录,把 jmxremote.password.template文件改名为jmxremote.password,去掉最后两行的注释(用户名和密码):monitorRole QED controlRole R&D 确保 jmxremote.access文件末尾的访问角色没有被注释掉:monitorRole readonly controlRole readwrite create javax.management.monitor.*,javax.management.timer.* unregister 然后分别选择这两个文件,点右键“ 属性 ” -安全,点 “ 高级 ” ,去掉 “ 从父项继承 .”,弹出窗口中选“ 删除” ,这样删除了所有访问权限。再选“ 添加 ” -高级, “ 立即查找 ” ,选中你的用户,例administrator ,点 “ 确定,“ 确定 。来到权限窗口,勾选完全控制 ,点 确定 注: JDK 好像需要装在NTFS 文件系统下才行3、启动 Tomcat 4、在命令行输入netstat -an 查看端口 8999 是否已经打开,如果没有,则是前面的配置没配好。5、如果已经配置好,则在命令行输入jconsole ,打开 jdk 自带的 JMX 客户端,选择远程连接,录入tomcat 所在机器的IP,端口例 192.168.1.100:8999,帐号、密码在jmxremote.password中,如帐号controlRole ,密码 R&D(缺省 monitorRole只能读, controlRole 能读写, jmxremote.access中可配置) 。点“ 连接” 。编写 JAVA 程序收集Tomcat性能数据import java.lang.management.MemoryUsage; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Formatter; import java.util.HashMap; import java.util.Iterator; import java.util.Map; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 16 页 - - - - - - - - - import java.util.Set; import javax.management.MBeanAttributeInfo; import javax.management.MBeanInfo; import javax.management.MBeanServerConnection; import javax.management.ObjectInstance; import javax.management.ObjectName; import javax.management.openmbean.CompositeDataSupport; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; public class MonitorTomcat /* * param args */ public static void main(String args) try String jmxURL = service:jmx:rmi:/jndi/rmi:/192.168.1.100:8999/jmxrmi;/tomcat jmx url JMXServiceURL serviceURL = new JMXServiceURL(jmxURL); Map map = new HashMap(); String credentials = new String monitorRole , QED ; map.put(jmx.remote.credentials, credentials); JMXConnector connector = JMXConnectorFactory.connect(serviceURL, map); MBeanServerConnection mbsc = connector.getMBeanServerConnection(); /端口最好是动态取得 ObjectName threadObjName = new ObjectName(Catalina:type=ThreadPool,name=http-8080); MBeanInfo mbInfo = mbsc.getMBeanInfo(threadObjName); String attrName = currentThreadCount;/tomcat的线程数对应的属性值 MBeanAttributeInfo mbAttributes = mbInfo.getAttributes(); System.out.println(currentThreadCount:+mbsc.getAttribute(threadObjName, attrName); /heap for(int j=0;j mbsc.getDomains().length;j+) System.out.println(#+mbsc.getDomains()j); Set MBeanset = mbsc.queryMBeans(null, null); System.out.println(MBeanset.size() : + MBeanset.size(); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 16 页 - - - - - - - - - Iterator MBeansetIterator = MBeanset.iterator(); while (MBeansetIterator.hasNext() ObjectInstance objectInstance = (ObjectInstance)MBeansetIterator.next(); ObjectName objectName = objectInstance.getObjectName(); String canonicalName = objectName.getCanonicalName(); System.out.println(canonicalName : + canonicalName); if (canonicalName.equals(Catalina:host=localhost,type=Cluster) / Get details of cluster MBeans System.out.println(Cluster MBeans Details:); System.out.println(=); /getMBeansDetails(canonicalName); String canonicalKeyPropList = objectName.getCanonicalKeyPropertyListString(); /- system - ObjectName runtimeObjName = new ObjectName(java.lang:type=Runtime); System.out.println(厂商:+ (String)mbsc.getAttribute(runtimeObjName, VmVendor); System.out.println(程序:+ (String)mbsc.getAttribute(runtimeObjName, VmName); System.out.println(版本:+ (String)mbsc.getAttribute(runtimeObjName, VmVersion); Date starttime=new Date(Long)mbsc.getAttribute(runtimeObjName, StartTime); SimpleDateFormat df = new SimpleDateFormat(yyyy-MM-dd HH:mm:ss); System.out.println(启动时间 :+df.format(starttime); Long timespan=(Long)mbsc.getAttribute(runtimeObjName, Uptime); System.out.println(连续工作时间 :+MonitorTomcat.formatTimeSpan(timespan); /- JVM - /堆使用率 ObjectName heapObjName = new ObjectName(java.lang:type=Memory); MemoryUsage heapMemoryUsage = MemoryUsage.from(CompositeDataSupport)mbsc.getAttribute(heapObjName, HeapMemoryUsage); long maxMemory = heapMemoryUsage.getMax();/堆最大 long commitMemory = heapMemoryUsage.getCommitted();/堆当前分配 long usedMemory = heapMemoryUsage.getUsed(); System.out.println(heap:+(double)usedMemory*100/commitMemory+%);/堆使用率 MemoryUsage nonheapMemoryUsage = MemoryUsage.from(CompositeDataSupport)mbsc.getAttribute(heapObjName, NonHeapMemoryUsage); long noncommitMemory = nonheapMemoryUsage.getCommitted(); long nonusedMemory = heapMemoryUsage.getUsed(); System.out.println(nonheap:+(double)nonusedMemory*100/noncommitMemory+%); ObjectName permObjName = new ObjectName(java.lang:type=MemoryPool,name=Perm Gen); MemoryUsage permGenUsage = MemoryUsage.from(CompositeDataSupport)mbsc.getAttribute(permObjName, Usage); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 16 页 - - - - - - - - - long committed = permGenUsage.getCommitted();/持久堆大小 long used = heapMemoryUsage.getUsed();/ System.out.println(perm gen:+(double)used*100/committed+%);/持久堆使用率 /- Session - ObjectName managerObjName = new ObjectName(Catalina:type=Manager,*); Set s=mbsc.queryNames(managerObjName, null); for (ObjectName obj:s) System.out.println(应用名 :+obj.getKeyProperty(path); ObjectName objname=new ObjectName(obj.getCanonicalName(); System.out.println(最大会话数 :+ mbsc.getAttribute( objname, maxActiveSessions); System.out.println(会话数 :+ mbsc.getAttribute( objname, activeSessions); System.out.println(活动会话数 :+ mbsc.getAttribute( objname, sessionCounter); /- Thread Pool - ObjectName threadpoolObjName = new ObjectName(Catalina:type=ThreadPool,*); Set s2=mbsc.queryNames(threadpoolObjName, null); for (ObjectName obj:s2) System.out.println(端口名 :+obj.getKeyProperty(name); ObjectName objname=new ObjectName(obj.getCanonicalName(); System.out.println(最大线程数 :+ mbsc.getAttribute( objname, maxThreads); System.out.println(当前线程数 :+ mbsc.getAttribute( objname, currentThreadCount); System.out.println(繁忙线程数 :+ mbsc.getAttribute( objname, currentThreadsBusy); catch (Exception e) e.printStackTrace(); public static String formatTimeSpan(long span) long minseconds = span % 1000; span = span /1000; long seconds = span % 60; span = span / 60; long mins = span % 60; span = span / 60; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 16 页 - - - - - - - - - long hours = span % 24; span = span / 24; long days = span; return (new Formatter().format(%1$d天 %2$02d:%3$02d:%4$02d.%5$03d, days,hours,mins,seconds,minseconds).toString(); 记录的数据:currentThreadCount:150 #JMImplementation #Users #com.sun.management #Catalina #java.lang #java.util.logging MBeanset.size() : 383 canonicalName : Catalina:name=HttpRequest152,type=RequestProcessor,worker=http-8080 canonicalName : Catalina:J2EEApplication=none,J2EEServer=none,WebModule=/localhost/jsp-examples,j2eeType=Servlet,name=org.apache.jsp.jsp2.el.basic_002dcomparisons_jsp canonicalName : Catalina:port=8009,type=Mapper canonicalName : Catalina:J2EEApplication=none,J2EEServer=none,WebModule=/localhost/jsp-examples,j2eeType=Servlet,name=org.apache.jsp.dates.date_jsp 厂商 :Sun Microsystems Inc. 程序 :Java HotSpot(TM) Client VM 版本 :11.3-b02 启动时间 :2010-02-09 11:36:59 连续工作时间 :0 天 00:13:55.775 heap:62.221410820735% nonheap:84.59782727899399% perm gen:210.93058268229166% 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 16 页 - - - - - - - - - 应用名 :/jsp-examples 最大会话数 :-1 会话数 :0 活动会话数 :0 应用名 :/ 最大会话数 :-1 会话数 :0 活动会话数 :0 应用名 :/host-manager 最大会话数 :-1 会话数 :0 活动会话数 :0 应用名 :/tomcat-docs 最大会话数 :-1 会话数 :0 活动会话数 :0 应用名 :/AltoroJ 最大会话数 :-1 会话数 :301 活动会话数 :301 应用名 :/webdav 最大会话数 :-1 会话数 :0 活动会话数 :0 应用名 :/servlets-examples 最大会话数 :-1 会话数 :0 活动会话数 :0 应用名 :/manager 最大会话数 :-1 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 16 页 - - - - - - - - - 会话数 :0 活动会话数 :0 应用名 :/balancer 最大会话数 :-1 会话数 :0 活动会话数 :0 端口名 :http-8080 最大线程数 :150 当前线程数 :150 繁忙线程数 :100 端口名 :jk-8009 最大线程数 :200 当前线程数 :4 繁忙线程数 :1 使用 LR 的 lr_user_data_point函数/ This script collects server metrics from the Tomcat Status page (http:/127.0.0.1:8080/manager/status ). / Runtime settings are set to run this script once every 5 seconds. double atof (const char *string); /* Explicit declaration */ extern char* strtok(char *token, const char *delimiter); CollectMetrics() int countP, countS, countF, countR, countK; int numValues; static int loggedVersionInfo = FALSE; lr_save_string(127.0.0.1:8080, ServerName); web_set_max_html_param_len(102480); / 65536 Note: this may need to be increased. web_set_user(admin, 123456, ServerName); lr_start_transaction(monitor tomcat); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 7 页,共 16 页 - - - - - - - - - /* JVM Free memory: 130.99 MB Total memory: 254.18 MB Max memory: 1016.12 MB */ web_reg_save_param(JVMFreeMemory, LB=Free memory: , RB= MB, Ord=1, LAST); web_reg_save_param(JVMTotalMemory, LB=Total memory: , RB= MB, Ord=1, LAST); web_reg_save_param(JVMMaxMemory, LB=Max memory: , RB= MB, Ord=1, LAST); /* http-8080 Max threads: 150 Min spare threads: 25 Max spare threads: 75 Current thread count: 25 Current thread busy: 2 Max processing time: 78 ms Processing time: 0.124 s Request count: 11 Error count: 3 Bytes received: 0.00 MB Bytes sent: 0.03 MB */ web_reg_save_param(HTTPMaxThreads, LB=Max threads: , RB= , Ord=1, LAST); web_reg_save_param(HTTPMinSpareThreads, LB=Min spare threads: , RB= , Ord=1, LAST); web_reg_save_param(HTTPMaxSpareThreads, LB=Max spare threads: , 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 8 页,共 16 页 - - - - - - - - - RB= , Ord=1, LAST); web_reg_save_param(HTTPCurrentSpareThreads, LB=Current thread count: , RB= , Ord=1, LAST); web_reg_save_param(HTTPCurrentThreadBusy, LB=Current thread busy: , RB= , Ord=1, LAST); web_reg_save_param(HTTPMaxProcessingTime, LB=Max processing time: , RB= , Ord=1, LAST); web_reg_save_param(HTTPRequestCount, LB=Request count: , RB= , Ord=1, LAST); web_reg_save_param(HTTPErrorCount, LB=Error count: , RB= , Ord=1, LAST); web_reg_save_param(HTTPBytesReceived, LB=Bytes received: , RB= , Ord=1, LAST); web_reg_save_param(HTTPBytesSent, LB=Bytes sent: , RB= , Ord=1, 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 9 页,共 16 页 - - - - - - - - - LAST); /* jk-8009 Max threads: 200 Min spare threads: 4 Max spare threads: 50 Current thread count: 8 Current thread busy: 6 Max processing time: 8031 ms Processing time: 199.1 s Request count: 11279 Error count: 426 Bytes received: 0.00 MB Bytes sent: 100.88 MB */ web_reg_save_param(JKMaxThreads, LB=Max threads: , RB= , Ord=2, LAST); web_reg_save_param(JKMinSpareThreads, LB=Min spare threads: , RB= , Ord=2, LAST); web_reg_save_param(JKMaxSpareThreads, LB=Max spare threads: , RB= , Ord=2, LAST); web_reg_save_param(JKCurrentSpareThreads, LB=Current thread count: , RB= , Ord=2, LAST); web_reg_save_param(JKCurrentThreadBusy, LB=Current thread busy: , RB= , Ord=2, LAST); web_reg_save_param(JKMaxProcessingTime, LB=Max processing time: , RB= , Ord=2, 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 10 页,共 16 页 - - - - - - - - - LAST); web_reg_save_param(JKRequestCount, LB=Request count: , RB= , Ord=2, LAST); web_reg_save_param(JKErrorCount, LB=Error count: , RB= , Ord=2, LAST); web_reg_save_param(JKBytesReceived, LB=Bytes received: , RB= , Ord=2, LAST); web_reg_save_param(JKBytesSent, LB=Bytes sent: , RB= , Ord=2, LAST); / Version Information /* Server Information Tomcat Version JVM Version JVM Vendor OS Name OS Version OS Architecture Apache Tomcat/5.5.23 1.5.0_15-b04 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 11 页,共 16 页 - - - - - - - - - Sun Microsystems Inc. Windows 2003 5.2 x86 */ web_reg_save_param(ServerTomcatVersion, LB=, RB=, Ord=1, LAST); web_reg_save_param(ServerJVMVersion, LB=, RB=, Ord=2, LAST); web_reg_save_param(ServerJVMVendor, LB=, RB=, Ord=3, LAST); web_reg_save_param(ServerOSName, LB=, RB=, Ord=4, LAST); web_reg_save_param(ServerOSVersione, LB=, RB=, Ord=5, LAST); web_reg_save_param(ServerOSArchitecture, LB=, RB=, Ord=6, LAST); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 12 页,共 16 页 - - - - - - - - - /* / Determine number of threads in each state. / P: Parse and prepare request S: Service F: Finishing R: Ready K: Keepalive web_reg_save_param(StageTable, LB=StageTimeB SentB RecvClientVHostRequest, /Stage, /TimeB SentB RecvClientVHostRequest, RB=, Ord=All, / note that there should only be 2 tables in this test environment. LAST); */ web_reg_find(Text=/manager, LAST); web_url(status, URL=http:/ServerName/manager/status, Resource=0, RecContentType=text/html, Referer=, Snapshot=t1.inf, Mode=HTTP, LAST); lr_end_transaction(monitor tomcat, LR_AUTO); / Tomcat JVM metrics lr_user_data_point(Tomcat JVM Free memory, atof(lr_eval_string(JVMFreeMemory); lr_user_data_point(Tomcat JVM Total memory, atof(lr_eval_string(JVMTotalMemory); lr_user_data_point(Tomcat JVM Max memory, atof(lr_eval_string(JVMMaxMemory); / Tomcat web server metrics lr_user_data_point(Tomcat HTTP Max threads, atof(lr_eval_string(HTTPMaxThreads); /lr_user_data_point(Tomcat HTTP Min spare threads, atof(lr_eval_string(HTTPMinSpareThreads); /lr_user_data_point(Tomcat HTTP Max spare threads, atof(lr_eval_string(HTTPMaxSpareThreads); lr_user_data_point(Tomcat HTTP Current spare threads, atof(lr_eval_string(HTTPCurrentSpareThreads); lr_user_data_point(Tomcat HTTP Current thread busy, atof(lr_eval_string(HTTPCurrentThreadBusy); lr_user_data_point(Tomcat HTTP Max processing time, atof(lr_eval_string(HTTPMaxProcessing名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 13 页,共 16 页 - - - - - - - - - Time); lr_user_data_point(Tomcat HTTP Request count, atof(lr_eval_string(HTTPRequestCount); lr_user_data_point(Tomcat HTTP Error count, atof(lr_eval_string(HTTPErrorCount); lr_user_data_point(Tomcat HTTP Bytes received, atof(lr_eval_string(HTTPBytesReceived); lr_user_data_point(Tomcat HTTP Bytes sent, atof(lr_eval_string(HTTPBytesSent); / Tomcat servlet container metrics lr_user_data_point(Tomcat JK Max threads, atof(lr_eval_string(JKMaxThreads); lr_user_data_point(Tomcat JK Min spare threads, atof(lr_eval_string(JKMinSpareThreads); lr_user_data_point(Tomcat JK Max spare threads, atof(lr_eval_string(JKMaxSpareThreads); lr_user_data_point(Tomcat JK Current spare threads, atof(lr_eval_string(JKCurrentSpareThreads); lr_user_data_point(Tomcat JK Current thread busy, atof(lr_eval_string(JKCurrentThreadBusy); lr_user_data_point(Tomcat JK Max processing time, atof(lr_eval_string(JKMaxProcessingTime); lr_user_data_point(Tomcat JK Request count, atof(lr_eval_string(JKRequestCount

    注意事项

    本文(2022年LoadRunner监控Tomcat的几种方法 .pdf)为本站会员(Che****ry)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开