提交 0c76ff0f 编写于 作者: Y youyong

modify the event graph

上级 3381ab1f
......@@ -26,6 +26,7 @@
<attribute name="totalCount" value-type="long" primitive="true" method-inc="true" />
<attribute name="failCount" value-type="long" primitive="true" method-inc="true" />
<attribute name="failPercent" value-type="double" primitive="true" format="0.00" />
<attribute name="totalPercent" value-type="double" primitive="true" format="0.00" render="false"/>
<entity-ref name="range" type="list" names="ranges" method-find-or-create="true" />
</entity>
<entity name="range">
......
package com.dianping.cat.report.page.event;
import java.io.IOException;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
......@@ -25,6 +26,7 @@ import com.dianping.cat.home.dal.report.DailyreportDao;
import com.dianping.cat.home.dal.report.DailyreportEntity;
import com.dianping.cat.report.ReportPage;
import com.dianping.cat.report.graph.GraphBuilder;
import com.dianping.cat.report.page.event.PieChart.Item;
import com.dianping.cat.report.page.model.event.EventReportMerger;
import com.dianping.cat.report.page.model.spi.ModelRequest;
import com.dianping.cat.report.page.model.spi.ModelResponse;
......@@ -98,6 +100,7 @@ public class Handler implements PageHandler<Context> {
nameTps = totalNameCount / (double) time;
}
transName.setTps(nameTps);
transName.setTotalPercent(totalNameCount / (double) totalCount);
}
}
}
......@@ -279,6 +282,7 @@ public class Handler implements PageHandler<Context> {
if (!StringUtils.isEmpty(type)) {
model.setDisplayNameReport(new DisplayNames().display(sorted, type, ip, report));
buildEventNameGraph(ip,type,report,model);
} else {
model.setDisplayTypeReport(new DisplayTypes().display(sorted, ip, payload.isShowAll(), report));
}
......@@ -288,6 +292,19 @@ public class Handler implements PageHandler<Context> {
}
}
private void buildEventNameGraph(String ip, String type, EventReport report, Model model) {
PieChart chart = new PieChart();
Collection<EventName> values = report.findOrCreateMachine(ip).findOrCreateType(type).getNames().values();
for (EventName name : values) {
Item item = new Item();
item.setNumber(name.getTotalCount()).setTitle(name.getId());
chart.addItem(item);
}
Gson gson = new Gson();
model.setPieChart(gson.toJson(chart));
}
private MobileGraphs showMobileGraphs(Model model, Payload payload) {
EventName name = getEventName(payload);
......@@ -349,6 +366,7 @@ public class Handler implements PageHandler<Context> {
model.setReport(eventReport);
if (!StringUtils.isEmpty(type)) {
model.setDisplayNameReport(new DisplayNames().display(sorted, type, ip, eventReport));
buildEventNameGraph(ip,type,eventReport,model);
} else {
model.setDisplayTypeReport(new DisplayTypes().display(sorted, ip, payload.isShowAll(), eventReport));
}
......
......@@ -30,6 +30,8 @@ public class Model extends AbstractReportModel<Action, Context> {
private EventReport m_report;
private String m_type;
private String m_pieChart;
public Model(Context ctx) {
super(ctx);
......@@ -160,4 +162,12 @@ public class Model extends AbstractReportModel<Action, Context> {
m_type = type;
}
public String getPieChart() {
return m_pieChart;
}
public void setPieChart(String pieChart) {
m_pieChart = pieChart;
}
}
package com.dianping.cat.report.page.event;
import java.util.ArrayList;
import java.util.List;
public class PieChart {
private List<Item> items = new ArrayList<Item>();
public List<Item> getItems() {
return items;
}
public void setItems(List<Item> items) {
this.items = items;
}
public void addItem(Item item) {
items.add(item);
String title = item.getTitle();
if (title.length() > 28) {
title = title.substring(0, 12) + "..." + title.substring(title.length() - 12);
item.setTitle(title);
}
}
public static class Item {
private String title;
private double number;
public String getTitle() {
return title;
}
public Item setTitle(String title) {
this.title = title;
return this;
}
public double getNumber() {
return number;
}
public Item setNumber(double number) {
this.number = number;
return this;
}
}
}
package com.dianping.cat.report.view;
import com.dianping.cat.report.ReportPage;
import com.dianping.cat.system.SystemPage;
import com.site.web.mvc.Page;
public class NavigationBar {
......@@ -34,10 +35,21 @@ public class NavigationBar {
ReportPage.DATABASE,
ReportPage.HEALTH,
ReportPage.MONTHREPORT,
ReportPage.LOGVIEW
};
}
public Page[] getSystemPages() {
return new Page[] {
SystemPage.ALARM,
SystemPage.LOGIN
};
}
}
......@@ -1118,11 +1118,11 @@
</component>
<component>
<role>com.site.dal.jdbc.mapping.TableProvider</role>
<role-hint>DP_AdminLogin</role-hint>
<role-hint>dp-admin-login</role-hint>
<implementation>com.site.dal.jdbc.mapping.SimpleTableProvider</implementation>
<configuration>
<logical-table-name>DP_AdminLogin</logical-table-name>
<physical-table-name>DP_AdminLogin</physical-table-name>
<logical-table-name>dp-admin-login</logical-table-name>
<physical-table-name>dp_admin_login</physical-table-name>
<data-source-name>user</data-source-name>
</configuration>
</component>
......
<%@ tag trimDirectiveWhitespaces="true" %>
<%@ tag trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="res" uri="http://www.unidal.org/webres"%>
<jsp:useBean id="navBar" class="com.dianping.cat.report.view.NavigationBar" scope="page"/>
<jsp:useBean id="navBar"
class="com.dianping.cat.report.view.NavigationBar" scope="page" />
<res:bean id="res"/>
<res:bean id="res" />
<html>
<head>
<title>CAT - ${model.page.description}</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<res:cssSlot id="head-css"/>
<res:jsSlot id="head-js"/>
<res:useCss value='${res.css.local.body_css}' target="head-css"/>
</head>
<body>
<table style="height:8px"></table>
<ul class="tabs">
<c:forEach var="page" items="${navBar.visiblePages}">
<c:if test="${page.standalone}">
<li ${model.page.name == page.name ? 'class="selected"' : ''}><a href="${model.webapp}/${page.moduleName}/${page.path}?domain=${model.domain}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}">${page.title}</a></li>
</c:if>
<c:if test="${not page.standalone and model.page.name == page.name}">
<li class="selected">${page.title}</li>
</c:if>
</c:forEach>
</ul>
<head>
<title>CAT - ${model.page.description}</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<res:cssSlot id="head-css" />
<res:jsSlot id="head-js" />
<res:useCss value='${res.css.local.body_css}' target="head-css" />
</head>
<body>
<div class="login"><a href="">Login</a></div>
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="80%"><ul class="tabs">
<c:forEach var="page" items="${navBar.visiblePages}">
<c:if test="${page.standalone}">
<li ${model.page.name == page.name ? 'class="selected"' : ''}><a
href="${model.webapp}/${page.moduleName}/${page.path}?domain=${model.domain}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}">${page.title}</a></li>
</c:if>
<c:if
test="${not page.standalone and model.page.name == page.name}">
<li class="selected">${page.title}</li>
</c:if>
</c:forEach>
</ul></td>
<td width="20%"><ul class="tabs">
<c:forEach var="page" items="${navBar.systemPages}">
<c:if test="${page.standalone}">
<li ${model.page.name == page.name ? 'class="selected"' : ''}><a
href="${model.webapp}/${page.moduleName}/${page.path}?domain=${model.domain}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}">${page.title}</a></li>
</c:if>
<c:if
test="${not page.standalone and model.page.name == page.name}">
<li class="selected">${page.title}</li>
</c:if>
</c:forEach>
</ul></td>
</tr>
</table>
<jsp:doBody />
<jsp:doBody />
<res:jsSlot id="bottom-js"/>
</body>
<res:jsSlot id="bottom-js" />
</body>
</html>
......@@ -160,4 +160,12 @@ a.heartbeat {
.right {
text-align: right;
}
.login{
height:12px;
width:97%;
text-align:right;
margin-right:20px;
pedding-right:20px;
}
\ No newline at end of file
......@@ -50,3 +50,10 @@ tr.link td {
.graph_link{
font-weight: normal;
}
.graph {
text-align:left;
width: 650px;
height: 450px;
margin: 4px auto;
}
\ No newline at end of file
......@@ -76,3 +76,41 @@ $(document).delegate('.history_graph_link', 'click', function(e){
cell.parentNode.style.display = 'none';
}
});
function graphPieChart(container,data){
var showData=[];
for(i = 0; i < data.items.length; i++){
var dataItem = [];
var graphItem ={};
dataItem.push([0,data.items[i].number]);
graphItem.data=dataItem;
graphItem.label=data.items[i].title;
showData.push(graphItem);
}
var graph = Flotr.draw(container,showData, {
HtmlText : true,
grid : {
verticalLines : false,
horizontalLines : false
},
xaxis : { showLabels : false },
yaxis : { showLabels : false },
pie : {
show : true,
position : 'ne',
explode : 6
},
mouse : { track : true },
legend : {
position : 'ne',
backgroundColor : '#D2E8FF'
}
});
}
graphPieChart(document.getElementById('eventGraph'), data );
function graphReal(container, data, step) {
var real = data.values[0];
var d1 = [], start = new Date(data.start).getTime(), options, graph, i, x, o;
console.log(new Date(data.start));
for (i = 0; i < data.size; i++) {
x = start + (i * step);
d1.push([ x, real[i] ]);
......
<%@ page contentType="text/html; charset=utf-8" %>
<jsp:useBean id="ctx" type="com.dianping.cat.report.page.14.Context" scope="request"/>
<jsp:useBean id="payload" type="com.dianping.cat.report.page.14.Payload" scope="request"/>
<jsp:useBean id="model" type="com.dianping.cat.report.page.14.Model" scope="request"/>
View of 14 page under report
\ No newline at end of file
......@@ -4,9 +4,12 @@
<%@ taglib prefix="w" uri="http://www.unidal.org/web/core"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="res" uri="http://www.unidal.org/webres"%>
<jsp:useBean id="ctx" type="com.dianping.cat.report.page.event.Context" scope="request" />
<jsp:useBean id="payload" type="com.dianping.cat.report.page.event.Payload" scope="request" />
<jsp:useBean id="model" type="com.dianping.cat.report.page.event.Model"scope="request" />
<jsp:useBean id="ctx" type="com.dianping.cat.report.page.event.Context"
scope="request" />
<jsp:useBean id="payload"
type="com.dianping.cat.report.page.event.Payload" scope="request" />
<jsp:useBean id="model" type="com.dianping.cat.report.page.event.Model"
scope="request" />
<c:set var="report" value="${model.report}" />
<a:report
......@@ -20,27 +23,32 @@
<res:useCss value="${res.css.local.event_css}" target="head-css" />
<res:useJs value="${res.js.local['jquery-1.7.1.js']}" target="head-js" />
<res:useJs value="${res.js.local['flotr2_js']}" target="head-js" />
</br>
<table class="machines">
<tr style="text-align: left">
<th>Machines: &nbsp;[&nbsp; <c:choose>
<c:when test="${model.ipAddress eq 'All'}">
<a href="?domain=${model.domain}&date=${model.date}&type=${payload.type}"
<a
href="?domain=${model.domain}&date=${model.date}&type=${payload.type}"
class="current">All</a>
</c:when>
<c:otherwise>
<a href="?domain=${model.domain}&date=${model.date}&type=${payload.type}">All</a>
<a
href="?domain=${model.domain}&date=${model.date}&type=${payload.type}">All</a>
</c:otherwise>
</c:choose> &nbsp;]&nbsp; <c:forEach var="ip" items="${model.ips}">
&nbsp;[&nbsp;
<c:choose>
<c:when test="${model.ipAddress eq ip}">
<a href="?domain=${model.domain}&ip=${ip}&date=${model.date}&type=${payload.type}"
<a
href="?domain=${model.domain}&ip=${ip}&date=${model.date}&type=${payload.type}"
class="current">${ip}</a>
</c:when>
<c:otherwise>
<a href="?domain=${model.domain}&ip=${ip}&date=${model.date}&type=${payload.type}">${ip}</a>
<a
href="?domain=${model.domain}&ip=${ip}&date=${model.date}&type=${payload.type}">${ip}</a>
</c:otherwise>
</c:choose>
&nbsp;]&nbsp;
......@@ -53,11 +61,16 @@
<c:choose>
<c:when test="${empty payload.type}">
<tr>
<th><a href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=type"> Type</a></th>
<th class="right"><a href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=total">Total Count</a></th>
<th class="right"><a href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=failure">Failure Count</a></th>
<th class="right"><a href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=failurePercent">Failure%</a></th>
<th class="right">Sample Link</th><th class="right">TPS</th>
<th><a
href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=type"> Type</a></th>
<th class="right"><a
href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=total">Total Count</a></th>
<th class="right"><a
href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=failure">Failure Count</a></th>
<th class="right"><a
href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&sort=failurePercent">Failure%</a></th>
<th class="right">Sample Link</th>
<th class="right">TPS</th>
</tr>
<c:forEach var="item" items="${model.displayTypeReport.results}"
varStatus="status">
......@@ -69,22 +82,33 @@
<td>${w:format(e.totalCount,'#,###,###,###,##0')}</td>
<td>${e.failCount}</td>
<td>${w:format(e.failPercent/100,'0.00%')}</td>
<td><a href="${model.logViewBaseUri}/${empty e.failMessageUrl ? e.successMessageUrl : e.failMessageUrl}?domain=${model.domain}">Log View</a></td>
<td><a
href="${model.logViewBaseUri}/${empty e.failMessageUrl ? e.successMessageUrl : e.failMessageUrl}?domain=${model.domain}">Log View</a></td>
<td>${w:format(e.tps,'0.0')}</td>
</tr>
</c:forEach>
</c:when>
<c:otherwise>
<tr>
<th><a href="?op=graphs&domain=${model.domain}&date=${model.date}&type=${payload.type}" class="graph_link" data-status="-1">[:: show ::]</a>
<a href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=type"> Name</a></th>
<th class="right"><a href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=total">Total Count</a></th>
<th class="right"><a href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=failure">Failure Count</a></th>
<th class="right"><a href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=failurePercent">Failure%</a></th>
<th class="right">Sample Link</th><th class="right">TPS</th>
<th><a
href="?op=graphs&domain=${model.domain}&date=${model.date}&type=${payload.type}"
class="graph_link" data-status="-1">[:: show ::]</a>
<a
href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=type"> Name</a></th>
<th class="right"><a
href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=total">Total Count</a></th>
<th class="right"><a
href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=failure">Failure Count</a></th>
<th class="right"><a
href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=failurePercent">Failure%</a></th>
<th class="right">Sample Link</th>
<th class="right"><a
href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=total">TPS</a></th>
<th class="right"><a
href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=total">Percent%</a></th>
</tr>
<tr class="graphs">
<td colspan="6"><div id="-1" style="display: none"></div></td>
<td colspan="7"><div id="-1" style="display: none"></div></td>
</tr>
<c:forEach var="item" items="${model.displayNameReport.results}"
varStatus="status">
......@@ -97,8 +121,10 @@
<td>${w:format(e.totalCount,'#,###,###,###,##0')}</td>
<td>${e.failCount}</td>
<td>${w:format(e.failPercent/100,'0.00%')}</td>
<td><a href="${model.logViewBaseUri}/${empty e.failMessageUrl ? e.successMessageUrl : e.failMessageUrl}?domain=${model.domain}">Log View</a></td>
<td><a
href="${model.logViewBaseUri}/${empty e.failMessageUrl ? e.successMessageUrl : e.failMessageUrl}?domain=${model.domain}">Log View</a></td>
<td>${w:format(e.tps,'0.0')}</td>
<td>${w:format(e.totalPercent,'0.00%')}</td>
</tr>
<tr class="graphs">
<td colspan="5"><div id="${status.index}"
......@@ -108,7 +134,21 @@
</c:otherwise>
</c:choose>
</table>
<font color="white">${lastIndex+1}</font>
<c:choose>
<c:when test="${not empty payload.type}">
<table>
<tr>
<td><div id="eventGraph" class="graph"></div>
</td>
</tr>
</table>
<script type="text/javascript">
var data = ${model.pieChart};
</script>
</c:when>
</c:choose>
<res:useJs value="${res.js.local.event_js}" target="bottom-js" />
</jsp:body>
......
......@@ -42,8 +42,8 @@
<th class="right"><a href="?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&sort=total${model.customDate}">Total Count</a></th>
<th class="right"><a href="?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&sort=failure${model.customDate}">Failure Count</a></th>
<th class="right"><a href="?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&sort=failurePercent${model.customDate}">Failure%</a></th>
<th class="right">Sample Link</th><th class="right">TPS</th>
</tr>
<th class="right">Sample Link</th><th class="right"><a href="?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&sort=total${model.customDate}">TPS</a></th>
</tr>
<c:forEach var="item" items="${model.displayTypeReport.results}"
varStatus="status">
<c:set var="e" value="${item.detail}" />
......@@ -67,7 +67,9 @@
<th class="right"><a href="?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&type=${payload.type}&sort=total${model.customDate}">Total Count</a></th>
<th class="right"><a href="?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&type=${payload.type}&sort=failure${model.customDate}">Failure Count</a></th>
<th class="right"><a href="?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&type=${payload.type}&sort=failurePercent${model.customDate}">Failure%</a></th>
<th class="right">Sample Link</th><th class="right">TPS</th>
<th class="right">Sample Link</th><th class="right"><a href="?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&type=${payload.type}&sort=type${model.customDate}">TPS</a></th>
<th class="right"><a href="?op=history&domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&reportType=${model.reportType}&type=${payload.type}&sort=type${model.customDate}">Percent%</a></th>
</tr>
<c:forEach var="item" items="${model.displayNameReport.results}"
varStatus="status">
......@@ -82,6 +84,7 @@
<td>${w:format(e.failPercent/100,'0.00%')}</td>
<td><a href="${model.logViewBaseUri}/${empty e.failMessageUrl ? e.successMessageUrl : e.failMessageUrl}?domain=${model.domain}">Log View</a></td>
<td>${w:format(e.tps,'0.0')}</td>
<td>${w:format(e.totalPercent,'0.00%')}</td>
</tr>
<tr class="graphs"><td colspan="5"><div id="${status.index}" style="display:none"></div></td></tr>
</c:forEach>
......@@ -90,6 +93,19 @@
</table>
<font color="white">${lastIndex+1}</font>
<c:choose>
<c:when test="${not empty payload.type}">
<table>
<tr>
<td><div id="eventGraph" class="graph" ></div>
</td>
</tr>
</table>
<script type="text/javascript">
var data = ${model.pieChart};
</script>
</c:when>
</c:choose>
<res:useJs value="${res.js.local.event_js}" target="bottom-js" />
</jsp:body>
</a:historyReport>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册