相信大家对loadrunner应该十分熟悉了,所以在这里,我大概介绍下sitescope的安装和使用。
监测mysql需要使用到jdbc驱动程序,为了让sitescope能够监测到 mysql。下载地址:http://www.mysql.com/downloads/connector/j/
下载成功后,解压文件,把“mysql-connector-java-5.1.12-bin.jar”这个压缩文件复制到(sitescope安装目录下)sitescope\java\lib\ext下,重启系统。
进入sitescope主界面,点击“create group”,输入自定义的组名,即可成功添加group。
进入新建的组,在“add to group”一栏下点击monitor,新添加monitor。
然后“add database query monitor”。
这里是关键:
database connection url:jdbc:mysql://<database hostname>[:<tcp port>]/<database>
for example:要连接mysql的数据库abigdatabase,用mysql的标准端口3306,则为 jdbc:mysql://206.168.191.19/abigdatabase
query:show status where variable_name like ’innodb_buffer_pool_pages_total’
database driver:org.gjt.mm.mysql.driver
updates时间和title可以根据自己的需要设置。
点击“add”,保存即可。到此为止,sitescope已经能够监测到数据的信息了。接下去是连接loadrunner。
打开 loadrunner的controller,在“run”中添加“sitescope”,即可成功监测到被测数据库的信息了。哈哈,大功告成了!!!
备注:
sitescope利用database query monitor监控指定的数据库,通过sitescope监控器的show status命令,获得相应数据,命令如下:
show status where variable_name like ’innodb_buffer_pool_pages_total’
为了确保监控请确认loadrunner and sitescope之间的端口, sitescope和mysql必须打开tcp 8888和tcp 3306 . 还有sitescope要监控必须要确保有jdbc的安装。
以下为监控前需要注意的地方:
1. sitescope to be deployed.
2. sufficient license points for database query monitor.
3. tcp 8888 (default) opened two-way for loadrunner to sitescope.
4. tcp 3306 (default) opened two-way for sitescope to mysql.
5. monitoring privileges for sitescope to monitor mysql.
6. jdbc driver to be installed on sitescope.
7. have knowledge of the counter you want to monitor.
// mysql_dll.cpp : defines the entry point for the dll application.
#include "stdafx.h"
#include "stdlib.h"
mysql *conn=null;
mysql_res *p_res_ptr=null;
mysql_row sqlrows;
bool apientry dllmain( handle hmodule,
dword ul_reason_for_call,
lpvoid lpreserved
)
{
return true;
}
extern "c" int _declspec(dllexport) init_mysql_connection(char *str_server,char *str_username,char *str_pwd,char *str_table)
conn=mysql_init(null);
if(!conn)
printf("\nfailed to initate mysql connection");
return 1;
exit(0);
else
printf("\nsuccess to initate mysql connection");
if (!mysql_real_connect(conn,str_server,str_username,str_pwd,str_table,0,null,0))
{
printf( "failed to connect to mysql: error: %s\n", mysql_error(conn));
}
else
printf("\nlogged on to %s sucessfully",str_server);
return 0;
return 0;
extern "c" int _declspec(dllexport) close_mysql_connection()
if(conn=null)
printf("\nconnection is null");
else
mysql_free_result(p_res_ptr);
printf("\nclose connection");
mysql_close(conn);
//"show status like \'qcache%\'"
extern "c" int _declspec(dllexport) get_mysql_table_query(char *str_query)
int res=0;
res=mysql_query(conn,str_query);
if(res)
printf("failed to mysql query: error: %s\n", mysql_error(conn));
printf("\nsucess in mysql query");
extern "c" int _declspec(dllexport) get_mysql_query_data(char *str_query,char *str_data)
unsigned long u1_numrow=0;
unsigned int i_index = 0;
p_res_ptr=mysql_use_result(conn);
if(p_res_ptr){
while((sqlrows=mysql_fetch_row(p_res_ptr))){
if(*sqlrows[0]=*str_query)
{
strcpy(str_data,sqlrows[1]);
}
return null;
action()
int i=0;
double x;
char *str_data;
str_data=(char *)malloc(20*sizeof(char));
lr_load_dll("d:\\vc\\mysql_dll\\debug\\mysql_dll.dll");
i= init_mysql_connection("localhost","root","123456","mysql");
lr_output_message("%d",i);
for(;;)
{
get_mysql_query_data("qcache_hits",str_data);
i=get_mysql_table_query("show status like \'qcache%\'");
lr_output_message("%d",i);
x = atof(str_data);
lr_user_data_point("hits",x);
lr_think_time(5);
}
lr_output_message("%d",x);
close_mysql_connection();
return 0;
====================================分割线================================
最新内容请见作者的github页:http://qaseven.github.io/