mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
support monitor
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
CREATE TABLE druid_datasource (
|
||||
id bigint(20) AUTO_INCREMENT NOT NULL,
|
||||
domain varchar(45) NOT NULL,
|
||||
app varchar(45) NOT NULL,
|
||||
cluster varchar(45) NOT NULL,
|
||||
host varchar(128),
|
||||
pid int(10) NOT NULL,
|
||||
collectTime datetime NOT NULL,
|
||||
name varchar(256),
|
||||
dbType varchar(256),
|
||||
driverClassName varchar(256),
|
||||
url varchar(256),
|
||||
activeCount int(10),
|
||||
activePeak int(10),
|
||||
activePeakTime bigint(20),
|
||||
poolingCount int(10),
|
||||
poolingPeak int(10),
|
||||
poolingPeakTime bigint(20),
|
||||
connectCount bigint(20),
|
||||
closeCount bigint(20),
|
||||
waitThreadCount bigint(20),
|
||||
notEmptyWaitCount bigint(20),
|
||||
notEmptyWaitNanos bigint(20),
|
||||
logicConnectErrorCount bigint(20),
|
||||
physicalConnectCount bigint(20),
|
||||
physicalCloseCount bigint(20),
|
||||
physicalConnectErrorCount bigint(20),
|
||||
executeCount bigint(20),
|
||||
errorCount bigint(20),
|
||||
commitCount bigint(20),
|
||||
rollbackCount bigint(20),
|
||||
pstmtCacheHitCount bigint(20),
|
||||
pstmtCacheMissCount bigint(20),
|
||||
startTransactionCount bigint(20),
|
||||
clobOpenCount bigint(20),
|
||||
blobOpenCount bigint(20),
|
||||
PRIMARY KEY (id),
|
||||
KEY(collectTime, domain, app)
|
||||
)
|
||||
@@ -0,0 +1,41 @@
|
||||
CREATE TABLE druid_springmethod (
|
||||
id bigint(20) AUTO_INCREMENT NOT NULL,
|
||||
domain varchar(45) NOT NULL,
|
||||
app varchar(45) NOT NULL,
|
||||
cluster varchar(45) NOT NULL,
|
||||
host varchar(128),
|
||||
pid int(10) NOT NULL,
|
||||
collectTime datetime NOT NULL,
|
||||
className varchar(256),
|
||||
signature varchar(256),
|
||||
runningCount int(10),
|
||||
concurrentMax int(10),
|
||||
executeCount bigint(20),
|
||||
executeErrorCount bigint(20),
|
||||
executeTimeNano bigint(20),
|
||||
jdbcFetchRowCount bigint(20),
|
||||
jdbcUpdateCount bigint(20),
|
||||
jdbcExecuteCount bigint(20),
|
||||
jdbcExecuteErrorCount bigint(20),
|
||||
jdbcExecuteTimeNano bigint(20),
|
||||
jdbcCommitCount bigint(20),
|
||||
jdbcRollbackCount bigint(20),
|
||||
jdbcPoolConnectionOpenCount bigint(20),
|
||||
jdbcPoolConnectionCloseCount bigint(20),
|
||||
jdbcResultSetOpenCount bigint(20),
|
||||
jdbcResultSetCloseCount bigint(20),
|
||||
lastErrorClass varchar(256),
|
||||
lastErrorMessage varchar(256),
|
||||
lastErrorStackTrace varchar(256),
|
||||
lastErrorTimeMillis bigint(20),
|
||||
h1 bigint(20),
|
||||
h10 bigint(20),
|
||||
h100 bigint(20),
|
||||
h1000 bigint(20),
|
||||
h10000 int(10),
|
||||
h100000 int(10),
|
||||
h1000000 int(10),
|
||||
hmore int(10),
|
||||
PRIMARY KEY (id),
|
||||
KEY(collectTime, domain, app)
|
||||
)
|
||||
@@ -1,10 +1,10 @@
|
||||
CREATE TABLE druid_sql (
|
||||
id bigint(20) AUTO_INCREMENT NOT NULL,
|
||||
domain varchar(45),
|
||||
app varchar(45),
|
||||
cluster varchar(45),
|
||||
domain varchar(45) NOT NULL,
|
||||
app varchar(45) NOT NULL,
|
||||
cluster varchar(45) NOT NULL,
|
||||
host varchar(128),
|
||||
pid int(10),
|
||||
pid int(10) NOT NULL,
|
||||
collectTime datetime NOT NULL,
|
||||
sqlHash bigint(20),
|
||||
dataSource varchar(256),
|
||||
@@ -67,5 +67,7 @@ CREATE TABLE druid_sql (
|
||||
u1000 int(10),
|
||||
u10000 int(10),
|
||||
umore int(10),
|
||||
PRIMARY KEY (id)
|
||||
PRIMARY KEY (id),
|
||||
KEY (collectTime, domain, app),
|
||||
KEY(collectTime, domain, app)
|
||||
)
|
||||
@@ -0,0 +1,74 @@
|
||||
CREATE TABLE druid_webapp (
|
||||
id bigint(20) AUTO_INCREMENT NOT NULL,
|
||||
domain varchar(45) NOT NULL,
|
||||
app varchar(45) NOT NULL,
|
||||
cluster varchar(45) NOT NULL,
|
||||
host varchar(128),
|
||||
pid int(10) NOT NULL,
|
||||
collectTime datetime NOT NULL,
|
||||
contextPath varchar(256),
|
||||
runningCount int(10),
|
||||
concurrentMax int(10),
|
||||
requestCount bigint(20),
|
||||
sessionCount bigint(20),
|
||||
jdbcFetchRowCount bigint(20),
|
||||
jdbcUpdateCount bigint(20),
|
||||
jdbcExecuteCount bigint(20),
|
||||
jdbcExecuteTimeNano bigint(20),
|
||||
jdbcCommitCount bigint(20),
|
||||
jdbcRollbackCount bigint(20),
|
||||
osMacOSXCount bigint(20),
|
||||
osWindowsCount bigint(20),
|
||||
osLinuxCount bigint(20),
|
||||
osSymbianCount bigint(20),
|
||||
osFreeBSDCount bigint(20),
|
||||
osOpenBSDCount bigint(20),
|
||||
osAndroidCount bigint(20),
|
||||
osWindows98Count bigint(20),
|
||||
osWindowsXPCount bigint(20),
|
||||
osWindows2000Count bigint(20),
|
||||
osWindowsVistaCount bigint(20),
|
||||
osWindows7Count bigint(20),
|
||||
osWindows8Count bigint(20),
|
||||
osAndroid15Count bigint(20),
|
||||
osAndroid16Count bigint(20),
|
||||
osAndroid20Count bigint(20),
|
||||
osAndroid21Count bigint(20),
|
||||
osAndroid22Count bigint(20),
|
||||
osAndroid23Count bigint(20),
|
||||
osAndroid30Count bigint(20),
|
||||
osAndroid31Count bigint(20),
|
||||
osAndroid32Count bigint(20),
|
||||
osAndroid40Count bigint(20),
|
||||
osAndroid41Count bigint(20),
|
||||
osAndroid42Count bigint(20),
|
||||
osAndroid43Count bigint(20),
|
||||
osLinuxUbuntuCount bigint(20),
|
||||
browserIECount bigint(20),
|
||||
browserFirefoxCount bigint(20),
|
||||
browserChromeCount bigint(20),
|
||||
browserSafariCount bigint(20),
|
||||
browserOperaCount bigint(20),
|
||||
browserIE5Count bigint(20),
|
||||
browserIE6Count bigint(20),
|
||||
browserIE7Count bigint(20),
|
||||
browserIE8Count bigint(20),
|
||||
browserIE9Count bigint(20),
|
||||
browserIE10Count bigint(20),
|
||||
browser360SECount bigint(20),
|
||||
deviceAndroidCount bigint(20),
|
||||
deviceIpadCount bigint(20),
|
||||
deviceIphoneCount bigint(20),
|
||||
deviceWindowsPhoneCount bigint(20),
|
||||
botCount bigint(20),
|
||||
botBaiduCount bigint(20),
|
||||
botYoudaoCount bigint(20),
|
||||
botGoogleCount bigint(20),
|
||||
botMsnCount bigint(20),
|
||||
botBingCount bigint(20),
|
||||
botSosoCount bigint(20),
|
||||
botSogouCount bigint(20),
|
||||
botYahooCount bigint(20),
|
||||
PRIMARY KEY (id),
|
||||
KEY(collectTime, domain, app)
|
||||
)
|
||||
@@ -0,0 +1,40 @@
|
||||
CREATE TABLE druid_weburi (
|
||||
id bigint(20) AUTO_INCREMENT NOT NULL,
|
||||
domain varchar(45) NOT NULL,
|
||||
app varchar(45) NOT NULL,
|
||||
cluster varchar(45) NOT NULL,
|
||||
host varchar(128),
|
||||
pid int(10) NOT NULL,
|
||||
collectTime datetime NOT NULL,
|
||||
uri varchar(256),
|
||||
runningCount int(10),
|
||||
concurrentMax int(10),
|
||||
requestCount bigint(20),
|
||||
requestTimeNano bigint(20),
|
||||
jdbcFetchRowCount bigint(20),
|
||||
jdbcFetchRowPeak bigint(20),
|
||||
jdbcUpdateCount bigint(20),
|
||||
jdbcUpdatePeak bigint(20),
|
||||
jdbcExecuteCount bigint(20),
|
||||
jdbcExecuteErrorCount bigint(20),
|
||||
jdbcExecutePeak bigint(20),
|
||||
jdbcExecuteTimeNano bigint(20),
|
||||
jdbcCommitCount bigint(20),
|
||||
jdbcRollbackCount bigint(20),
|
||||
jdbcPoolConnectionOpenCount bigint(20),
|
||||
jdbcPoolConnectionCloseCount bigint(20),
|
||||
jdbcResultSetOpenCount bigint(20),
|
||||
jdbcResultSetCloseCount bigint(20),
|
||||
errorCount bigint(20),
|
||||
lastAccessTimeMillis bigint(20),
|
||||
h1 bigint(20),
|
||||
h10 bigint(20),
|
||||
h100 bigint(20),
|
||||
h1000 bigint(20),
|
||||
h10000 int(10),
|
||||
h100000 int(10),
|
||||
h1000000 int(10),
|
||||
hmore int(10),
|
||||
PRIMARY KEY (id),
|
||||
KEY(collectTime, domain, app)
|
||||
)
|
||||
@@ -463,7 +463,7 @@ public class MonitorDaoJdbcImpl implements MonitorDao {
|
||||
tableName = annotation.name();
|
||||
}
|
||||
|
||||
for (Field field : JdbcSqlStatValue.class.getDeclaredFields()) {
|
||||
for (Field field : clazz.getDeclaredFields()) {
|
||||
MField annotation = field.getAnnotation(MField.class);
|
||||
if (annotation == null) {
|
||||
continue;
|
||||
|
||||
@@ -9,12 +9,16 @@ import junit.framework.TestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.pool.DruidDataSourceStatValue;
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.stat.JdbcSqlStatValue;
|
||||
import com.alibaba.druid.support.http.stat.WebAppStatValue;
|
||||
import com.alibaba.druid.support.http.stat.WebURIStatValue;
|
||||
import com.alibaba.druid.support.monitor.MonitorClient;
|
||||
import com.alibaba.druid.support.monitor.dao.MonitorDaoJdbcImpl;
|
||||
import com.alibaba.druid.support.monitor.dao.MonitorDaoJdbcImpl.BeanInfo;
|
||||
import com.alibaba.druid.support.monitor.dao.MonitorDaoJdbcImpl.FieldInfo;
|
||||
import com.alibaba.druid.support.spring.stat.SpringMethodStatValue;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
|
||||
@@ -49,7 +53,31 @@ public class MonitorDaoJdbcImplTest extends TestCase {
|
||||
System.out.println(SQLUtils.format(sql, JdbcConstants.MYSQL));
|
||||
JdbcUtils.execute(dataSource, sql, Collections.emptyList());
|
||||
}
|
||||
|
||||
{
|
||||
String sql = buildCreateSql(dao, new BeanInfo(DruidDataSourceStatValue.class));
|
||||
System.out.println(SQLUtils.format(sql, JdbcConstants.MYSQL));
|
||||
JdbcUtils.execute(dataSource, sql, Collections.emptyList());
|
||||
}
|
||||
|
||||
{
|
||||
String sql = buildCreateSql(dao, new BeanInfo(WebURIStatValue.class));
|
||||
System.out.println(SQLUtils.format(sql, JdbcConstants.MYSQL));
|
||||
JdbcUtils.execute(dataSource, sql, Collections.emptyList());
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
String sql = buildCreateSql(dao, new BeanInfo(WebAppStatValue.class));
|
||||
System.out.println(SQLUtils.format(sql, JdbcConstants.MYSQL));
|
||||
JdbcUtils.execute(dataSource, sql, Collections.emptyList());
|
||||
}
|
||||
|
||||
{
|
||||
String sql = buildCreateSql(dao, new BeanInfo(SpringMethodStatValue.class));
|
||||
System.out.println(SQLUtils.format(sql, JdbcConstants.MYSQL));
|
||||
JdbcUtils.execute(dataSource, sql, Collections.emptyList());
|
||||
}
|
||||
client.collectSql();
|
||||
|
||||
{
|
||||
@@ -57,7 +85,7 @@ public class MonitorDaoJdbcImplTest extends TestCase {
|
||||
for (JdbcSqlStatValue sqlStatValue : sqlList) {
|
||||
System.out.println(sqlStatValue.getData());
|
||||
}
|
||||
Assert.assertEquals(1, sqlList.size());
|
||||
Assert.assertEquals(5, sqlList.size());
|
||||
}
|
||||
|
||||
client.collectSql();
|
||||
@@ -67,7 +95,7 @@ public class MonitorDaoJdbcImplTest extends TestCase {
|
||||
for (JdbcSqlStatValue sqlStatValue : sqlList) {
|
||||
System.out.println(sqlStatValue.getData());
|
||||
}
|
||||
Assert.assertEquals(3, sqlList.size());
|
||||
Assert.assertEquals(7, sqlList.size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,11 +106,11 @@ public class MonitorDaoJdbcImplTest extends TestCase {
|
||||
.append(dao.getTableName(beanInfo));
|
||||
|
||||
buf.append("( id bigint(20) NOT NULL AUTO_INCREMENT");
|
||||
buf.append(", domain varchar(45)");
|
||||
buf.append(", app varchar(45)");
|
||||
buf.append(", cluster varchar(45)");
|
||||
buf.append(", domain varchar(45) NOT NULL");
|
||||
buf.append(", app varchar(45) NOT NULL");
|
||||
buf.append(", cluster varchar(45) NOT NULL");
|
||||
buf.append(", host varchar(128)");
|
||||
buf.append(", pid int(10)");
|
||||
buf.append(", pid int(10) NOT NULL");
|
||||
buf.append(", collectTime datetime NOT NULL");
|
||||
List<FieldInfo> fields = beanInfo.getFields();
|
||||
for (int i = 0; i < fields.size(); ++i) {
|
||||
@@ -100,6 +128,7 @@ public class MonitorDaoJdbcImplTest extends TestCase {
|
||||
}
|
||||
}
|
||||
buf.append(", PRIMARY KEY(id)");
|
||||
// buf.append(", KEY(collectTime, domain, app)");
|
||||
buf.append(")");
|
||||
|
||||
return buf.toString();
|
||||
|
||||
Reference in New Issue
Block a user