From d278669aec97565d5695a584da53f384dde82085 Mon Sep 17 00:00:00 2001 From: youyong Date: Thu, 27 Sep 2012 21:58:50 +0800 Subject: [PATCH] modify the alarm page --- .../cat/consumer/matrix/MatrixAnalyzer.java | 7 +- .../java/com/dianping/cat/CatHomeModule.java | 3 + .../cat/build/ComponentsConfigurator.java | 13 +- .../cat/report/task/DailyTaskProducer.java | 22 +- .../cat/report/task/DefaultTaskConsumer.java | 22 +- .../cat/report/task/OtherJobReport.java | 382 ++++++++++++++++++ .../task/health/HealthReportCreator.java | 19 +- .../monthreport/MonthReportBuilderTask.java | 10 +- .../dianping/cat/system/page/alarm/Model.java | 7 + .../cat/system/page/alarm/Payload.java | 4 + .../resources/META-INF/plexus/components.xml | 12 + .../src/main/webapp/WEB-INF/tags/body.tag | 24 +- cat-home/src/main/webapp/css/alarm.css | 18 + cat-home/src/main/webapp/css/dtree.css | 34 ++ cat-home/src/main/webapp/img/base.gif | Bin 0 -> 1095 bytes cat-home/src/main/webapp/img/folder.gif | Bin 0 -> 372 bytes cat-home/src/main/webapp/img/join.gif | Bin 0 -> 69 bytes cat-home/src/main/webapp/img/joinbottom.gif | Bin 0 -> 66 bytes cat-home/src/main/webapp/img/menuarrow.gif | Bin 0 -> 68 bytes cat-home/src/main/webapp/img/minus.gif | Bin 0 -> 86 bytes cat-home/src/main/webapp/img/minusbottom.gif | Bin 0 -> 85 bytes .../src/main/webapp/img/nolines_minus.gif | Bin 0 -> 861 bytes cat-home/src/main/webapp/img/nolines_plus.gif | Bin 0 -> 870 bytes cat-home/src/main/webapp/img/page.gif | Bin 0 -> 582 bytes cat-home/src/main/webapp/js/dtree.js | 1 + cat-home/src/main/webapp/jsp/system/alarm.jsp | 40 +- src/main/conf/Cat.sql | 222 +++++----- 27 files changed, 679 insertions(+), 161 deletions(-) create mode 100644 cat-home/src/main/java/com/dianping/cat/report/task/OtherJobReport.java create mode 100644 cat-home/src/main/webapp/css/alarm.css create mode 100644 cat-home/src/main/webapp/css/dtree.css create mode 100644 cat-home/src/main/webapp/img/base.gif create mode 100644 cat-home/src/main/webapp/img/folder.gif create mode 100644 cat-home/src/main/webapp/img/join.gif create mode 100644 cat-home/src/main/webapp/img/joinbottom.gif create mode 100644 cat-home/src/main/webapp/img/menuarrow.gif create mode 100644 cat-home/src/main/webapp/img/minus.gif create mode 100644 cat-home/src/main/webapp/img/minusbottom.gif create mode 100644 cat-home/src/main/webapp/img/nolines_minus.gif create mode 100644 cat-home/src/main/webapp/img/nolines_plus.gif create mode 100644 cat-home/src/main/webapp/img/page.gif create mode 100644 cat-home/src/main/webapp/js/dtree.js diff --git a/cat-consumer/src/main/java/com/dianping/cat/consumer/matrix/MatrixAnalyzer.java b/cat-consumer/src/main/java/com/dianping/cat/consumer/matrix/MatrixAnalyzer.java index cba969f1a..c01c57cf2 100644 --- a/cat-consumer/src/main/java/com/dianping/cat/consumer/matrix/MatrixAnalyzer.java +++ b/cat-consumer/src/main/java/com/dianping/cat/consumer/matrix/MatrixAnalyzer.java @@ -211,7 +211,12 @@ public class MatrixAnalyzer extends AbstractMessageAnalyzer implem for (MatrixReport report : m_reports.values()) { try { - report.accept(new MatrixReportFilter(50)); + try { + report.accept(new MatrixReportFilter(50)); + } catch (Exception e) { + //ConcurrentModificationException + report.accept(new MatrixReportFilter(50)); + } Set domainNames = report.getDomainNames(); domainNames.clear(); domainNames.addAll(getDomains()); diff --git a/cat-home/src/main/java/com/dianping/cat/CatHomeModule.java b/cat-home/src/main/java/com/dianping/cat/CatHomeModule.java index 3d20aa846..dd2c9bb70 100644 --- a/cat-home/src/main/java/com/dianping/cat/CatHomeModule.java +++ b/cat-home/src/main/java/com/dianping/cat/CatHomeModule.java @@ -38,6 +38,9 @@ public class CatHomeModule extends AbstractModule { Threads.forGroup("Cat").start(taskConsumer); Threads.forGroup("Cat").start(monthReportTask); } + + //OtherJobReport tuangouMonth = ctx.lookup(OtherJobReport.class); + //Threads.forGroup("Cat").start(tuangouMonth); } @Override diff --git a/cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java b/cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java index c78fc9342..37dea78c1 100755 --- a/cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java +++ b/cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java @@ -23,6 +23,7 @@ import com.dianping.cat.report.page.health.HistoryGraphs; import com.dianping.cat.report.task.DailyTaskProducer; import com.dianping.cat.report.task.DefaultTaskConsumer; import com.dianping.cat.report.task.TaskConsumer; +import com.dianping.cat.report.task.OtherJobReport; import com.dianping.cat.report.task.cross.CrossMerger; import com.dianping.cat.report.task.cross.CrossReportBuilder; import com.dianping.cat.report.task.database.DatabaseMerger; @@ -87,7 +88,8 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator { all.add(C(SqlMerger.class)); all.add(C(TransactionReportBuilder.class) // - .req(GraphDao.class, ReportDao.class, DailyreportDao.class, TransactionGraphCreator.class, TransactionMerger.class)); + .req(GraphDao.class, ReportDao.class, DailyreportDao.class, TransactionGraphCreator.class, + TransactionMerger.class)); all.add(C(EventReportBuilder.class) // .req(GraphDao.class, ReportDao.class, DailyreportDao.class, EventGraphCreator.class, EventMerger.class)); @@ -96,7 +98,8 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator { .req(GraphDao.class, ReportDao.class, DailyreportDao.class, ProblemGraphCreator.class, ProblemMerger.class)); all.add(C(HeartbeatReportBuilder.class) // - .req(GraphDao.class, ReportDao.class, DailyreportDao.class, HeartbeatGraphCreator.class, HeartbeatMerger.class)); + .req(GraphDao.class, ReportDao.class, DailyreportDao.class, HeartbeatGraphCreator.class, + HeartbeatMerger.class)); all.add(C(MatrixReportBuilder.class) // .req(GraphDao.class, ReportDao.class, DailyreportDao.class, MatrixMerger.class)); @@ -137,11 +140,15 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator { all.add(C(ModuleManager.class, DefaultModuleManager.class) // .config(E("topLevelModules").value(CatHomeModule.ID))); + all.add(C(OtherJobReport.class).// + req(DailyreportDao.class, DomainManager.class)); + // model service all.addAll(new ServiceComponentConfigurator().defineComponents()); // database - all.add(C(JdbcDataSourceConfigurationManager.class).config(E("datasourceFile").value("/data/appdatas/cat/datasources.xml"))); + all.add(C(JdbcDataSourceConfigurationManager.class).config( + E("datasourceFile").value("/data/appdatas/cat/datasources.xml"))); all.addAll(new CatDatabaseConfigurator().defineComponents()); all.addAll(new UserDatabaseConfigurator().defineComponents()); diff --git a/cat-home/src/main/java/com/dianping/cat/report/task/DailyTaskProducer.java b/cat-home/src/main/java/com/dianping/cat/report/task/DailyTaskProducer.java index 26b158bda..524e4b95a 100644 --- a/cat-home/src/main/java/com/dianping/cat/report/task/DailyTaskProducer.java +++ b/cat-home/src/main/java/com/dianping/cat/report/task/DailyTaskProducer.java @@ -7,7 +7,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; @@ -24,6 +23,7 @@ import com.dianping.cat.home.dal.report.DailyreportEntity; import com.dianping.cat.message.Message; import com.dianping.cat.message.Transaction; import com.site.dal.jdbc.DalException; +import com.site.dal.jdbc.DalNotFoundException; import com.site.lookup.annotation.Inject; public class DailyTaskProducer implements com.site.helper.Threads.Task, Initializable { @@ -37,8 +37,6 @@ public class DailyTaskProducer implements com.site.helper.Threads.Task, Initiali private Set m_dailyReportNameSet = new HashSet(); - private Logger m_logger; - @Inject private ReportDao m_reportDao; @@ -51,8 +49,10 @@ public class DailyTaskProducer implements com.site.helper.Threads.Task, Initiali try { allReports = m_dailyReportDao.findDatabaseAllByPeriod(day, new Date(day.getTime() + DAY), DailyreportEntity.READSET_DOMAIN_NAME); + } catch (DalNotFoundException notFoundException) { + // Ignore } catch (DalException e) { - m_logger.warn("DailyTaskProducer isYesterdayTaskGenerated", e); + Cat.logError(e); } Set databaseSet = getDatabaseSet(day, new Date(day.getTime() + DAY)); @@ -70,8 +70,10 @@ public class DailyTaskProducer implements com.site.helper.Threads.Task, Initiali try { allReports = m_dailyReportDao.findAllByPeriod(day, new Date(day.getTime() + DAY), DailyreportEntity.READSET_DOMAIN_NAME); + } catch (DalNotFoundException notFoundException) { + // Ignore } catch (DalException e) { - m_logger.warn("DailyTaskProducer isYesterdayTaskGenerated", e); + Cat.logError(e); } Set domainSet = getDomainSet(day, new Date(day.getTime() + DAY)); @@ -191,6 +193,11 @@ public class DailyTaskProducer implements com.site.helper.Threads.Task, Initiali return domainSet; } + @Override + public String getName() { + return "DailyTask-Producer"; + } + @Override public void initialize() throws InitializationException { m_dailyReportNameSet.add("event"); @@ -226,11 +233,6 @@ public class DailyTaskProducer implements com.site.helper.Threads.Task, Initiali } } - @Override - public String getName() { - return "DailyTask-Producer"; - } - @Override public void shutdown() { } diff --git a/cat-home/src/main/java/com/dianping/cat/report/task/DefaultTaskConsumer.java b/cat-home/src/main/java/com/dianping/cat/report/task/DefaultTaskConsumer.java index faad65472..25531bd4c 100644 --- a/cat-home/src/main/java/com/dianping/cat/report/task/DefaultTaskConsumer.java +++ b/cat-home/src/main/java/com/dianping/cat/report/task/DefaultTaskConsumer.java @@ -45,15 +45,23 @@ public class DefaultTaskConsumer extends TaskConsumer { return task; } + @Override + public String getName() { + return "Task-Consumer"; + } + @Override protected boolean processTask(Task doing) { return m_reportFacade.builderReport(doing); } + @Override + public void shutdown() { + + } + @Override protected void taskNotFoundDuration() { - // Date awakeTime = TaskHelper.nextTaskTime(); - // LockSupport.parkUntil(awakeTime.getTime()); try { Thread.sleep(2 * 60 * 1000); } catch (InterruptedException e) { @@ -105,14 +113,4 @@ public class DefaultTaskConsumer extends TaskConsumer { return false; } } - - @Override - public String getName() { - return "Task-Consumer"; - } - - @Override - public void shutdown() { - - } } diff --git a/cat-home/src/main/java/com/dianping/cat/report/task/OtherJobReport.java b/cat-home/src/main/java/com/dianping/cat/report/task/OtherJobReport.java new file mode 100644 index 000000000..9076d8963 --- /dev/null +++ b/cat-home/src/main/java/com/dianping/cat/report/task/OtherJobReport.java @@ -0,0 +1,382 @@ +package com.dianping.cat.report.task; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import com.dianping.cat.Cat; +import com.dianping.cat.consumer.cross.model.entity.CrossReport; +import com.dianping.cat.consumer.health.model.entity.HealthReport; +import com.dianping.cat.consumer.health.model.transform.DefaultSaxParser; +import com.dianping.cat.consumer.transaction.model.entity.TransactionName; +import com.dianping.cat.consumer.transaction.model.entity.TransactionReport; +import com.dianping.cat.consumer.transaction.model.entity.TransactionType; +import com.dianping.cat.helper.TimeUtil; +import com.dianping.cat.home.dal.report.Dailyreport; +import com.dianping.cat.home.dal.report.DailyreportDao; +import com.dianping.cat.home.dal.report.DailyreportEntity; +import com.dianping.cat.report.page.cross.DomainManager; +import com.dianping.cat.report.page.cross.display.ProjectInfo; +import com.dianping.cat.report.page.cross.display.TypeDetailInfo; +import com.dianping.cat.report.page.model.cross.CrossReportMerger; +import com.dianping.cat.report.page.model.transaction.TransactionReportMerger; +import com.dianping.cat.report.task.health.HealthReportMerger; +import com.site.helper.Threads.Task; +import com.site.lookup.annotation.Inject; + +public class OtherJobReport implements Task { + + @Inject + private DailyreportDao m_dailyreportDao; + + @Inject + private DomainManager m_domainManager; + + private SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); + + private void buildOtherDomainCrossInfo(String domain, Date start, Date end, List domains) { + for (long current = start.getTime(); current < end.getTime(); current += TimeUtil.ONE_DAY) { + Date startDate = new Date(current); + Date endDate = new Date(current + TimeUtil.ONE_DAY); + + CrossReport crossReport = queryCrossReport(startDate, endDate, domain); + System.out.print(sdf.format(startDate) + "\t"); + for (String otherDomain : domains) { + Indicator otherDomainIndicator = getOtherDomainCrossInfo(otherDomain, crossReport); + System.out.print(otherDomainIndicator); + } + System.out.println(); + } + } + + private void buildServiceDetailInfo(String domain, Date start, Date end, List functionNames) { + for (long current = start.getTime(); current < end.getTime(); current += TimeUtil.ONE_DAY) { + Date startDate = new Date(current); + Date endDate = new Date(current + TimeUtil.ONE_DAY); + TransactionReport transactionReport = queryTransactionReport(startDate, endDate, domain); + System.out.print(sdf.format(startDate) + "\t"); + for (String functionName : functionNames) { + Indicator functionIndicator = getFunctionDetailIndicator(functionName, transactionReport); + System.out.print(functionIndicator); + } + System.out.println(); + } + } + + private void buildServiceTotalInfo(String domain, Date start, Date end) { + System.out.println(domain + " Service Info >>>>>>>>"); + for (long current = start.getTime(); current < end.getTime(); current += TimeUtil.ONE_DAY) { + Date startDate = new Date(current); + Date endDate = new Date(current + TimeUtil.ONE_DAY); + TransactionReport transactionReport = queryTransactionReport(startDate, endDate, domain); + HealthReport healthReport = queryHealthReport(startDate, endDate, domain); + + Indicator indicator = getServiceTotalIndicator(transactionReport, healthReport); + System.out.println(sdf.format(startDate) + '\t' + indicator); + } + } + + private void buildUrlDetailsInfo(String domain, Date start, Date end, List urls) { + for (long current = start.getTime(); current < end.getTime(); current += TimeUtil.ONE_DAY) { + Date startDate = new Date(current); + Date endDate = new Date(current + TimeUtil.ONE_DAY); + TransactionReport transactionReport = queryTransactionReport(startDate, endDate, domain); + System.out.print(sdf.format(startDate) + "\t"); + for (String url : urls) { + Indicator functionIndicator = getUrlDetailIndicator(transactionReport, url); + System.out.print(functionIndicator); + } + System.out.println(); + } + } + + private void buildUrlTotalInfo(String domain, Date start, Date end) { + System.out.println(domain + " Url Info"); + for (long current = start.getTime(); current < end.getTime(); current += TimeUtil.ONE_DAY) { + Date startDate = new Date(current); + Date endDate = new Date(current + TimeUtil.ONE_DAY); + TransactionReport transactionReport = queryTransactionReport(startDate, endDate, domain); + + Indicator indicator = getUrlTotalIndicator(transactionReport); + System.out.println(sdf.format(startDate) + '\t' + indicator); + } + } + + public Date calMonthFirstDay(int step) { + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.DAY_OF_MONTH, 1); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + cal.add(Calendar.MONTH, step); + return cal.getTime(); + } + + private Indicator getFunctionDetailIndicator(String functionName, TransactionReport report) { + TransactionType type = getPigeonServiceTransaction(report); + Indicator indicator = new Indicator(); + + if (type != null) { + TransactionName name = type.findName(functionName); + if (name == null) { + int index = functionName.indexOf("("); + if (index > 0) { + functionName = functionName.substring(0, index); + name = type.findName(functionName); + } + } + if (name != null) { + indicator.setTotalCount(name.getTotalCount()); + indicator.set95Line(name.getLine95Value()); + indicator.setAvg(name.getAvg()); + indicator.setFailureCount(name.getFailCount()); + } + } + return indicator; + } + + @Override + public String getName() { + return "TuanGouRemote"; + } + + private Indicator getOtherDomainCrossInfo(String otherDomain, CrossReport report) { + ProjectInfo projectInfo = new ProjectInfo(TimeUtil.ONE_HOUR); + projectInfo.setDomainManager(m_domainManager); + projectInfo.setClientIp("All"); + projectInfo.visitCrossReport(report); + + List types = projectInfo.getServiceProjectsInfo(); + + Indicator indicator = new Indicator(); + for (TypeDetailInfo info : types) { + if (info.getProjectName().equals(otherDomain)) { + indicator.setAvg(info.getAvg()); + indicator.setTotalCount(info.getTotalCount()); + indicator.setFailureCount(info.getTotalCount()); + break; + } + } + return indicator; + } + + private TransactionType getPigeonServiceTransaction(TransactionReport report) { + TransactionType type = report.findOrCreateMachine("All").getTypes().get("Service"); + if (type == null) { + type = report.getMachines().get("All").getTypes().get("PigeonService"); + } + String pigeonName = "piegonService:heartTaskService:heartBeat()"; + + if (type != null) { + TransactionName name = type.findName(pigeonName); + if (name == null) { + name = type.findName("piegonService:heartTaskService:heartBeat"); + } + if (name != null) { + type.setTotalCount(type.getTotalCount() - name.getTotalCount()); + double sum = type.getSum() - name.getSum(); + type.setAvg(sum / type.getTotalCount()); + } + } + return type; + } + + private Indicator getServiceTotalIndicator(TransactionReport transactionReport, HealthReport healthReport) { + TransactionType type = getPigeonServiceTransaction(transactionReport); + + Indicator indicator = new Indicator(); + if (type != null) { + indicator.set95Line(type.getLine95Value()); + indicator.setAvg(type.getAvg()); + indicator.setTotalCount(type.getTotalCount()); + } + + try { + indicator.setFailureCount(healthReport.getClientService().getBaseInfo().getErrorTotal()); + } catch (Exception e) { + } + return indicator; + } + + private Indicator getUrlDetailIndicator(TransactionReport transactionReport, String detailUrl) { + TransactionType type = transactionReport.findOrCreateMachine("All").findType("URL"); + + Indicator indicator = new Indicator(); + if (type != null) { + TransactionName name = type.findName(detailUrl); + if (name != null) { + + indicator.set95Line(name.getLine95Value()); + indicator.setAvg(name.getAvg()); + indicator.setTotalCount(name.getTotalCount()); + indicator.setFailureCount(name.getFailCount()); + } + } + return indicator; + } + + private Indicator getUrlTotalIndicator(TransactionReport transactionReport) { + TransactionType type = transactionReport.findOrCreateMachine("All").findType("URL"); + + Indicator indicator = new Indicator(); + if (type != null) { + indicator.set95Line(type.getLine95Value()); + indicator.setAvg(type.getAvg()); + indicator.setTotalCount(type.getTotalCount()); + indicator.setFailureCount(type.getFailCount()); + } + return indicator; + } + + public CrossReport queryCrossReport(Date start, Date end, String domain) { + CrossReport crossReport = null; + try { + List reports = m_dailyreportDao.findAllByDomainNameDuration(start, end, domain, "cross", + DailyreportEntity.READSET_FULL); + CrossReportMerger merger = new CrossReportMerger(new CrossReport(domain)); + for (Dailyreport report : reports) { + String xml = report.getContent(); + CrossReport reportModel = com.dianping.cat.consumer.cross.model.transform.DefaultSaxParser.parse(xml); + reportModel.accept(merger); + } + crossReport = merger.getCrossReport(); + } catch (Exception e) { + Cat.logError(e); + } + return crossReport; + } + + private HealthReport queryHealthReport(Date startDate, Date endDate, String domain) { + try { + List reports = m_dailyreportDao.findAllByDomainNameDuration(startDate, endDate, domain, "health", + DailyreportEntity.READSET_FULL); + HealthReportMerger merger = new HealthReportMerger(new HealthReport(domain)); + HealthReport healthReport = merger.getHealthReport(); + merger.setDuration(endDate.getTime() - startDate.getTime()); + + for (Dailyreport report : reports) { + String xml = report.getContent(); + HealthReport model = DefaultSaxParser.parse(xml); + model.accept(merger); + healthReport.getDomainNames().addAll(model.getDomainNames()); + } + return healthReport; + } catch (Exception e) { + Cat.logError(e); + } + return new HealthReport(domain); + } + + private TransactionReport queryTransactionReport(Date startDate, Date endDate, String domain) { + TransactionReport transactionReport = null; + try { + List reports = m_dailyreportDao.findAllByDomainNameDuration(startDate, endDate, domain, + "transaction", DailyreportEntity.READSET_FULL); + TransactionReportMerger merger = new TransactionReportMerger(new TransactionReport(domain)); + for (Dailyreport report : reports) { + String xml = report.getContent(); + TransactionReport reportModel = com.dianping.cat.consumer.transaction.model.transform.DefaultSaxParser + .parse(xml); + reportModel.accept(merger); + } + transactionReport = merger.getTransactionReport(); + } catch (Exception e) { + Cat.logError(e); + } + return transactionReport; + } + + @Override + public void run() { + Date lastMonth = calMonthFirstDay(-2); + Date nextMonth = calMonthFirstDay(1); + List otherDomains = new ArrayList(); + List urls = new ArrayList(); + String domain = "TuanGouRemote"; + otherDomains.add("MobileApi"); + otherDomains.add("TuanGouWeb"); + otherDomains.add("TuanGouApiMobile"); + otherDomains.add("ShopWeb"); + + List functionNames = new ArrayList(); + functionNames.add("dealRemoteService:dealRemoteService_1.0.0:getDeal(Integer)"); + functionNames.add("dealGroupRemoteService:dealGroupRemoteService_1.0.0:getActiveDealGroupList(DealListRequest)"); + functionNames.add("receiptRemoteService:receiptRemoteService_1.0.0:getReceiptList(Integer,Integer,Boolean)"); + + try { + Thread.sleep(1000 * 2); + } catch (InterruptedException e) { + } + buildServiceTotalInfo(domain, lastMonth, nextMonth); + buildServiceDetailInfo(domain, lastMonth, nextMonth, functionNames); + buildOtherDomainCrossInfo(domain, lastMonth, nextMonth, otherDomains); + + domain = "TuanGouWeb"; + urls.add("/index"); + urls.add("/detail"); + buildUrlTotalInfo(domain, lastMonth, nextMonth); + buildUrlDetailsInfo(domain, lastMonth, nextMonth, urls); + + domain = "BCTuangouWeb"; + buildUrlTotalInfo(domain, lastMonth, nextMonth); + domain = "TuanGouApi"; + buildUrlTotalInfo(domain, lastMonth, nextMonth); + domain = "TuanGouApiMobile"; + buildUrlTotalInfo(domain, lastMonth, nextMonth); + + } + + @Override + public void shutdown() { + } + + public static class Indicator { + private long m_totalCount; + + private long m_failureCount; + + private double m_avg; + + private double m_95Line; + + public double get95Line() { + return m_95Line; + } + + public double getAvg() { + return m_avg; + } + + public long getFailureCount() { + return m_failureCount; + } + + public long getTotalCount() { + return m_totalCount; + } + + public void set95Line(double line) { + m_95Line = line; + } + + public void setAvg(double avg) { + m_avg = avg; + } + + public void setFailureCount(long failureCount) { + m_failureCount = failureCount; + } + + public void setTotalCount(long totalCount) { + m_totalCount = totalCount; + } + + public String toString() { + return new StringBuilder().append(m_totalCount).append('\t').append(m_failureCount).append('\t').append(m_avg) + .append('\t').append(m_95Line).append('\t').toString(); + } + } +} diff --git a/cat-home/src/main/java/com/dianping/cat/report/task/health/HealthReportCreator.java b/cat-home/src/main/java/com/dianping/cat/report/task/health/HealthReportCreator.java index 7692c7393..90c03a6ba 100644 --- a/cat-home/src/main/java/com/dianping/cat/report/task/health/HealthReportCreator.java +++ b/cat-home/src/main/java/com/dianping/cat/report/task/health/HealthReportCreator.java @@ -167,6 +167,18 @@ public class HealthReportCreator { m_healthReport.setMachineInfo(info); } + private double queryOldgcNumber(com.dianping.cat.consumer.heartbeat.model.entity.Machine machine){ + double oldgcTotal =0; + List periods = machine.getPeriods(); + long l = periods.get(periods.size() - 1).getOldGcCount() - periods.get(0).getOldGcCount(); + if (l >= 0) { + oldgcTotal = l; + } else { + oldgcTotal = periods.get(periods.size() - 1).getOldGcCount(); + } + return oldgcTotal; + } + private void buildMachinInfos(MachineInfo info, HeartbeatReport heartBeatReport) { Map loads = new HashMap(); Map gcs = new HashMap(); @@ -186,12 +198,7 @@ public class HealthReportCreator { int i = 0; List periods = machine.getPeriods(); - long l = periods.get(periods.size() - 1).getOldGcCount() - periods.get(0).getOldGcCount(); - if (l > 0) { - oldgcTotal = l; - } else { - oldgcTotal = periods.get(periods.size() - 1).getOldGcCount(); - } + oldgcTotal = queryOldgcNumber(machine); for (; i < periods.size(); i++) { loadTotal += periods.get(i).getSystemLoadAverage(); diff --git a/cat-home/src/main/java/com/dianping/cat/report/task/monthreport/MonthReportBuilderTask.java b/cat-home/src/main/java/com/dianping/cat/report/task/monthreport/MonthReportBuilderTask.java index 51c7c6846..63804080e 100644 --- a/cat-home/src/main/java/com/dianping/cat/report/task/monthreport/MonthReportBuilderTask.java +++ b/cat-home/src/main/java/com/dianping/cat/report/task/monthreport/MonthReportBuilderTask.java @@ -29,6 +29,7 @@ import com.dianping.cat.report.page.model.problem.ProblemReportMerger; import com.dianping.cat.report.page.model.transaction.TransactionReportMerger; import com.dianping.cat.report.task.TaskHelper; import com.site.dal.jdbc.DalException; +import com.site.dal.jdbc.DalNotFoundException; import com.site.helper.Threads.Task; import com.site.lookup.annotation.Inject; @@ -50,7 +51,7 @@ public class MonthReportBuilderTask implements Task { MonthReportBuilder builder = new MonthReportBuilder(); MonthReport report = builder.build(transactionReport, eventReport, problemReport); - + report.setStartTime(start); report.setEndTime(end); return report; @@ -120,8 +121,9 @@ public class MonthReportBuilderTask implements Task { for (Monthreport report : monthreports) { domains.add(report.getDomain()); } + } catch (DalNotFoundException e1) { } catch (DalException e) { - e.printStackTrace(); + Cat.logError(e); } return domains; @@ -211,12 +213,13 @@ public class MonthReportBuilderTask implements Task { Date currentMonth = getMonthFirstDay(0); Set allDomains = getAllDomains(lastMonth, currentMonth); List createdDomains = getMonthReportCreatedDomin(lastMonth); - + for (String temp : createdDomains) { allDomains.remove(temp); } for (String domain : allDomains) { Transaction t = Cat.newTransaction("MonthReport", domain); + t.setStatus(Transaction.SUCCESS); try { MonthReport report = buildMonthReport(domain, lastMonth, currentMonth); @@ -227,7 +230,6 @@ public class MonthReportBuilderTask implements Task { entity.setPeriod(lastMonth); m_monthreportDao.insert(entity); - t.setStatus(Transaction.SUCCESS); } catch (Exception e) { Cat.logError(e); t.setStatus(e); diff --git a/cat-home/src/main/java/com/dianping/cat/system/page/alarm/Model.java b/cat-home/src/main/java/com/dianping/cat/system/page/alarm/Model.java index add217460..7375947cb 100644 --- a/cat-home/src/main/java/com/dianping/cat/system/page/alarm/Model.java +++ b/cat-home/src/main/java/com/dianping/cat/system/page/alarm/Model.java @@ -12,4 +12,11 @@ public class Model extends ViewModel { public Action getDefaultAction() { return Action.VIEW; } + + public String getDomain(){ + return ""; + } + public String getDate(){ + return ""; + } } diff --git a/cat-home/src/main/java/com/dianping/cat/system/page/alarm/Payload.java b/cat-home/src/main/java/com/dianping/cat/system/page/alarm/Payload.java index e59b5c2d4..fcd062fa4 100644 --- a/cat-home/src/main/java/com/dianping/cat/system/page/alarm/Payload.java +++ b/cat-home/src/main/java/com/dianping/cat/system/page/alarm/Payload.java @@ -30,6 +30,10 @@ public class Payload implements ActionPayload { m_page = SystemPage.getByName(page, SystemPage.ALARM); } + public String getReportType(){ + return ""; + } + @Override public void validate(ActionContext ctx) { } diff --git a/cat-home/src/main/resources/META-INF/plexus/components.xml b/cat-home/src/main/resources/META-INF/plexus/components.xml index 2e55704f1..92a91d1f0 100755 --- a/cat-home/src/main/resources/META-INF/plexus/components.xml +++ b/cat-home/src/main/resources/META-INF/plexus/components.xml @@ -367,6 +367,18 @@ cat-home + + com.dianping.cat.report.task.OtherJobReport + com.dianping.cat.report.task.OtherJobReport + + + com.dianping.cat.home.dal.report.DailyreportDao + + + com.dianping.cat.report.page.cross.DomainManager + + + com.dianping.cat.report.page.model.spi.ModelService transaction-local diff --git a/cat-home/src/main/webapp/WEB-INF/tags/body.tag b/cat-home/src/main/webapp/WEB-INF/tags/body.tag index d8967ba4d..c6e201e2e 100755 --- a/cat-home/src/main/webapp/WEB-INF/tags/body.tag +++ b/cat-home/src/main/webapp/WEB-INF/tags/body.tag @@ -29,18 +29,18 @@ - <%-- --%> + diff --git a/cat-home/src/main/webapp/css/alarm.css b/cat-home/src/main/webapp/css/alarm.css new file mode 100644 index 000000000..1cb3ea2e3 --- /dev/null +++ b/cat-home/src/main/webapp/css/alarm.css @@ -0,0 +1,18 @@ +.body-content { + height: 1200px; + text-align: left; + width: 100%; +} + +.content-left { + float: left; + width: 15%; + text-indent: 1em; + height: 1200px; + text-align: left; +} + +.content-right { + float: left; + width: 85%; +} \ No newline at end of file diff --git a/cat-home/src/main/webapp/css/dtree.css b/cat-home/src/main/webapp/css/dtree.css new file mode 100644 index 000000000..5e89a482c --- /dev/null +++ b/cat-home/src/main/webapp/css/dtree.css @@ -0,0 +1,34 @@ +.dtree { + font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; + font-size: 13px; + color: #666; + white-space: nowrap; +} + +.dtree img { + border: 0px; + vertical-align: middle; +} + +.dtree a { + color: #333; + text-decoration: none; +} + +.dtree a.node,.dtree a.nodeSel { + white-space: nowrap; + padding: 1px 2px 1px 2px; +} + +.dtree a.node:hover,.dtree a.nodeSel:hover { + color: #333; + text-decoration: underline; +} + +.dtree a.nodeSel { + background-color: #c0d2ec; +} + +.dtree .clip { + overflow: hidden; +} \ No newline at end of file diff --git a/cat-home/src/main/webapp/img/base.gif b/cat-home/src/main/webapp/img/base.gif new file mode 100644 index 0000000000000000000000000000000000000000..57123d0e69310db17f0c248cd291009a3cb2dd93 GIT binary patch literal 1095 zcmcK3`8(SO9KiAKCkG~uV;mw0cLrC^)_Z0DGV33b1Po(Sa(>zf!o}J1>$0ZL+5}+6JHr`< zs59<2ADD$k0dv7VSPBs!85|83W2YWrU{mu%Hi8cua%jT}X0VKs8iV_@s~cN|4IQK7 zlgwVZniU_ug+va|$vdW0wiwXo*|ykB@De?HwLlJxC0N(!S8i(2E~|v9(_+$dE1QD4 z(6NQB0}P|~wBw2sEI5NRJ4=uuOa5tsBHg+7q6Hu5dC6C#RV~P$5g9p@LhLx0zT1=#$;61Slp z{b$G3Cq5tj+aRnLm}j%g>meJip=3z4fBc6cC?X}jzdC>`>6~1Hyp7=2MId*?rsV_o z0IrGVmN!ePo4-uR0e|!Ywb#GtFWpGfTw^6849G2ChCzJ@XGmPPTIixuZ>)mYL-;TxSo$E#hk&Ui;z3lE682RvPTxRDt7BWAb0m{VSvJ=cgb~yz@9V5_O(cZFI)`$`ISCTU`DjBw zyS8egLnhurnWUI?_PR)I7%9~+D!e_EXKRJ1r3zig4{K%xOvx2|%18b>$me4+u^7Xq I@p#1QKgm$!SpWb4 literal 0 HcmV?d00001 diff --git a/cat-home/src/main/webapp/img/folder.gif b/cat-home/src/main/webapp/img/folder.gif new file mode 100644 index 0000000000000000000000000000000000000000..eb129763dcea0dc1916b7e934fdce2fd8770c380 GIT binary patch literal 372 zcmZ?wbhEHb6k-r!xXQrr`}gnn@893v9&~1=$&)8f4jw$XxRCo$zt;Bc+vnx5?P^z= zlf`m!n&I9q)y<94Gt(JwZ!g^1B)cGw zMSgXq@QJAg2YNM*9XqzJMr>9F(~2^IHB}=2ujK##G5PiD*Z=>|`G33g|C9Rv?>o0` z+x8y>W-^ck6o0ZXGBD^d=zw&C{KUXE(P4UlhmKVLi6xgzC4402GB{W!L~2f9POOq~ zU`a4ovhaqB%+vz~Nx8dkFFrrvqSej!Kd!MF9@+A*p|PG#+gVIkwX>^RSE$vAT~}-J zl&QL${d#h`nsevP*X5qctE;hW`3hadnOwRm>o;uF<*#vKOczy ZVbwl)>NG2h3j?FtrOQ`>yuBP5tO0@?i&Ovr literal 0 HcmV?d00001 diff --git a/cat-home/src/main/webapp/img/join.gif b/cat-home/src/main/webapp/img/join.gif new file mode 100644 index 0000000000000000000000000000000000000000..34dd47610a5d7c3580dedc342683559bf77abce2 GIT binary patch literal 69 zcmZ?wbhEHb6k-r!XkcV$XlVHV|G(l-7DfgJMg|=QAOOiQFv;}DH=KUEdfpt3ORshA Wx&LIzk};W<vKC_i literal 0 HcmV?d00001 diff --git a/cat-home/src/main/webapp/img/joinbottom.gif b/cat-home/src/main/webapp/img/joinbottom.gif new file mode 100644 index 0000000000000000000000000000000000000000..48b81c80a9e25f6f29e2614aaa33bdf4a4d2881b GIT binary patch literal 66 zcmZ?wbhEHb6k-r!XkcV$XlVHV|G(l-7DfgJMg|=QAOOiQFiG~vH=KUEdfpt3ORshA Tx&LIzy5lkJS?4l0Mh0sDgH;v` literal 0 HcmV?d00001 diff --git a/cat-home/src/main/webapp/img/menuarrow.gif b/cat-home/src/main/webapp/img/menuarrow.gif new file mode 100644 index 0000000000000000000000000000000000000000..ed2dee0e6368d201bf5d32833884c7c1da6c7424 GIT binary patch literal 68 zcmZ?wbhEHbWM^Py_{hZ2(9rPi-LwDy|1&T!DE?$&WME)o&;ha;K=KSsqAVN&i(DE6 VRJ~d>0vEY-3aNTcS;53$4FHxP5xxKb literal 0 HcmV?d00001 diff --git a/cat-home/src/main/webapp/img/minus.gif b/cat-home/src/main/webapp/img/minus.gif new file mode 100644 index 0000000000000000000000000000000000000000..3d212a97ae0d8f83aa39836c5a85d442f8602553 GIT binary patch literal 86 zcmZ?wbhEHb6k-r!n8?h~)YR0_(7?dJ@c;jR#h)yU3=GT+IzTQ^R)~RtNqvreafzu-gC3m_gnAtsyGG)YXIxA8@>Pl literal 0 HcmV?d00001 diff --git a/cat-home/src/main/webapp/img/nolines_minus.gif b/cat-home/src/main/webapp/img/nolines_minus.gif new file mode 100644 index 0000000000000000000000000000000000000000..2592ac20f3f4c28e38f789309ec52f08505bdf6e GIT binary patch literal 861 zcmZ?wbhEHb6k-r!_|DAG)YR0_(7-SXMnhmkhJfNv7DfgJW(FOQ??HKjfy0V{okPZB z!-9j&9Ku>LGYlFIxARNO@hDtWaBUIiPTOMfV7_}lvsu=hh(Z;&NfL@qDJM29Jw4q( Jn2m+O8UP#&8=e3F literal 0 HcmV?d00001 diff --git a/cat-home/src/main/webapp/img/nolines_plus.gif b/cat-home/src/main/webapp/img/nolines_plus.gif new file mode 100644 index 0000000000000000000000000000000000000000..f258ce211a0a19c2ecbcb11170b9a8b35ae2436c GIT binary patch literal 870 zcmZ?wbhEHb6k-r!_|DAG)YR0_(7-SXMnhmkhJfNv7DfgJW(FOQ??HKjfy0@BokPZB z!-9j&9Ku>LGYlFIxARNO@hAj7*xx83m?l#Y_`t1M|Ba{La?4kwX3c6}c&WZ`PygnpJ?rkDyZry# zum9<}^Zxw(U)#BD%KlHsjvf2=@89j`-!lsq`N~Rn2+cXw3F)`cNXo|{M zwn^yh*lA;L&u+56RaJ{?r=8t#bK_Gj;^%BG95Yu?zS_*U>z2K_g$4ipCbgRvpFHC> zdg-Vu`PTd?H;48ok#7ReIGiR-xW0J7!Dc}Y2`z_&_QUOboFWD+3JrbT68dFMM=k~^ HFjxZso}Jb2 literal 0 HcmV?d00001 diff --git a/cat-home/src/main/webapp/js/dtree.js b/cat-home/src/main/webapp/js/dtree.js new file mode 100644 index 000000000..b9b6d9d8e --- /dev/null +++ b/cat-home/src/main/webapp/js/dtree.js @@ -0,0 +1 @@ +function Node(id, pid, name, url, title, target, icon, iconOpen, open) { this.id = id; this.pid = pid; this.name = name; this.url = url; this.title = title; this.target = target; this.icon = icon; this.iconOpen = iconOpen; this._io = open || false; this._is = false; this._ls = false; this._hc = false; this._ai = 0; this._p; }; // Tree object function dTree(objName) { this.config = { target : null, folderLinks : true, useSelection : true, useCookies : true, useLines : true, useIcons : true, useStatusText : false, closeSameLevel : false, inOrder : false }; this.icon = { root : '/cat/img/base.gif', folder : '/cat/img/folder.gif', folderOpen : '/cat/img/folderopen.gif', node : '/cat/img/page.gif', empty : '/cat/img/empty.gif', line : '/cat/img/line.gif', join : '/cat/img/join.gif', joinBottom : '/cat/img/joinbottom.gif', plus : '/cat/img/plus.gif', plusBottom : '/cat/img/plusbottom.gif', minus : '/cat/img/minus.gif', minusBottom : '/cat/img/minusbottom.gif', nlPlus : '/cat/img/nolines_plus.gif', nlMinus : '/cat/img/nolines_minus.gif' }; this.obj = objName; this.aNodes = []; this.aIndent = []; this.root = new Node(-1); this.selectedNode = null; this.selectedFound = false; this.completed = false; }; // Adds a new node to the node array dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) { this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open); }; // Open/close all nodes dTree.prototype.openAll = function() { this.oAll(true); }; dTree.prototype.closeAll = function() { this.oAll(false); }; // Outputs the tree to the page dTree.prototype.toString = function() { var str = '
\n'; if (document.getElementById) { if (this.config.useCookies) this.selectedNode = this.getSelected(); str += this.addNode(this.root); } else str += 'Browser not supported.'; str += '
'; if (!this.selectedFound) this.selectedNode = null; this.completed = true; return str; }; // Creates the tree structure dTree.prototype.addNode = function(pNode) { var str = ''; var n = 0; if (this.config.inOrder) n = pNode._ai; for (n; n < this.aNodes.length; n++) { if (this.aNodes[n].pid == pNode.id) { var cn = this.aNodes[n]; cn._p = pNode; cn._ai = n; this.setCS(cn); if (!cn.target && this.config.target) cn.target = this.config.target; if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id); if (!this.config.folderLinks && cn._hc) cn.url = null; if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) { cn._is = true; this.selectedNode = n; this.selectedFound = true; } str += this.node(cn, n); if (cn._ls) break; } } return str; }; // Creates the node icon, url and text dTree.prototype.node = function(node, nodeId) { var str = '
' + this.indent(node, nodeId); if (this.config.useIcons) { if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node); if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node; if (this.root.id == node.pid) { node.icon = this.icon.root; node.iconOpen = this.icon.root; } str += ''; } if (node.url) { str += ''; str += node.name; if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += ''; str += '
'; if (node._hc) { str += '
'; str += this.addNode(node); str += '
'; } this.aIndent.pop(); return str; }; // Adds the empty and line icons dTree.prototype.indent = function(node, nodeId) { var str = ''; if (this.root.id != node.pid) { for ( var n = 0; n < this.aIndent.length; n++) str += ''; (node._ls) ? this.aIndent.push(0) : this.aIndent.push(1); if (node._hc) { str += ''; } else str += ''; } return str; }; // Checks if a node has any children and if it is the last sibling dTree.prototype.setCS = function(node) { var lastId; for ( var n = 0; n < this.aNodes.length; n++) { if (this.aNodes[n].pid == node.id) node._hc = true; if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id; } if (lastId == node.id) node._ls = true; }; // Returns the selected node dTree.prototype.getSelected = function() { var sn = this.getCookie('cs' + this.obj); return (sn) ? sn : null; }; // Highlights the selected node dTree.prototype.s = function(id) { if (!this.config.useSelection) return; var cn = this.aNodes[id]; if (cn._hc && !this.config.folderLinks) return; if (this.selectedNode != id) { if (this.selectedNode || this.selectedNode == 0) { eOld = document.getElementById("s" + this.obj + this.selectedNode); eOld.className = "node"; } eNew = document.getElementById("s" + this.obj + id); eNew.className = "nodeSel"; this.selectedNode = id; if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id); } }; // Toggle Open or close dTree.prototype.o = function(id) { var cn = this.aNodes[id]; this.nodeStatus(!cn._io, id, cn._ls); cn._io = !cn._io; if (this.config.closeSameLevel) this.closeLevel(cn); if (this.config.useCookies) this.updateCookie(); }; // Open or close all nodes dTree.prototype.oAll = function(status) { for ( var n = 0; n < this.aNodes.length; n++) { if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) { this.nodeStatus(status, n, this.aNodes[n]._ls); this.aNodes[n]._io = status; } } if (this.config.useCookies) this.updateCookie(); }; // Opens the tree to a specific node dTree.prototype.openTo = function(nId, bSelect, bFirst) { if (!bFirst) { for ( var n = 0; n < this.aNodes.length; n++) { if (this.aNodes[n].id == nId) { nId = n; break; } } } var cn = this.aNodes[nId]; if (cn.pid == this.root.id || !cn._p) return; cn._io = true; cn._is = bSelect; if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls); if (this.completed && bSelect) this.s(cn._ai); else if (bSelect) this._sn = cn._ai; this.openTo(cn._p._ai, false, true); }; // Closes all nodes on the same level as certain node dTree.prototype.closeLevel = function(node) { for ( var n = 0; n < this.aNodes.length; n++) { if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) { this.nodeStatus(false, n, this.aNodes[n]._ls); this.aNodes[n]._io = false; this.closeAllChildren(this.aNodes[n]); } } }; // Closes all children of a node dTree.prototype.closeAllChildren = function(node) { for ( var n = 0; n < this.aNodes.length; n++) { if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) { if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls); this.aNodes[n]._io = false; this.closeAllChildren(this.aNodes[n]); } } }; // Change the status of a node(open or closed) dTree.prototype.nodeStatus = function(status, id, bottom) { eDiv = document.getElementById('d' + this.obj + id); eJoin = document.getElementById('j' + this.obj + id); if (this.config.useIcons) { eIcon = document.getElementById('i' + this.obj + id); eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon; } eJoin.src = (this.config.useLines) ? ((status) ? ((bottom) ? this.icon.minusBottom : this.icon.minus) : ((bottom) ? this.icon.plusBottom : this.icon.plus)) : ((status) ? this.icon.nlMinus : this.icon.nlPlus); eDiv.style.display = (status) ? 'block' : 'none'; }; // [Cookie] Clears a cookie dTree.prototype.clearCookie = function() { var now = new Date(); var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24); this.setCookie('co' + this.obj, 'cookieValue', yesterday); this.setCookie('cs' + this.obj, 'cookieValue', yesterday); }; // [Cookie] Sets value in a cookie dTree.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) { document.cookie = escape(cookieName) + '=' + escape(cookieValue) + (expires ? '; expires=' + expires.toGMTString() : '') + (path ? '; path=' + path : '') + (domain ? '; domain=' + domain : '') + (secure ? '; secure' : ''); }; // [Cookie] Gets a value from a cookie dTree.prototype.getCookie = function(cookieName) { var cookieValue = ''; var posName = document.cookie.indexOf(escape(cookieName) + '='); if (posName != -1) { var posValue = posName + (escape(cookieName) + '=').length; var endPos = document.cookie.indexOf(';', posValue); if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos)); else cookieValue = unescape(document.cookie.substring(posValue)); } return (cookieValue); }; // [Cookie] Returns ids of open nodes as a string dTree.prototype.updateCookie = function() { var str = ''; for ( var n = 0; n < this.aNodes.length; n++) { if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) { if (str) str += '.'; str += this.aNodes[n].id; } } this.setCookie('co' + this.obj, str); }; // [Cookie] Checks if a node id is in a cookie dTree.prototype.isOpen = function(id) { var aOpen = this.getCookie('co' + this.obj).split('.'); for ( var n = 0; n < aOpen.length; n++) if (aOpen[n] == id) return true; return false; }; // If Push and pop is not implemented by the browser if (!Array.prototype.push) { Array.prototype.push = function array_push() { for ( var i = 0; i < arguments.length; i++) this[this.length] = arguments[i]; return this.length; }; }; if (!Array.prototype.pop) { Array.prototype.pop = function array_pop() { lastElement = this[this.length - 1]; this.length = Math.max(this.length - 1, 0); return lastElement; }; }; \ No newline at end of file diff --git a/cat-home/src/main/webapp/jsp/system/alarm.jsp b/cat-home/src/main/webapp/jsp/system/alarm.jsp index 37b33c70e..095c935ba 100644 --- a/cat-home/src/main/webapp/jsp/system/alarm.jsp +++ b/cat-home/src/main/webapp/jsp/system/alarm.jsp @@ -1,6 +1,36 @@ -<%@ page contentType="text/html; charset=utf-8" %> - - - +<%@ page contentType="text/html; charset=utf-8"%> +<%@ taglib prefix="a" uri="/WEB-INF/app.tld"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="res" uri="http://www.unidal.org/webres"%> +<%@ taglib prefix="w" uri="http://www.unidal.org/web/core"%> -View of alarm page under system \ No newline at end of file + + + + + + + + + + + +
+
+

+ +

+
+
+ TODO +
+
+
\ No newline at end of file diff --git a/src/main/conf/Cat.sql b/src/main/conf/Cat.sql index bd1e2116e..d4ed8ac1a 100644 --- a/src/main/conf/Cat.sql +++ b/src/main/conf/Cat.sql @@ -1,100 +1,17 @@ -CREATE TABLE `logview` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `message_id` varchar(64) NOT NULL COMMENT '消息ID', - `data_path` varchar(200) NOT NULL COMMENT '消息路径', - `data_offset` bigint(20) NOT NULL COMMENT '消息偏移量', - `data_length` int(11) NOT NULL COMMENT '消息长度', - `tag_thread` varchar(128) DEFAULT NULL COMMENT '消息的线程标志', - `tag_session` varchar(128) DEFAULT NULL COMMENT '消息的会话标志', - `tag_request` varchar(128) DEFAULT NULL COMMENT '消息请求标志', - `creation_date` timestamp NOT NULL COMMENT '创建时间', - PRIMARY KEY (`id`), - KEY `message_id` (`message_id`), - KEY `tag_thread` (`tag_thread`), - KEY `tag_session` (`tag_session`), - KEY `tag_request` (`tag_request`) -) DEFAULT CHARSET=utf8 COMMENT='logview用于存放错误的消息的索引,用来标志它在HDFS上的存放路径'; - -CREATE TABLE `report` ( - `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(20) NOT NULL COMMENT '报表处理的Domain信息', - `period` timestamp NOT NULL COMMENT '报表时间段', - `type` tinyint(4) NOT NULL COMMENT '报表数据格式, 1/xml, 2/json, 默认1', - `content` mediumtext NOT NULL COMMENT '报表内容', - `creation_date` timestamp NOT NULL COMMENT '报表创建时间', - PRIMARY KEY (`id`) -) DEFAULT CHARSET=utf8 COMMENT='用于存放以小时为单位的报表信息'; - -CREATE TABLE `sqlreport` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `domain` varchar(50) NOT NULL COMMENT 'SQL报表的内容', - `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`) -) DEFAULT CHARSET=utf8 COMMENT='用于存放Hadoop处理的SQL报表信息'; - - -CREATE TABLE `comment` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `domain` varchar(50) NOT NULL COMMENT '报表Domain', - `author` varchar(32) NOT NULL COMMENT '作者', - `content` varchar(1024) NOT NULL COMMENT '事件内容', - `status` tinyint(4) NOT NULL COMMENT '执行状态: 0/active, 1/inactive', - `happened` datetime NOT NULL COMMENT '事件发生时间', - `creation_date` datetime NOT NULL COMMENT '创建时间', - PRIMARY KEY (`id`) -) 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(20) 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 COMMENT '执行状态: /daily', - `creation_date` datetime NOT NULL COMMENT '任务创建时间', - `start_date` datetime NULL COMMENT '开始时间, 这次执行开始时间', - `end_date` datetime NULL COMMENT '结束时间, 这次执行结束时间', - PRIMARY KEY (`id`) -) DEFAULT CHARSET=utf8 COMMENT='用于存放故障/事件信息'; - -CREATE UNIQUE INDEX task_period_domain_name ON task (report_period, report_domain, report_name); -CREATE TABLE `graph` ( +CREATE TABLE `dailygraph` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(20) NOT NULL COMMENT '报表名称', - `ip` varchar(20) NULL COMMENT '报表来自于哪台cat-client机器ip, NULL表示合并同domain所有ip', + `ip` varchar(20) NULL COMMENT '报表来自于哪台cat-client机器ip, 空串表示合并同domain所有ip', `domain` varchar(20) 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`) -) DEFAULT CHARSET=utf8 COMMENT='用于存放以小时为单位的绘图数据'; - -CREATE UNIQUE INDEX graph_period_ip_domain_name ON graph (period, ip, domain, name); + 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, @@ -105,25 +22,34 @@ CREATE TABLE `dailyreport` ( `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`) -) DEFAULT CHARSET=utf8 COMMENT='用于存放以天为单位的报表信息'; - -CREATE UNIQUE INDEX dailyreport_period_domain_name ON dailyreport (period, domain, name); + PRIMARY KEY (`id`), + UNIQUE KEY `period` (`period`,`domain`,`name`), + KEY `type` (`type`) +) ENGINE=InnoDB AUTO_INCREMENT=16027 DEFAULT CHARSET=utf8 COMMENT='天报表'; -CREATE TABLE `dailygraph` ( +CREATE TABLE `graph` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(20) NOT NULL COMMENT '报表名称', - `ip` varchar(20) NULL COMMENT '报表来自于哪台cat-client机器ip, 空串表示合并同domain所有ip', + `ip` varchar(20) NULL COMMENT '报表来自于哪台cat-client机器ip, NULL表示合并同domain所有ip', `domain` varchar(20) 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`) -) DEFAULT CHARSET=utf8 COMMENT='用于存放以天为单位的绘图数据'; + PRIMARY KEY (`id`), + UNIQUE KEY `graph_period_ip_domain_name` (`period`,`ip`,`domain`,`name`) +) ENGINE=InnoDB AUTO_INCREMENT=1588163 DEFAULT CHARSET=utf8 COMMENT='小时图表曲线'; -CREATE UNIQUE INDEX dailygraph_period_ip_domain_name ON dailygraph (period, ip, domain, name); +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 AUTO_INCREMENT=226602 DEFAULT CHARSET=utf8; CREATE TABLE `location` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -132,30 +58,110 @@ CREATE TABLE `location` ( `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 `maillog` ( + `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键', + `address` varchar(500) NOT NULL COMMENT '收件人', + `title` varchar(500) NOT NULL COMMENT '邮件标题', + `content` text NOT NULL COMMENT '邮件内容', + `sendtime` datetime NOT NULL COMMENT '发送时间', + `status` int(11) NOT NULL COMMENT '发送状态(0、发送成功;1、发送失败)', + `error` varchar(1000) DEFAULT NULL COMMENT '发送失败错误信息', + `cc` varchar(500) DEFAULT NULL COMMENT '邮件抄送人', PRIMARY KEY (`id`) -) DEFAULT CHARSET=utf8 COMMENT='热点数据'; +) ENGINE=InnoDB AUTO_INCREMENT=2224 DEFAULT CHARSET=utf8 COMMENT='邮件提醒发送记录'; + +CREATE TABLE `monthreport` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + `domain` varchar(100) DEFAULT NULL, + `period` datetime DEFAULT NULL, + `content` mediumtext, + `creation_date` datetime DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_2` (`name`,`domain`,`period`) +) ENGINE=InnoDB AUTO_INCREMENT=65 DEFAULT CHARSET=utf8; -CREATE UNIQUE INDEX transaction_date_lat_lng ON location (transaction_date, lat, lng); -CREATE TABLE `hostinfo` ( +CREATE TABLE `report` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `ip` varchar(50) NOT NULL COMMENT '机器的IP信息', - `domain` varchar(50) NOT NULL COMMENT 'IP对应项目信息', - `creation_date` datetime NOT NULL, - `last_modified_date` datetime NOT NULL, + `type` tinyint(4) NOT NULL COMMENT '报表类型', + `name` varchar(20) NOT NULL COMMENT '报表名称', + `ip` varchar(20) DEFAULT NULL COMMENT '报表来自于哪台机器', + `domain` varchar(50) NOT NULL, + `period` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '报表时间段', + `content` longtext NOT NULL, + `creation_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '报表创建时间', PRIMARY KEY (`id`), - UNIQUE KEY `ip_index` (`ip`) -) + KEY `IX_Domain_Name_Period` (`domain`,`name`,`period`), + KEY `IX_Name_Period` (`name`,`period`), + KEY `IX_Period` (`period`) +) ENGINE=InnoDB AUTO_INCREMENT=433981 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 AUTO_INCREMENT=196645 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` varchar(1000) 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 AUTO_INCREMENT=767 DEFAULT CHARSET=utf8; + +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 AUTO_INCREMENT=28 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(20) 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 AUTO_INCREMENT=471692 DEFAULT CHARSET=utf8 COMMENT='后台任务'; + -- GitLab