Authored by jack.xue

Merge branch 'master' of http://git.yoho.cn/ops/monitor-ui

... ... @@ -45,6 +45,32 @@ public class HttpRestClient {
}
}
public <T> T get(String url, Class<T> responseType,Map<String, ?> map) {
try {
StringBuilder uri = new StringBuilder(url);
if(map != null){
uri.append("?");
for (Map.Entry<String, ?> entry : map.entrySet()) {
uri.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
}
return restTemplate.getForObject(uri.toString().substring(0, uri.length()-1), responseType);
}
return restTemplate.getForObject(url, responseType);
} catch (Exception e) {
logger.error("getForObject failed!url: "+url, e);
return null;
}
}
public <T> T post(String url, Object request, Class<T> responseType) {
try {
return restTemplate.postForObject(url, request,responseType);
} catch (Exception e) {
logger.error("postForObject failed!url:"+url, e);
return null;
}
}
public <T> T defaultGet(String uri, Class<T> responseType) {
try {
return restTemplate.getForObject(systemConfig.getServiceUrl() + uri, responseType);
... ...
package com.ui.model.req;
import java.io.Serializable;
@SuppressWarnings("serial")
public class BuildRequest implements Serializable {
private String project;
private String environment;
private String operate;
private String rollbackfile;
private String messageid;
private String tag;
private String branch;
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getProject() {
return project;
}
public void setProject(String project) {
this.project = project;
}
public String getEnvironment() {
return environment;
}
public void setEnvironment(String environment) {
this.environment = environment;
}
public String getOperate() {
return operate;
}
public void setOperate(String operate) {
this.operate = operate;
}
public String getRollbackfile() {
return rollbackfile;
}
public void setRollbackfile(String rollbackfile) {
this.rollbackfile = rollbackfile;
}
public String getMessageid() {
return messageid;
}
public void setMessageid(String messageid) {
this.messageid = messageid;
}
public String getBranch() {
return branch;
}
public void setBranch(String branch) {
this.branch = branch;
}
}
... ...
package com.ui.project;
/**
* Created by zhengyouwei on 2016/6/29.
*/
public class Project {
private String order;//顺序
private String name;
private String projectid;
private String group;
public Project(){
}
public Project(String order, String name, String projectid, String group){
this.order = order;
this.name = name;
this.projectid = projectid;
this.group = group;
}
public String getOrder() {
return order;
}
public void setOrder(String order) {
this.order = order;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getProjectid() {
return projectid;
}
public void setProjectid(String projectid) {
this.projectid = projectid;
}
public String getGroup() {
return group;
}
public void setGroup(String group) {
this.group = group;
}
}
... ...
package com.ui.project;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class ProjectEnvironment {
private static Map<String,String> map = new HashMap<>();
static{
map.put("aws", "");
map.put("qcloud","");
map.put("qcloud_gray","");
map.put("test","http://192.168.102.220:8080/web/");
//map.put("dev");
}
public static Set<String> getEnviroments(){
return map.keySet();
}
public static String getUrl(String envi){
return map.get(envi);
}
}
... ...
package com.ui.project;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ProjectOnline {
private static List<Project> list = new ArrayList<Project>();
private static Map<String,Project> map = new HashMap<String,Project>();
static{
list.add(new Project("1","yoho-gateway","126","yoho30"));
list.add(new Project("1","yoho-users","134","yoho30"));
list.add(new Project("1","yoho-message","123","yoho30"));
list.add(new Project("1","yoho-sns","125","yoho30"));
list.add(new Project("1","yoho-push","137","yoho30"));
list.add(new Project("1","yohobuy-resources","122","yoho30"));
list.add(new Project("1","yohobuy-order","124","yoho30"));
list.add(new Project("1","yohobuy-promotion","140","yoho30"));
list.add(new Project("1","yohobuy-product","143","yoho30"));
list.add(new Project("1","yohobuy-union","133","yoho30"));
list.add(new Project("1","yohobuy-activity","129","yoho30"));
list.add(new Project("1","yohobuy-task","138","yoho30"));
list.add(new Project("1","yohobuy-wechat","248","yoho30"));
list.add(new Project("1","yohobuy-brower","131","yoho30"));
list.add(new Project("2","yoho-search-service","12","yoho-search"));
list.add(new Project("2","yoho-search-consumer","8","yoho-search"));
list.add(new Project("2","yoho-search-producer","7","yoho-search"));
list.add(new Project("3","yohobuy-platform","110","platform"));
list.add(new Project("3","yohobuy-bigdata","113","platform"));
for(Project project :list){
map.put(project.getName(),project);
}
}
public static List<Project> getProjectList() {
return list;
}
public static Project getProject(String name){
return map.get(name);
}
}
... ...
package com.ui.ctrl;
import com.alibaba.fastjson.JSONArray;
import com.ui.http.HttpRestClient;
import com.ui.model.req.BuildRequest;
import com.ui.project.ProjectEnvironment;
import com.ui.project.ProjectOnline;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping("/project")
public class ProjectBuildCtrl {
@Autowired
private HttpRestClient httpRestClient;
@RequestMapping(value = "projectbuild")
public ModelAndView projectbuild(Model model) {
model.addAttribute("environments", ProjectEnvironment.getEnviroments());
return new ModelAndView("jsp/project/project");
}
/**
* 获取所有项目
*
* @return
*/
@RequestMapping(value = "getProjects", method = RequestMethod.POST)
@ResponseBody
public String getProjects() {
try {
return JSONArray.toJSON(ProjectOnline.getProjectList()).toString();
} catch (Exception ex) {
return "failed";
}
}
/**
* 校验tag
*
* @return
*/
@RequestMapping(value = "checkTag", method = RequestMethod.POST)
@ResponseBody
public String checkTag(String projects, String tag, String enviromment) {
Map<String, String> map = new HashMap<>();
map.put("projects", projects);
map.put("tag", tag);
return httpRestClient.get(ProjectEnvironment.getUrl(enviromment) + "checkTag", String.class, map);
}
/**
* 校验branch
*
* @return
*/
@RequestMapping(value = "checkBranch")
@ResponseBody
public String checkBranch(String projects, String branch, String environment) {
if (!("master".equals(branch) || "test".equals(branch) || "dev".equals(branch))) {
Map<String, String> map = new HashMap<>();
map.put("projects", projects);
map.put("branch", branch);
return httpRestClient.get(ProjectEnvironment.getUrl(environment) + "checkBranch", String.class, map);
}
return "1";
}
/**
* 执行任务
*
* @param request
* @return
*/
@RequestMapping(value = "build", method = RequestMethod.POST)
@ResponseBody
public String build(@RequestBody BuildRequest request) {
try {
return httpRestClient.post(ProjectEnvironment.getUrl(request.getEnvironment()) + "build", request, String.class);
} catch (Exception ex) {
return "failed";
}
}
/**
* 获取执行结果
*
* @param messageid
* @return
*/
@RequestMapping(value = "getbuildmsg", method = RequestMethod.POST)
@ResponseBody
public String getbuildmsg(String messageid, String project) {
try {
Map<String, String> map = new HashMap<>();
map.put("messageid", messageid);
map.put("project", project);
return httpRestClient.get(ProjectEnvironment.getUrl(messageid.split("_")[0]) + "getbuildmsg", String.class, map);
} catch (Exception ex) {
return "failed";
}
}
@RequestMapping(value = "cancelBuild")
@ResponseBody
public String cancelBuild(String id) {
try {
Map<String, String> map = new HashMap<>();
map.put("id", id);
return httpRestClient.get(ProjectEnvironment.getUrl(id.split("_")[0]) + "cancelBuild", String.class, map);
} catch (Exception ex) {
return "failed";
}
}
@RequestMapping(value = "rollbackList", method = RequestMethod.POST)
@ResponseBody
public String rollbackList(String project, String environment) {
try {
Map<String, String> map = new HashMap<>();
map.put("project", project);
map.put("environment", environment);
return httpRestClient.get(ProjectEnvironment.getUrl(environment) + "rollbackList", String.class, map);
} catch (Exception ex) {
return "failed";
}
}
}
... ...
package com.ui.ctrl;
import com.ui.contants.HttpUriContants;
import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -7,11 +10,6 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ui.contants.HttpUriContants;
import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
import com.ui.model.req.RedisReq;
@Controller
@RequestMapping("redisInfo")
... ... @@ -24,9 +22,9 @@ public class RedisInfoCtrl {
@RequestMapping("/getRedisInfo")
@ResponseBody
public BaseResponse getRedisInfo(RedisReq req){
log.info("getRedisInfo with param is {} ",req);
BaseResponse response=httpRestClient.defaultPost(HttpUriContants.GET_REDIS_INFO, req, BaseResponse.class);
public BaseResponse getRedisInfo(){
log.info("into getRedisInfo");
BaseResponse response=httpRestClient.defaultPost(HttpUriContants.GET_REDIS_INFO, null, BaseResponse.class);
return response;
}
... ...
monitor.service.url=http://127.0.0.1:8880/monitor
\ No newline at end of file
monitor.service.url=http://127.0.0.1:8080/monitor
\ No newline at end of file
... ...
... ... @@ -31,15 +31,21 @@
<link rel="stylesheet" href="<%=basePath %>css/bootstrap-responsive.min.css"/>
<link rel="stylesheet" href="<%=basePath %>css/fullcalendar.css"/>
<link rel="stylesheet" href="<%=basePath %>css/unicorn.main.css"/>
<link rel="stylesheet" href="<%=basePath %>css/unicorn.grey.css" class="skin-color"/>
<link rel="stylesheet" href="<%=basePath %>css/unicorn.grey.css"/>
<link rel="stylesheet" href="<%=basePath %>css/jquery-ui.css"/>
<link rel="stylesheet" href="<%=basePath %>css/uniform.css"/>
<link rel="stylesheet" href="<%=basePath %>css/select2.css"/>
<link rel="stylesheet" href="<%=basePath %>js/jstree/themes/proton/style.css"/>
<link rel="stylesheet" href="<%=basePath %>css/select2.css"/>
<link rel="stylesheet" href="<%=basePath %>css/yoho.css"/>
<script src="<%=basePath %>js/excanvas.min.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jquery-1.12.0.min.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jquery-ui.custom.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>/js/bootstrap.min.js"></script>
<script src="<%=basePath %>/js/jquery.flot.min.js"></script>
<script src="<%=basePath %>/js/jquery.flot.resize.min.js"></script>
<script src="<%=basePath %>/js/unicorn.js"></script>
<script src="<%=basePath %>/js/unicorn.dashboard.js"></script>
<script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/moment-with-locales.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/bootstrap-datetimepicker.js" charset="UTF-8"
... ... @@ -104,6 +110,31 @@
<li class="" id="ProjectRelease"><a href="?page_type=projectRelease"><i
class="icon icon-th"></i><span>项目发布</span></a>
</li>
<li class="submenu">
<a href="#"><i class="icon icon-th-list"></i> <span>其他</span></a>
<ul>
<li class="">
<a href="#" id="rabbitmqMenu"><i class="icon icon-th-list"></i> <span>rabbitmq dashboard</span></a>
<ul style="display:none" id="rabbitmqUl">
<li><a href="http://rabbit-aws.yohops.com/" target="_blank">aws交易</a></li>
<li><a href="http://rabbit-aws-common.yohops.com/" target="_blank">aws通用</a></li>
<li><a href="http://rabbit-qq.yohops.com/" target="_blank">qq交易</a></li>
<li><a href="http://rabbit-qq-common.yohops.com/" target="_blank">qq通用</a></li>
</ul>
</li>
<li class="">
<a href="#" id="monitorMenu"><i class="icon icon-th-list"></i> <span>微服务监控</span></a>
<ul style="display:none" id="monitorUl">
<li><a href="http://aws-monitor.yohops.com/" target="_blank">aws</a></li>
<li><a href="http://aws-monitor.yohops.com/" target="_blank">Qcloud</a></li>
</ul>
</li>
<li><a href="http://g.yohops.com" target="_blank">grafana dashboard</a></li>
<li><a href="http://zk.yohops.com" target="_blank">zookeeper dashboard</a></li>
<li><a href="http://dev.yohops.com" target="_blank">开发运维信息查询</a></li>
<li><a href="http://kibana.yoho.cn/" target="_blank">kibana</a></li>
</ul>
</li>
</ul>
</div>
<!-- 右侧具体内容 -->
... ... @@ -124,7 +155,7 @@
"qcnginx": '/jsp/mobject/qcnginx.jsp',
"nginxview": '/jsp/mobject/nginxview.jsp',
"projectRelease": '/jsp/project/projectRelease.jsp',
"rabbitInfo": '/jsp/mobject/rabbitmq.jsp'
"rabbitInfo": '/jsp/mobject/rabbitmq.jsp',
};
var page_type = "<%=page_type %>";
var page_url = "<%=page_url %>";
... ... @@ -171,6 +202,26 @@
}]
});
}
$("#rabbitmqMenu").click(function(){
if($("#rabbitmqUl").css('display')=="none"){
$("#rabbitmqUl").css('display','block');
$("#rabbitmqUl li").css('background','#CFCFCF');
}else{
$("#rabbitmqUl").css('display','none');
}
});
$("#monitorMenu").click(function(){
if($("#monitorUl").css('display')=="none"){
$("#monitorUl").css('display','block');
$("#monitorUl li").css('background','#CFCFCF');
}else{
$("#monitorUl").css('display','none');
}
});
</script>
</body>
</html>
\ No newline at end of file
... ...
var dataString ='<chart charttopmargin="0" chartBottomMargin="0" chartleftmargin="0" chartrightmargin="0" bordercolor="#FFFFFF" border="0" borderAlpha="0" borderThickness="0" canvasBorderThickness="0" canvasBorderColor="#FFFFFF" showFormBtn="0">\n\
<dataset plotborderAlpha="0" >\n\
<set x="12" y="80" width="120" height="40" name="AWS" color="62D0FE" id="AWS" tooltext= "AWS" />\n\
<set x="8" y="70" width="120" height="40" name="172.31.19.49:6379" color="62D0FE" id="172.31.19.49:6379" />\n\
<set x="16" y="70" width="120" height="40" name="172.31.24.61:6379" color="62D0FE" id="172.31.24.61:6379" />\n\
<set x="4" y="55" width="55" height="40" name="172.31.19.49:16379" color="62D0FE" id="172.31.19.49:16379" />\n\
<set x="8" y="55" width="55" height="40" name="172.31.19.49:26379" color="62D0FE" id="172.31.19.49:26379" />\n\
<set x="16" y="70" width="120" height="40" name="172.31.24.61:6379" color="62D0FE" id="172.31.24.61:6379" />\n\
<set x="12" y="55" width="55" height="40" name="172.31.24.61:16379" color="62D0FE" id="172.31.24.61:16379" />\n\
<set x="16" y="55" width="55" height="40" name="172.31.24.61:26379" color="62D0FE" id="172.31.24.61:26379" />\n\
<set x="12" y="80" width="120" height="40" name="AWS" color="62D0FE" id="AWS" tooltext= "AWS" />\n\
<set x="30" y="70" width="120" height="40" name="10.66.4.2:6379" id="10.66.4.2:6379" color="62D0FE"/>\n\
<set x="20" y="55" width="55" height="40" name="10.66.4.2:16379" color="62D0FE" id="10.66.4.2:16379" />\n\
<set x="24" y="55" width="55" height="40" name="10.66.4.2:26379" color="62D0FE" id="10.66.4.2:26379" />\n\
... ...
... ... @@ -55,13 +55,13 @@
var initDashBoard = function (data) {
var div_dash = $(".api_info_container");
$.each(data, function (idx, val) {
var api_info_item = $('<div class="api_info_item col-xs-4 ">');
var api_info_item = $('<div class="api_info_item col-xs-3 ">');
var api_info_item_panel = $(' <div class="panel panel-default">');
var api_info_item_panel_title = $('<div class="item_java_api_title panel-heading">' + val.typeName + '<span style="font-size: medium;float: right;padding-top: 15px"><span id="span_time_' + val.typeId + '"></span></span></div>');
var api_info_item_panel_body = $('<div class="panel-body">');
api_info_item_panel_body.append('<button class="btn_java_api btn btn-lg btn-default" id="btn_1_' + val.typeId + '">AWS &nbsp;<span class="badge"></span></button>');
api_info_item_panel_body.append('<button class="btn_java_api btn btn-lg btn-default" id="btn_2_' + val.typeId + '">QCloud &nbsp;<span class="badge"></span></button>');
api_info_item_panel_body.append('<button class="btn_java_api btn btn-lg btn-default" id="btn_3_' + val.typeId + '">其他 &nbsp;<span class="badge"></span></button>');
// api_info_item_panel_body.append('<button class="btn_java_api btn btn-lg btn-default" id="btn_3_' + val.typeId + '">其他 &nbsp;<span class="badge"></span></button>');
// api_info_item_panel_body.append('<h5 >更新时间:<span id="span_time_'+val.typeId+'"></span></h5>');
api_info_item_panel.append(api_info_item_panel_title)
.append(api_info_item_panel_body);
... ... @@ -112,6 +112,8 @@
$.each(data.data, function (idx, val) {
console.log($("#btn_" + val.cloudType + "_" + val.serviceType));
if(val.cloudType!=1&&val.cloudType!=2)//目前只有腾讯aws
return;
var btn = $("#btn_" + val.cloudType + "_" + val.serviceType);
if (val.updateTime != undefined && val.updateTime != "") {
... ...
... ... @@ -149,12 +149,12 @@
$.each(apps, function (idx, val) {
var span;
if (toggle == 1) {
span = $("<button class='btn btn-success btn-xs tag_javaapp has-popover' >").attr("id", "span_" + serviceId + "_" + val.moId).html(val.moHostIp);
span = $("<button class='btn btn-default btn-xs tag_javaapp has-popover' >").attr("id", "span_" + serviceId + "_" + val.moId).html(val.moHostIp);
span.attr("data-toggle", "popover");
span.attr("data-placement", "bottom");
span.attr("data-html", "true");
// span.attr("title", "message");
// span.attr("data-content", "message");
span.attr("data-content", "unkown");
} else {
span = $("<button class='btn btn-inverse btn-xs tag_javaapp' >").attr("id", "span_no_" + serviceId + "_" + val.moId).html(val.moHostIp);
}
... ... @@ -173,16 +173,16 @@
var content = "start: " + statusObj.startTime + " ";
content += "end: " + statusObj.endTime + " ";
content += "cost: " + statusObj.costTime + "ms<br>";
$("#" + id).removeClass('btn-default');
if (statusObj.status == 0) {
content += "exception: " + statusObj.exception;
if ($("#" + id).hasClass('btn-success')) {
if (!$("#" + id).hasClass('btn-danger')) {
$("#" + id).removeClass('btn-success');
$("#" + id).addClass('btn-danger');
}
}
else {
if ($("#" + id).hasClass('btn-danger')) {
if (!$("#" + id).hasClass('btn-success')) {
$("#" + id).removeClass('btn-danger');
$("#" + id).addClass('btn-success');
}
... ...
... ... @@ -10,8 +10,8 @@
<div class="widget-title">
<h5>项目发布</h5>
</div>
<iframe src="http://ops-deploy.yohoops.org/web/projectbuild" id="iframepage" frameborder="0" scrolling="yes" width="100%" height="800px"></iframe>
<iframe src="http://123.206.79.151/web/projectbuild" id="iframepage" frameborder="0" scrolling="yes" width="100%" height="800px"></iframe>
</div>
</div>
\ No newline at end of file
... ...
... ... @@ -24,12 +24,11 @@
<div id="chartdiv" align="center" style="width:800px;">
FusionCharts.
</div>
<script type="text/javascript">
var chart = new FusionCharts("<%=basePath %>/js/charts/DragNode.swf", "ChartId", "1650", "650", "0");
chart.setXMLData(dataString );
chart.render("chartdiv");
</script>
</div>
</div>
</div>
<script type="text/javascript">
var chart = new FusionCharts("<%=basePath %>/js/charts/DragNode.swf", "ChartId", "1650", "650", "0");
chart.setXMLData(dataString );
chart.render("chartdiv");
</script>
\ No newline at end of file
... ...
... ... @@ -15,7 +15,7 @@
<div class="row api_info_container">
<div class="api_info_item col-xs-10 ">
<div class="panel panel-default">
<div class="item_java_api_title panel-heading" style="text-align: center">AWS-Zookeeper集群(最近更新时间:<span id="zkAwsTime">15分钟以前</span>)</div>
<div class="item_java_api_title panel-heading" style="text-align: center">AWS-Zookeeper集群(最近更新时间:<span id="zkAwsTime">2分钟以前</span>)</div>
<div class="panel-body" style="height: 180px; padding-top: 60px;text-align: center;" id="zkAwsDiv">
</div>
... ... @@ -23,7 +23,7 @@
</div>
<div class="api_info_item col-xs-10 ">
<div class="panel panel-default">
<div class="item_java_api_title panel-heading" style="text-align: center">QCloud-Zookeeper集群(最近更新时间:<span id="zkQCloudTime">15分钟以前</span>)</div>
<div class="item_java_api_title panel-heading" style="text-align: center">QCloud-Zookeeper集群(最近更新时间:<span id="zkQCloudTime">2分钟以前</span>)</div>
<div class="panel-body" style="height: 180px; padding-top: 80px;text-align: center;" id="zkQCloudDiv">
</div>
... ...