提交 f6c6e95d 编写于 作者: Y youyong205

Merge pull request #187 from ainilife/biz

add cat and jetty maven plugin
......@@ -299,7 +299,6 @@ public class CatFilter implements Filter {
Object catStatus = req.getAttribute(CatConstants.CAT_STATE);
if (catPageUri != null && t instanceof DefaultTransaction && catPageUri instanceof String) {
System.err.println(catPageUri.toString());
((DefaultTransaction) t).setName(catPageUri.toString());
}
if (catStatus != null) {
......
......@@ -4,6 +4,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
......@@ -84,7 +85,7 @@ public class MetricConfigManager implements Initializable, LogEnabled {
m_metricConfig = DefaultSaxParser.parse(content);
m_configId = config.getId();
m_modifyTime = config.getModifyDate().getTime();
m_modifyTime = new Date().getTime();
} catch (Exception ex) {
Cat.logError(ex);
}
......
......@@ -4,6 +4,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
......@@ -84,7 +85,7 @@ public class ProductLineConfigManager implements Initializable, LogEnabled {
m_company = DefaultSaxParser.parse(content);
m_configId = config.getId();
m_modifyTime = config.getModifyDate().getTime();
m_modifyTime = new Date().getTime();
} catch (Exception ex) {
Cat.logError(ex);
}
......
......@@ -220,6 +220,22 @@
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.26</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<contextPath>/cat</contextPath>
<defaultsDescriptor>src/main/webapp/WEB-INF/web.xml</defaultsDescriptor>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>2281</port>
<maxIdleTime>500000</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>
</plugins>
</build>
<properties>
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>com.dianping.cat</groupId>
<artifactId>parent</artifactId>
<version>0.6.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cat-maven-plugin</artifactId>
<name>cat-maven-plugin</name>
<packaging>maven-plugin</packaging>
<prerequisites>
<maven>3.0.3</maven>
</prerequisites>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.unidal.framework</groupId>
<artifactId>foundation-service</artifactId>
<version>2.0.4</version>
</dependency>
</dependencies>
</project>
package com.dianping.cat.plugin;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.unidal.helper.Files;
import org.unidal.helper.Files.AutoClose;
/**
* @goal install
*/
public class CatInstallMojo extends AbstractMojo {
private final String m_datasourceUrl = "JDBC-URL";
private final String m_datasourceUser = "JDBC-USER";
private final String m_datasourcePassword = "JDBC-PASSWORD";
private String m_path = "/data/appdatas/cat";
private String m_clientPath = m_path + File.separator + "client.xml";
private String m_serverPath = m_path + File.separator + "server.xml";
private String m_datasourcePath = m_path + File.separator + "datasources.xml";
/**
* @parameter expression="${jdbc.url}"
*/
private String m_jdbcUrl;
/**
* @parameter expression="${jdbc.user}"
*/
private String m_user;
/**
* @parameter expression="${jdbc.password}"
*/
private String m_password;
private void createDatabase(Statement stmt) throws SQLException {
try {
stmt.executeUpdate("create database cat");
} catch (SQLException e) {
if (e.getErrorCode() == 1007) {
getLog().info("Database 'cat' already exists, drop it first...");
stmt.executeUpdate("drop database cat");
getLog().info("Database 'cat' has dropped.");
stmt.executeUpdate("create database cat");
} else {
throw e;
}
}
}
private void createTables(Statement stmt) throws IOException, SQLException {
String sqlTable = Files.forIO().readFrom(getClass().getResourceAsStream("Cat.sql"), "utf-8");
String[] tables = sqlTable.split(";");
sqlTable = sqlTable.replace("\n", " ");
for (String table : tables) {
if (table != null && table.trim().length() > 0) {
stmt.execute(table.trim() + ";");
}
}
}
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info("Delopying the Cat environment...");
validate();
setupDatabase();
setupConfigurationFiles();
}
private Connection getConnection(String jdbcUrl) throws ClassNotFoundException, SQLException {
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection(jdbcUrl, m_user, m_password);
return conn;
}
private void setupConfigurationFiles() {
File path = new File(m_path);
if (!path.exists()) {
path.mkdirs();
}
if (!path.canRead() || !path.canWrite()) {
getLog()
.warn(m_path
+ " doesn't have enough privilege to read or write this pathname, please add read and write privileges to the current user.");
}
getLog().info("Generating the configuration files to " + m_path + "...");
try {
Files.forIO().copy(getClass().getResourceAsStream("client.xml"), new FileOutputStream(m_clientPath),
AutoClose.INPUT_OUTPUT);
getLog().info("generate client.xml .");
Files.forIO().copy(getClass().getResourceAsStream("server.xml"), new FileOutputStream(m_serverPath),
AutoClose.INPUT_OUTPUT);
getLog().info("generate server.xml .");
String datasources = Files.forIO().readFrom(getClass().getResourceAsStream("datasources.xml"), "utf-8");
datasources = datasources.replaceAll(m_datasourceUrl, m_jdbcUrl + "/cat");
datasources = datasources.replaceAll(m_datasourceUser, m_user);
datasources = datasources.replaceAll(m_datasourcePassword, m_password);
Files.forIO().writeTo(new File(m_datasourcePath), datasources);
getLog().info("generate datasources.xml .");
} catch (Exception e) {
getLog().error(e);
}
}
private void setupDatabase() {
Connection conn = null;
Statement stmt = null;
try {
getLog().info("Connect the mysql database : " + m_jdbcUrl);
conn = getConnection(m_jdbcUrl);
stmt = conn.createStatement();
getLog().info("Creating database...");
createDatabase(stmt);
getLog().info("Database 'cat' created successfully.");
getLog().info("Create tables...");
createTables(stmt);
getLog().info("Create tables successfully.");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn.close();
}
} catch (Exception e) {
// ignore it
}
}
}
private void validate() {
Reader inputStream = null;
BufferedReader reader = null;
try {
inputStream = new InputStreamReader(System.in);
reader = new BufferedReader(inputStream);
if (m_jdbcUrl == null || m_jdbcUrl.length() == 0) {
System.out.print("Please input the mysql jdbc url(jdbc:mysql://192.168.1.1:3306):");
m_jdbcUrl = reader.readLine();
}
if (m_user == null || m_user.length() == 0) {
System.out.print("Please input the mysql user:");
m_user = reader.readLine();
}
if (m_password == null || m_password.length() == 0) {
System.out.print("Please input the mysql password:");
m_password = reader.readLine();
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (inputStream != null) {
inputStream.close();
}
if (reader != null) {
reader.close();
}
} catch (IOException e) {
// ignore it
}
}
}
}
\ No newline at end of file
use cat;
CREATE TABLE `DP_AdminLogin` (
`LoginID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`AdminID` int(10) DEFAULT NULL,
`LoginName` varchar(128) DEFAULT NULL COMMENT '登陆名',
`Password` varchar(128) DEFAULT NULL COMMENT '密码',
`Email` varchar(128) DEFAULT NULL COMMENT '邮箱',
`RealName` varchar(128) DEFAULT NULL COMMENT '真实姓名',
`MobileNo` varchar(128) DEFAULT NULL COMMENT '手机号码',
PRIMARY KEY (`LoginID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户信息表';
CREATE TABLE `dailygraph` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL COMMENT '报表名称',
`ip` varchar(20) NULL COMMENT '报表来自于哪台cat-client机器ip, 空串表示合并同domain所有ip',
`domain` varchar(50) NOT NULL COMMENT '报表处理的Domain信息',
`period` datetime NOT NULL COMMENT '报表时间段',
`type` tinyint(4) NOT NULL COMMENT '报表数据格式, 1/xml, 2/json, 3/csv, 默认3',
`detail_content` mediumtext NOT NULL COMMENT '详细绘图内容',
`summary_content` mediumtext NOT NULL COMMENT '概要绘图内容',
`creation_date` datetime NOT NULL COMMENT '报表创建时间',
PRIMARY KEY (`id`),
UNIQUE KEY `dailygraph_period_ip_domain_name` (`period`,`ip`,`domain`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用于月报的画图曲线';
CREATE TABLE `dailyreport` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL COMMENT '报表名称, transaction, problem...',
`ip` varchar(20) NOT NULL COMMENT '报表来自于哪台cat-consumer机器',
`domain` varchar(50) NOT NULL COMMENT '报表处理的Domain信息',
`period` datetime NOT NULL COMMENT '报表时间段',
`type` tinyint(4) NOT NULL COMMENT '报表数据格式, 1/xml, 2/json, 默认1',
`content` mediumtext NOT NULL COMMENT '报表内容',
`creation_date` datetime NOT NULL COMMENT '报表创建时间',
PRIMARY KEY (`id`),
UNIQUE KEY `period` (`period`,`domain`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='天报表';
CREATE TABLE `weeklyreport` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL COMMENT '报表名称, transaction, problem...',
`ip` varchar(20) NOT NULL COMMENT '报表来自于哪台cat-consumer机器',
`domain` varchar(50) NOT NULL COMMENT '报表处理的Domain信息',
`period` datetime NOT NULL COMMENT '报表时间段',
`type` tinyint(4) NOT NULL COMMENT '报表数据格式, 1/xml, 2/json, 默认1',
`content` mediumtext NOT NULL COMMENT '报表内容',
`creation_date` datetime NOT NULL COMMENT '报表创建时间',
PRIMARY KEY (`id`),
UNIQUE KEY `period` (`period`,`domain`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='周报表';
CREATE TABLE `monthreport` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL COMMENT '报表名称, transaction, problem...',
`ip` varchar(20) NOT NULL COMMENT '报表来自于哪台cat-consumer机器',
`domain` varchar(50) NOT NULL COMMENT '报表处理的Domain信息',
`period` datetime NOT NULL COMMENT '报表时间段',
`type` tinyint(4) NOT NULL COMMENT '报表数据格式, 1/xml, 2/json, 默认1',
`content` mediumtext NOT NULL COMMENT '报表内容',
`creation_date` datetime NOT NULL COMMENT '报表创建时间',
PRIMARY KEY (`id`),
UNIQUE KEY `period` (`period`,`domain`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='月报表';
CREATE TABLE `graph` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL COMMENT '报表名称',
`ip` varchar(20) NULL COMMENT '报表来自于哪台cat-client机器ip, NULL表示合并同domain所有ip',
`domain` varchar(50) NOT NULL COMMENT '报表处理的Domain信息',
`period` datetime NOT NULL COMMENT '报表时间段',
`type` tinyint(4) NOT NULL COMMENT '报表数据格式, 1/xml, 2/json, 3/csv, 默认3',
`detail_content` mediumtext NOT NULL COMMENT '详细绘图内容',
`summary_content` mediumtext NOT NULL COMMENT '概要绘图内容',
`creation_date` datetime NOT NULL COMMENT '报表创建时间',
PRIMARY KEY (`id`),
UNIQUE KEY `graph_period_ip_domain_name` (`period`,`ip`,`domain`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='小时图表曲线';
CREATE TABLE `hostinfo` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip` varchar(50) NOT NULL COMMENT '部署机器IP',
`domain` varchar(50) NOT NULL COMMENT '部署机器对应的项目名',
`creation_date` datetime NOT NULL,
`last_modified_date` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ip_index` (`ip`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='IP和项目名的对应关系';
CREATE TABLE `location` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`lat` double NOT NULL,
`lng` double NOT NULL,
`total` int(11) NOT NULL,
`transaction_date` datetime NOT NULL,
`creation_date` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `transaction_date_lat_lng` (`transaction_date`,`lat`,`lng`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用于热点图地理位置表';
CREATE TABLE `report` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` tinyint(4) NOT NULL COMMENT '报表类型, 1/xml, 9/binary 默认1',
`name` varchar(20) NOT NULL COMMENT '报表名称',
`ip` varchar(20) DEFAULT NULL COMMENT '报表来自于哪台机器',
`domain` varchar(50) NOT NULL COMMENT '报表项目',
`period` timestamp NOT NULL COMMENT '报表时间段',
`content` longtext NULL,
`creation_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '报表创建时间',
PRIMARY KEY (`id`),
KEY `IX_Domain_Name_Period` (`domain`,`name`,`period`),
KEY `IX_Name_Period` (`name`,`period`),
KEY `IX_Period` (`period`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED COMMENT='用于存放实时报表信息,处理之后的结果';
CREATE TABLE `report_content` (
`report_id` int(11) NOT NULL COMMENT '报表ID',
`content` longblob NOT NULL COMMENT '二进制报表内容',
`creation_date` timestamp NOT NULL COMMENT '创建时间',
PRIMARY KEY (`report_id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED COMMENT='小时报表二进制内容';
CREATE TABLE `daily_report_content` (
`report_id` int(11) NOT NULL COMMENT '报表ID',
`content` longblob NOT NULL COMMENT '二进制报表内容',
`creation_date` timestamp NOT NULL COMMENT '创建时间',
PRIMARY KEY (`report_id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED COMMENT='天报表二进制内容';
CREATE TABLE `weekly_report_content` (
`report_id` int(11) NOT NULL COMMENT '报表ID',
`content` longblob NOT NULL COMMENT '二进制报表内容',
`creation_date` timestamp NOT NULL COMMENT '创建时间',
PRIMARY KEY (`report_id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED COMMENT='周报表二进制内容';
CREATE TABLE `monthly_report_content` (
`report_id` int(11) NOT NULL COMMENT '报表ID',
`content` longblob NOT NULL COMMENT '二进制报表内容',
`creation_date` timestamp NOT NULL COMMENT '创建时间',
PRIMARY KEY (`report_id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED COMMENT='月报表二进制内容';
CREATE TABLE `businessReport` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` tinyint(4) NOT NULL COMMENT '报表类型 报表数据格式, 1/Binary, 2/xml , 3/json',
`name` varchar(20) NOT NULL COMMENT '报表名称',
`ip` varchar(20) NOT NULL COMMENT '报表来自于哪台机器',
`productLine` varchar(50) NOT NULL COMMENT '指标来源于哪个产品组',
`period` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '报表时间段',
`content` longblob COMMENT '用于存放报表的具体内容',
`creation_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '报表创建时间',
PRIMARY KEY (`id`),
KEY `IX_Group_Name_Period` (`productLine`,`name`,`period`),
KEY `IX_Name_Period` (`name`,`period`),
KEY `IX_Period` (`period`)
) ENGINE=InnoDB AUTO_INCREMENT=106 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED COMMENT='用于存放业务监控实时报表信息,处理之后的结果';
CREATE TABLE `sqlreport` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`domain` varchar(50) NOT NULL,
`name` varchar(100) NOT NULL COMMENT 'SQL的名称',
`statement` varchar(3000) NOT NULL COMMENT 'SQL的具体描述',
`total_count` int(11) NOT NULL COMMENT '总数',
`failure_count` int(11) NOT NULL COMMENT '错误数目',
`long_sqls` int(11) NOT NULL COMMENT 'longsql的数目',
`min_value` double NOT NULL COMMENT '最小值',
`max_value` double NOT NULL COMMENT '最大值',
`avg2_value` double NOT NULL COMMENT '90%的平均值',
`sum_value` double NOT NULL COMMENT '和',
`sum2_value` double NOT NULL COMMENT '平方和',
`sample_link` varchar(64) NOT NULL COMMENT '链接',
`transaction_date` datetime NOT NULL COMMENT 'SQL的时间段',
`creation_date` datetime NOT NULL COMMENT '数据库创建时间',
`duration_distribution` varchar(512) NOT NULL COMMENT 'SQL处理的时间分布信息',
`hits_over_time` varchar(512) NOT NULL COMMENT 'SQL在当前一个小时处理信息',
`duration_over_time` varchar(512) NOT NULL COMMENT 'SQL处理时间的信息',
`failure_over_time` varchar(512) NOT NULL COMMENT '在一个小时内的错误分布',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用于存放Hadoop处理的SQL报表信息';
CREATE TABLE `sqltable` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`domain` varchar(50) DEFAULT NULL COMMENT '这条sql语句的属于项目名',
`sql_name` varchar(100) DEFAULT NULL COMMENT 'sql 语句的简写',
`table_name` varchar(100) DEFAULT NULL COMMENT 'sql语句操作的表名',
`sql_statement` text,
`creation_date` datetime DEFAULT NULL COMMENT '创建时间',
`modify_date` datetime DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`id`),
KEY `domain` (`domain`),
KEY `sql_name` (`sql_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用于存放SQL和操作的表名的关系';
CREATE TABLE `subscriber` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`domain` char(250) NOT NULL COMMENT '域名',
`group` char(250) NOT NULL COMMENT '域名',
`owner` char(250) NOT NULL COMMENT '域名',
`address` varchar(1000) NOT NULL COMMENT '订阅者地址',
`type` int(4) NOT NULL DEFAULT '0' COMMENT '订阅类型(0,表示邮件;1,表示短信)',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='通知订阅者表';
CREATE TABLE `task` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`producer` varchar(20) NOT NULL COMMENT '任务创建者ip',
`consumer` varchar(20) NULL COMMENT '任务执行者ip',
`failure_count` tinyint(4) NOT NULL COMMENT '任务失败次数',
`report_name` varchar(20) NOT NULL COMMENT '报表名称, transaction, problem...',
`report_domain` varchar(50) NOT NULL COMMENT '报表处理的Domain信息',
`report_period` datetime NOT NULL COMMENT '报表时间',
`status` tinyint(4) NOT NULL COMMENT '执行状态: 1/todo, 2/doing, 3/done 4/failed',
`task_type` tinyint(4) NOT NULL DEFAULT '1' COMMENT '0表示小时任务,1表示天任务',
`creation_date` datetime NOT NULL COMMENT '任务创建时间',
`start_date` datetime NULL COMMENT '开始时间, 这次执行开始时间',
`end_date` datetime NULL COMMENT '结束时间, 这次执行结束时间',
PRIMARY KEY (`id`),
UNIQUE KEY `task_period_domain_name_type` (`report_period`,`report_domain`,`report_name`,`task_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='后台任务';
CREATE TABLE `alarmTemplate` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(64) DEFAULT NULL COMMENT '告警模板名称',
`content` text DEFAULT NULL COMMENT '告警模板内容',
`creation_date` datetime DEFAULT NULL COMMENT '创建时间',
`modify_date` datetime DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='告警模板';
CREATE TABLE `alarmRule` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`template_id` int(11) NOT NULL COMMENT '告警模板ID' ,
`domain` varchar(64) DEFAULT NULL COMMENT '具体项目名称',
`content` text DEFAULT NULL COMMENT '自定义告警模板内容',
`creation_date` datetime DEFAULT NULL COMMENT '创建时间',
`modify_date` datetime DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='告警规则实例表';
CREATE TABLE `alarmRuleSubscription` (
`alarm_rule_id` int(11) NOT NULL COMMENT '告警规则ID',
`user_id` int(11) NOT NULL COMMENT '用户ID',
`creation_date` datetime DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`alarm_rule_id`,`user_id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户订阅告警记录表';
CREATE TABLE `mailRecord` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` int(11) NOT NULL COMMENT '发送邮件的内容,1表示告警邮件,2表示每日报表邮件',
`rule_id` int(11) NOT NULL COMMENT '用户订阅ID外间',
`receivers` varchar(500) NOT NULL COMMENT '接受用户邮件列表',
`title` varchar(200) NOT NULL COMMENT '邮件标题',
`content` text NOT NULL COMMENT '邮件具体内容',
`status` int(11) NOT NULL COMMENT '1表示发送成功、2表示发送失败',
`creation_date` datetime NOT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='邮件通知记录表';
CREATE TABLE `scheduledReport` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`domain` varchar(64) DEFAULT NULL COMMENT '具体项目名称',
`names` varchar(200) DEFAULT NULL COMMENT '发送具体的报表,逗号分割',
`creation_date` datetime DEFAULT NULL COMMENT '创建时间',
`modify_date` datetime DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='告警规则实例表';
CREATE TABLE `scheduledReportSubscription` (
`scheduled_report_id` int(11) NOT NULL COMMENT '定时任务ID',
`user_id` int(11) NOT NULL COMMENT '用户ID',
`creation_date` datetime DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`scheduled_report_id`,`user_id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户订阅定时报表记录表';
CREATE TABLE `project` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`domain` varchar(50) NOT NULL COMMENT '项目名称',
`project_line` varchar(50) DEFAULT NULL COMMENT '关联产品线名称',
`department` varchar(50) DEFAULT NULL COMMENT '关联项目组名称',
`owner` varchar(50) DEFAULT NULL COMMENT '项目负责人',
`email` varchar(200) DEFAULT NULL COMMENT '项目组邮件',
`creation_date` datetime DEFAULT NULL COMMENT '创建时间',
`modify_date` datetime DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='项目基本信息';
CREATE TABLE `event` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` int(11) NOT NULL COMMENT '1、运维系统告警,2、DB告警,3、CAT内容告警',
`link` varchar(500) DEFAULT NULL COMMENT '详细信息link',
`domain` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
`ip` varchar(32) DEFAULT NULL COMMENT '错误机器IP',
`subject` varchar(200) DEFAULT NULL COMMENT '事件标题',
`content` text COMMENT '事件内容',
`date` datetime NOT NULL COMMENT '事件发生时间',
`creation_date` datetime NOT NULL COMMENT '记录创建时间',
PRIMARY KEY (`id`),
KEY `ix_date_domain` (`date`,`domain`)
) ENGINE=InnoDB AUTO_INCREMENT=23106 DEFAULT CHARSET=utf8 COMMENT='事件记录表';
CREATE TABLE `config` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL COMMENT '配置名称',
`content` longtext COMMENT '配置的具体内容',
`creation_date` datetime NOT NULL COMMENT '配置创建时间',
`modify_date` datetime NOT NULL COMMENT '配置修改时间',
PRIMARY KEY (`id`),
KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用于存储系统的全局配置信息';
CREATE TABLE `abtest` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`name` varchar(45) NOT NULL COMMENT '名字',
`owner` varchar(45) NOT NULL COMMENT 'case的Owner',
`group_strategy` int(11) DEFAULT NULL COMMENT '分组策略ID',
`domains` varchar(200) DEFAULT NULL COMMENT 'Domains,逗号分割',
`creation_date` datetime DEFAULT NULL COMMENT '创建时间',
`modified_date` datetime DEFAULT NULL COMMENT '上次修改时间',
`description` varchar(512) DEFAULT NULL COMMENT '描述',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='AB测试内容';
CREATE TABLE `abtest_report` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`run_id` int(11) DEFAULT NULL,
`period` datetime DEFAULT NULL,
`content` text,
`creation_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='AB测试报表';
CREATE TABLE `abtest_run` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`creator` varchar(45) DEFAULT NULL COMMENT 'Creator',
`case_id` int(11) NOT NULL COMMENT 'Case ID',
`start_date` datetime DEFAULT NULL COMMENT '开始时间',
`end_date` datetime DEFAULT NULL COMMENT '结束时间',
`disabled` tinyint(4) NOT NULL COMMENT '是否有效',
`domains` varchar(100) NOT NULL COMMENT '属于的domain,用逗号分割',
`conditions` text,
`java_fragement` text,
`conversion_goals` text,
`strategy_configuration` text COMMENT '策略配置',
`creation_date` datetime NOT NULL COMMENT '创建时间',
`modified_date` datetime NOT NULL COMMENT '上次修改时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='AB测试运行实例';
CREATE TABLE `group_strategy` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL COMMENT 'GroupStrategy的名字',
`class_name` varchar(100) NOT NULL COMMENT 'GroupStrategy的英文名',
`fully_qualified_name` varchar(100) NOT NULL COMMENT 'GroupStrategy的class名字',
`descriptor` text COMMENT '配置的schema',
`status` tinyint(4) NOT NULL COMMENT '是否开/关,1是开,0是关',
`description` varchar(512) DEFAULT NULL COMMENT '描述',
PRIMARY KEY (`id`),
UNIQUE KEY `name_UNIQUE` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用于记录分组策略';
CREATE TABLE `topologyGraph` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip` varchar(20) DEFAULT NULL COMMENT '报表来自于哪台cat-client机器ip',
`period` datetime NOT NULL COMMENT '报表时间段,精确到分钟',
`type` tinyint(4) NOT NULL COMMENT '报表数据格式, 1/xml, 2/json, 3/binary',
`content` longblob COMMENT '用于存放报表的具体内容',
`creation_date` datetime NOT NULL COMMENT '报表创建时间',
PRIMARY KEY (`id`),
KEY `period` (`period`)
) ENGINE=InnoDB AUTO_INCREMENT=21912 DEFAULT CHARSET=utf8 COMMENT='用于存储历史的拓扑图曲线';
CREATE TABLE `baseline` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`report_name` varchar(100) DEFAULT NULL,
`index_key` varchar(100) DEFAULT NULL,
`report_period` datetime DEFAULT NULL,
`data` blob,
`creation_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `ix_indexkey_reportperiod` (`index_key`,`report_period`),
KEY `ix_reportperiod` (`report_period`)
) ENGINE=InnoDB AUTO_INCREMENT=5062 DEFAULT CHARSET=utf8;
<!--客户端需要配置Cat服务器的地址。客户端使用多个地址进行热备,从第一个地址开发发送消息,如果成功发送,则停止;如果发送失败,则从第二个地址开发重新发送。 -->
<config mode="client" xmlns:xsi="http://www.w3.org/2001/XMLSchema"
xsi:noNamespaceSchemaLocation="config.xsd">
<servers>
<!-- 开发模式的地址。真实环境下删除这行。 -->
<server ip="127.0.0.1" port="2280" http-port="2281" />
<!-- <server ip="192.168.7.70" port="2280" /> -->
</servers>
</config>
<?xml version="1.0" encoding="utf-8"?>
<!-- 配置Cat服务器数据源。id为cat的是生产环境数据源,cat.qa是测试环境数据源,user是用户信息表。默认情况下使用cat库,也可以自行修改指向相应的表。 -->
<data-sources>
<data-source id="cat">
<maximum-pool-size>3</maximum-pool-size>
<connection-timeout>1s</connection-timeout>
<idle-timeout>10m</idle-timeout>
<statement-cache-size>1000</statement-cache-size>
<properties>
<driver>com.mysql.jdbc.Driver</driver>
<url><![CDATA[JDBC-URL]]></url>
<user>JDBC-USER</user>
<password>JDBC-PASSWORD</password>
<connectionProperties><![CDATA[useUnicode=true&autoReconnect=true]]></connectionProperties>
</properties>
</data-source>
<data-source id="cat.qa">
<maximum-pool-size>3</maximum-pool-size>
<connection-timeout>1s</connection-timeout>
<idle-timeout>10m</idle-timeout>
<statement-cache-size>1000</statement-cache-size>
<properties>
<driver>com.mysql.jdbc.Driver</driver>
<url><![CDATA[JDBC-URL]]></url>
<user>JDBC-USER</user>
<password>JDBC-PASSWORD</password>
<connectionProperties><![CDATA[useUnicode=true&autoReconnect=true]]></connectionProperties>
</properties>
</data-source>
<data-source id="user">
<maximum-pool-size>3</maximum-pool-size>
<connection-timeout>1s</connection-timeout>
<idle-timeout>10m</idle-timeout>
<statement-cache-size>1000</statement-cache-size>
<properties>
<driver>com.mysql.jdbc.Driver</driver>
<url><![CDATA[JDBC-URL]]></url>
<user>JDBC-USER</user>
<password>JDBC-PASSWORD</password>
<connectionProperties><![CDATA[useUnicode=true&autoReconnect=true]]></connectionProperties>
</properties>
</data-source>
</data-sources>
<!-- Cat服务器的配置文件。主要配置hadoop存储地址、消费机和控制台 -->
<config local-mode="true" job-machine="false">
<!-- 以下配置是Hadoop集群配置,请根据自身情况修改之 -->
<storage local-base-dir="/data/appdatas/cat/bucket/">
<hdfs id="logview" max-size="128M" server-uri="hdfs://10.1.77.86/user/cat" base-dir="logview"/>
<hdfs id="dump" max-size="128M" server-uri="hdfs://10.1.77.86/user/cat" base-dir="dump"/>
<hdfs id="remote" max-size="128M" server-uri="hdfs://10.1.77.86/user/cat" base-dir="remote"/>
<properties>
<property name="hadoop.security.authentication" value="kerberos"/>
<property name="dfs.namenode.kerberos.principal" value="hadoop/test86.hadoop@DIANPING.COM"/>
<property name="dfs.cat.kerberos.principal" value="cat@DIANPING.COM"/>
<property name="dfs.cat.keytab.file" value="/data/appdatas/cat/cat.keytab"/>
<property name="java.security.krb5.realm" value="DIANPING.COM"/>
<property name="java.security.krb5.kdc" value="192.168.7.80"/>
</properties>
</storage>
<!-- 以下配置是消费机集群配置,请根据自身情况修改之 -->
<consumer>
<long-config default-url-threshold="1000" default-sql-threshold="100">
<domain name="Cat" url-threshold="500" sql-threshold="40"/>
</long-config>
</consumer>
<!-- 以下是配置控制台配置,请根据自身情况修改之 -->
<console default-domain="Cat" show-cat-domain="true">
<!-- 添加多台consumer的地址,用逗号分隔 -->
<remote-servers>127.0.0.1:2281</remote-servers>
</console>
</config>
......@@ -15,6 +15,7 @@
<module>cat-hadoop</module>
<module>cat-consumer-advanced</module>
<module>cat-home</module>
<module>cat-maven-plugin</module>
<module>abtest-sample</module>
</modules>
<dependencyManagement>
......@@ -174,6 +175,11 @@ org.eclipse.jdt.core.compiler.compliance=1.6
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.dianping.cat</groupId>
<artifactId>cat-maven-plugin</artifactId>
<version>0.6.2</version>
</plugin>
</plugins>
</build>
<repositories>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册