thinking

          one platform thousands thinking

          LoadRunner監(jiān)控Tomcat的幾種方法(轉(zhuǎn)自csdn,陳能技ID:Testing_is_believing)

          LoadRunner監(jiān)控Tomcat的幾種方法(轉(zhuǎn)自csdn,陳能技ID:Testing_is_believing)

          通過JConsole監(jiān)控Tomcat

          1、打開tomcat5bin目錄中的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遠(yuǎn)程訪問授權(quán)。

          進(jìn)入JAVA安裝目錄的"jre6"lib"management目錄,把jmxremote.password.template文件改名為jmxremote.password,去掉最后兩行的注釋(用戶名和密碼):

          monitorRole  QED

          controlRole   R&D

          確保jmxremote.access文件末尾的訪問角色沒有被注釋掉:

          monitorRole   readonly

          controlRole   readwrite "

                        create javax.management.monitor.*,javax.management.timer.* "

                        unregister

          然后分別選擇這兩個(gè)文件,點(diǎn)右鍵“屬性”-〉安全,點(diǎn)“高級(jí)”,去掉“從父項(xiàng)繼承....”,彈出窗口中選“刪除”,這樣刪除了所有訪問權(quán)限。再選“添加”-〉高級(jí),“立即查找”,選中你的用戶,例administrator,點(diǎn)“確定",“確定"。來到權(quán)限窗口,勾選"完全控制",點(diǎn)"確定"

          注:JDK好像需要裝在NTFS文件系統(tǒng)下才行

          3、啟動(dòng)Tomcat

          4、在命令行輸入netstat -an 查看端口8999是否已經(jīng)打開,如果沒有,則是前面的配置沒配好。

          5、如果已經(jīng)配置好,則在命令行輸入jconsole,打開jdk自帶的JMX客戶端,選擇遠(yuǎn)程連接,錄入tomcat所在機(jī)器的IP,端口例192.168.1.100:8999,帳號(hào)、密碼在jmxremote.password中,如帳號(hào)controlRole,密碼R&D(缺省monitorRole只能讀,controlRole能讀寫,jmxremote.access中可配置)。點(diǎn)“連接”。

          參考:

          http://blog.csdn.net/airobot008/archive/2009/03/03/3951524.aspx

          編寫JAVA程序收集Tomcat性能數(shù)據(jù)

          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;

          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();  

                       

                     //端口最好是動(dòng)態(tài)取得  

                     ObjectName threadObjName = new ObjectName("Catalina:type=ThreadPool,name=http-8080");  

                     MBeanInfo mbInfo = mbsc.getMBeanInfo(threadObjName);  

                       

                     String attrName = "currentThreadCount";//tomcat的線程數(shù)對(duì)應(yīng)的屬性值  

                     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(nullnull);  

                     System.out.println("MBeanset.size() : " + MBeanset.size());  

                     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("啟動(dòng)時(shí)間:"+df.format(starttime));  

                       

                     Long timespan=(Long)mbsc.getAttribute(runtimeObjName, "Uptime");  

                     System.out.println("連續(xù)工作時(shí)間:"+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();//堆當(dāng)前分配  

                     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"));             

                     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<ObjectName> s=mbsc.queryNames(managerObjName, null);  

                     for (ObjectName obj:s){  

                         System.out.println("應(yīng)用名:"+obj.getKeyProperty("path"));  

                         ObjectName objname=new ObjectName(obj.getCanonicalName());  

                         System.out.println("最大會(huì)話數(shù):"+ mbsc.getAttribute( objname"maxActiveSessions"));  

                         System.out.println("會(huì)話數(shù):"+ mbsc.getAttribute( objname"activeSessions"));  

                         System.out.println("活動(dòng)會(huì)話數(shù):"+ mbsc.getAttribute( objname"sessionCounter"));  

                     }  

                       

                     //----------------- Thread Pool ----------------  

                     ObjectName threadpoolObjName = new ObjectName("Catalina:type=ThreadPool,*");  

                     Set<ObjectName> s2=mbsc.queryNames(threadpoolObjName, null);  

                     for (ObjectName obj:s2){  

                         System.out.println("端口名:"+obj.getKeyProperty("name"));  

                         ObjectName objname=new ObjectName(obj.getCanonicalName());  

                         System.out.println("最大線程數(shù):"+ mbsc.getAttribute( objname, "maxThreads"));  

                         System.out.println("當(dāng)前線程數(shù):"+ mbsc.getAttribute( objname, "currentThreadCount"));  

                         System.out.println("繁忙線程數(shù):"+ 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;  

                  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();  

              }  

          }

          記錄的數(shù)據(jù):

          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

          啟動(dòng)時(shí)間:2010-02-09 11:36:59

          連續(xù)工作時(shí)間:0 00:13:55.775

          heap:62.221410820735%

          nonheap:84.59782727899399%

          perm gen:210.93058268229166%

          應(yīng)用名:/jsp-examples

          最大會(huì)話數(shù):-1

          會(huì)話數(shù):0

          活動(dòng)會(huì)話數(shù):0

          應(yīng)用名:/

          最大會(huì)話數(shù):-1

          會(huì)話數(shù):0

          活動(dòng)會(huì)話數(shù):0

          應(yīng)用名:/host-manager

          最大會(huì)話數(shù):-1

          會(huì)話數(shù):0

          活動(dòng)會(huì)話數(shù):0

          應(yīng)用名:/tomcat-docs

          最大會(huì)話數(shù):-1

          會(huì)話數(shù):0

          活動(dòng)會(huì)話數(shù):0

          應(yīng)用名:/AltoroJ

          最大會(huì)話數(shù):-1

          會(huì)話數(shù):301

          活動(dòng)會(huì)話數(shù):301

          應(yīng)用名:/webdav

          最大會(huì)話數(shù):-1

          會(huì)話數(shù):0

          活動(dòng)會(huì)話數(shù):0

          應(yīng)用名:/servlets-examples

          最大會(huì)話數(shù):-1

          會(huì)話數(shù):0

          活動(dòng)會(huì)話數(shù):0

          應(yīng)用名:/manager

          最大會(huì)話數(shù):-1

          會(huì)話數(shù):0

          活動(dòng)會(huì)話數(shù):0

          應(yīng)用名:/balancer

          最大會(huì)話數(shù):-1

          會(huì)話數(shù):0

          活動(dòng)會(huì)話數(shù):0

          端口名:http-8080

          最大線程數(shù):150

          當(dāng)前線程數(shù):150

          繁忙線程數(shù):100

          端口名:jk-8009

          最大線程數(shù):200

          當(dāng)前線程數(shù):4

          繁忙線程數(shù):1

          參考:

          http://blog.csdn.net/airobot008/archive/2009/03/03/3951524.aspx

          使用LRlr_user_data_point函數(shù)

          // 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");

                 /*

                 <h1>JVM</h1><p> Free memory: 130.99 MB Total memory: 254.18 MB Max memory: 1016.12 MB</p>

                 */

                 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);

                 /*

                 <h1>http-8080</h1><p> Max threads: 150 Min spare threads: 25 Max spare threads: 75 Current

                 thread count: 25 Current thread busy: 2<br>

                 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</p>

                 */

                 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: ",

                        "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",

                        LAST);

                 /*

                 <h1>jk-8009</h1><p> Max threads: 200 Min spare threads: 4 Max spare threads: 50 Current thread count: 8 Current thread busy: 6

                 <br> 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</p>

              */

                 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",

                        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

                 /*

                 <table border="1" cellspacing="0" cellpadding="3">

                 <tr>

                  <td colspan="6" class="title">Server Information</td>

                 </tr>

                 <tr>

                  <td class="header-center"><small>Tomcat Version</small></td>

                  <td class="header-center"><small>JVM Version</small></td>

                  <td class="header-center"><small>JVM Vendor</small></td>

                  <td class="header-center"><small>OS Name</small></td>

                  <td class="header-center"><small>OS Version</small></td>

                  <td class="header-center"><small>OS Architecture</small></td>

                 </tr>

                 <tr>

                  <td class="row-center"><small>Apache Tomcat/5.5.23</small></td>

                  <td class="row-center"><small>1.5.0_15-b04</small></td>

                  <td class="row-center"><small>Sun Microsystems Inc.</small></td>

                  <td class="row-center"><small>Windows 2003</small></td>

                  <td class="row-center"><small>5.2</small></td>

                  <td class="row-center"><small>x86</small></td>

                 </tr>

                 </table>

                 */

                 web_reg_save_param("ServerTomcatVersion",

                        "LB=<td class=""row-center""><small>",

                        "RB=</small></td>",

                        "Ord=1",

                        LAST);

                 web_reg_save_param("ServerJVMVersion",

                        "LB=<td class=""row-center""><small>",

                        "RB=</small></td>",

                        "Ord=2",

                        LAST);

                 web_reg_save_param("ServerJVMVendor",

                        "LB=<td class=""row-center""><small>",

                        "RB=</small></td>",

                        "Ord=3",

                        LAST);

                 web_reg_save_param("ServerOSName",

                        "LB=<td class=""row-center""><small>",

                        "RB=</small></td>",

                        "Ord=4",

                        LAST);

                 web_reg_save_param("ServerOSVersione",

                        "LB=<td class=""row-center""><small>",

                        "RB=</small></td>",

                        "Ord=5",

                        LAST);

                 web_reg_save_param("ServerOSArchitecture",

                        "LB=<td class=""row-center""><small>",

                        "RB=</small></td>",

                        "Ord=6",

                        LAST);

          /*

                 // 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=<table border=""0""><tr><th>Stage</th><th>Time</th><th>B Sent</th><th>B Recv</th><th>Client</th><th>VHost</th><th>Request</th></tr>", //<tr><th>Stage", //</th><th>Time</th><th>B Sent</th><th>B Recv</th><th>Client</th><th>VHost</th><th>Request</th></tr><tr>",

                        "RB=</table>",

                        "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("{HTTPMaxProcessingTime}")));

                 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}")));

                 lr_user_data_point("Tomcat JK Error count", atof(lr_eval_string("{JKErrorCount}")));

                 lr_user_data_point("Tomcat JK Bytes received", atof(lr_eval_string("{JKBytesReceived}")));

                 lr_user_data_point("Tomcat JK Bytes sent", atof(lr_eval_string("{JKBytesSent}")));

                

                 // Determine number of threads in each state.

                 // Note that there is some complexity in doing this (see code below)...

                 // P: Parse and prepare request S: Service F: Finishing R: Ready K: Keepalive

              if (strcmp(lr_eval_string("{StageTable_count}"), "2") != 0) { // Verify that there are only two tables.

                        lr_error_message("Monitoring script expected 2 tables of thread metrics, but instead found %s", lr_eval_string("{StageTable_count}"));

                 } else {   // extract the P, S, F, R, and K values from both the tables.

                        // check that there are only 2 tables. Raise an error if there is not...

                        //lr_save_searched_string(const char *buffer, long buf_size, unsigned int occurrence, const char *search_string, int offset, unsigned int string_len, const char *parm_name );

                        // maybe should use strtok for this.

                        //strtok

                        // lr_xml_get_values

                  lr_output_message("%s", lr_eval_string("{StageTable_1}"));

                        numValues= lr_xml_get_values("XML={StageTable_1}",

                               "ValueParam=OutputParam",

                               "Query=/tr/td/strong/*",

                               "SelectAll=yes", LAST);

                 }

                 // Log Tomcat/JVM version info on the first iteration only.

                 if (loggedVersionInfo != TRUE) {

                        lr_log_message("****** Test Environment Information ******");

                        lr_log_message("%s", lr_eval_string("Tomcat: {ServerTomcatVersion}"));

                        lr_log_message("%s", lr_eval_string("JVM: {ServerJVMVersion} {ServerJVMVendor}"));

                        lr_log_message("%s", lr_eval_string("Operating System: {ServerOSName} {ServerOSVersione} {ServerOSArchitecture}"));

                        lr_log_message("******************************************");

                        loggedVersionInfo = TRUE;

                 }

                

                 return 0;

          }

          參考:

          http://www.jds.net.au/tech-tips/monitoring-tomcat/

          使用SiteScope監(jiān)控Tomcat

          1、安裝SiteScope

          LR9.5的安裝包中附帶了SiteScope9.5的安裝文件

          "Additional Components"Sitescope"SiteScope 9.50

          2、配置SiteScope

          新建監(jiān)視器,選擇JMX類別

          輸入TomcatJMX URL地址,例如:

          service:jmx:rmi:///jndi/rmi://192.168.1.100:8999/jmxrmi

          用戶名:monitorRole

          密碼:QED

          添加計(jì)數(shù)器,例如:

          java.lang/Memory/HeapMemoryUsage/used

          java.lang/Memory/HeapMemoryUsage/max

          Catalina/ThreadPool/jk-8010/currentThreadCount

          Catalina/ThreadPool/jk-8010/maxSpareThreads

          Catalina/ThreadPool/jk-8010/minSpareThreads

          然后就可以在LRController中連接SiteScope對(duì)Tomcat進(jìn)行監(jiān)控。

          posted on 2010-10-19 18:13 lau 閱讀(1346) 評(píng)論(0)  編輯  收藏 所屬分類: Test


          只有注冊用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 高雄市| 久治县| 于都县| 南城县| 南涧| 那坡县| 桃江县| 青田县| 织金县| 克拉玛依市| 高陵县| 阿坝县| 阿合奇县| 青龙| 武威市| 依安县| 厦门市| 灵丘县| 邹城市| 甘德县| 丰顺县| 密云县| 沙湾县| 贡嘎县| 新蔡县| 铜陵市| 读书| 云林县| 合肥市| 贡嘎县| 张家口市| 南充市| 恭城| 如皋市| 新密市| 尉犁县| 郎溪县| 宁阳县| 曲阜市| 高邮市| 桐乡市|