Commit 762400ae authored by gaozhentao's avatar gaozhentao

拓扑图消息显示增加错误ip

parent 583cb579
......@@ -81,7 +81,7 @@ public class ReliabilityApi {
return manager.selectChart(json);
}
/**
* 获取拓扑图数据
* 获取拓扑图数据
*
* @return
*/
......
......@@ -121,6 +121,9 @@ public class HttpTask extends BasicTask{
default:
flag = checkStatusCode(map);
}
if(!flag){
logger.warn("错误:"+hostInfo.getService_path()+", body:"+map.get("body"));
}
if (map.get("body") != null && !map.get("body").isEmpty() ) {
insertToKairos(httpClient, hostInfo.getService_path(), dur, flag);
logger.info("httpTask to {}|{}", hostInfo.getHost_ip(), flag);
......
......@@ -417,12 +417,14 @@ public class Manager {
Map result = new HashMap();
List<FlowNode> flowNodes = flowDao.findNodeAll();
List<FlowLine> flowLines = flowDao.findLineAll();
List<Server_Host_Info> hostInfos = cassandraDao.getClusterBeMonitoredList();
List<TcpFlowLineDto> lineDtos = new ArrayList<>();
List<TcpFlowNodeDto> nodeDtos = new ArrayList<>();
for(FlowNode node : flowNodes){
TcpFlowNodeDto nodeDto = new TcpFlowNodeDto();
long faultCount=0;
String errorCount = "0";
String errorIp = "";
String totalCount = "0";
if(node.getServerPath()==null || node.getServerPath().isEmpty()){
nodeDto.setCategory(node.getMark());
......@@ -432,7 +434,8 @@ public class Manager {
totalCount = String.valueOf(total.get(node.getCluster_name()));
}
if(error.containsKey(node.getCluster_name())){
errorCount = String.valueOf(total.get(node.getCluster_name()));
errorCount = String.valueOf(error.get(node.getCluster_name()));
errorIp = String.valueOf(error.get(node.getCluster_name()+"msg"));
nodeDto.setCategory("clusterFault");
}
......@@ -451,7 +454,7 @@ public class Manager {
}
nodeDto.setFaultCount((int) faultCount);
nodeDto.setKey(node.getCluster_name());
nodeDto.setDescription("服务异常数:"+errorCount+"/"+totalCount);
nodeDto.setDescription("服务异常数:"+errorCount+"/"+totalCount+"<br>"+errorIp);
nodeDto.setUrl(node.getServerPath());
nodeDto.setServerName(node.getCluster_name());
nodeDto.setText(node.getCluster_name());
......@@ -557,6 +560,19 @@ public class Manager {
// map中没有 就新建一个 默认值是1
errorMap.put(hostInfo.getCluster_name(),1);
}
/*记录错误IP*/
if(errorMap.containsKey(hostInfo.getCluster_name()+"msg")){
// map中存在 取出原先值 +1 然后覆盖原有的
// errorMap.put(hostInfo.getCluster_name()+"msg",errorMap.get(hostInfo.getCluster_name()+"msg")
// +"<div>"+hostInfo.getHost_ip()+"</div>");
errorMap.put(hostInfo.getCluster_name()+"msg",errorMap.get(hostInfo.getCluster_name()+"msg")
+hostInfo.getHost_ip()+"<br>");
}else{
// map中没有 就新建一个 默认值是1
// errorMap.put(hostInfo.getCluster_name()+"msg","<div>"+hostInfo.getHost_ip()+"</div>");
errorMap.put(hostInfo.getCluster_name()+"msg",hostInfo.getHost_ip()+"<br>");
}
}
} catch (Exception e) {
e.printStackTrace();
......
......@@ -56,10 +56,10 @@ public class SendHttpUtil {
RequestConfig requestConfig = RequestConfig.custom()
// 设置连接超时时间(单位毫秒)
.setConnectTimeout(5000)
// 设置请求超时时间(单位毫秒)
.setConnectionRequestTimeout(5000)
// socket读写超时时间(单位毫秒)
.setSocketTimeout(5000)
// // 设置请求超时时间(单位毫秒)
// .setConnectionRequestTimeout(5000)
// // socket读写超时时间(单位毫秒)
// .setSocketTimeout(5000)
// 设置是否允许重定向(默认为true)
.setRedirectsEnabled(true).build();
......@@ -76,16 +76,11 @@ public class SendHttpUtil {
map.put("body",EntityUtils.toString(responseEntity));
}
}catch (ConnectException e){
// logger.error(uri+"请求超时");
logger.error(uri+"请求超时"+" "+e.getMessage());
}catch (ConnectTimeoutException e){
}
catch (ClientProtocolException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
logger.error(uri+"请求超时"+" "+e.getMessage());
}catch (Exception e){
logger.error(uri+"请求失败"+" "+e.getMessage());
} finally {
try {
// 释放资源
......@@ -112,11 +107,11 @@ public class SendHttpUtil {
RequestConfig requestConfig = RequestConfig.custom()
// 设置连接超时时间(单位毫秒)
.setConnectTimeout(5000)
// 设置请求超时时间(单位毫秒)
.setConnectionRequestTimeout(3000)
// socket读写超时时间(单位毫秒)
.setSocketTimeout(3000)
// 设置是否允许重定向(默认为true)
// // 设置请求超时时间(单位毫秒)
// .setConnectionRequestTimeout(3000)
// // socket读写超时时间(单位毫秒)
// .setSocketTimeout(3000)
// // 设置是否允许重定向(默认为true)
.setRedirectsEnabled(true).build();
httpPost.setConfig(requestConfig);
StringEntity entity = new StringEntity(body, "UTF-8");
......@@ -140,18 +135,12 @@ public class SendHttpUtil {
}
// 从响应模型中获取响应实体
}catch (ConnectTimeoutException e){
// logger.error(uri+"连接超时");
logger.error(uri+"连接超时"+" "+e.getMessage());
} catch (ConnectException e){
// logger.error(uri+"请求超时");
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}catch (SocketException e){
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
logger.error(uri+"请求超时"+" "+e.getMessage());
} catch (Exception e){
logger.error(uri+"请求失败"+" "+e.getMessage());
}finally {
try {
// 释放资源
if (httpClient != null) {
......
server:
port: 8090
port: 8091
spring:
data:
cassandra:
keyspace-name: ctid_prof
contact-points: 200.102.10.11
port: 9042
username: gzt
password: gzt
# contact-points: 200.102.10.11
contact-points: 121.22.111.251
# port: 9042
port: 9002
# username: gzt
# password: gzt
security:
user:
name: user
......@@ -47,8 +49,10 @@ pointNumber: 60
#应用代理ID
agentId: 1000004
#管理组凭证密钥
corpsecret: 0gXvh18To60vLpw1wlPO4ncshvZjDKR0vaUuHAeDOb0
corpsecret: 0gXvhsss
#corpsecret: 0gXvh18To60vLpw1wlPO4ncshvZjDKR0vaUuHAeDOb0
#wx告警地址
wxurl: https://qyapi.weixin.qq.com/cgi-bin/gettoken
wxurl: hssss
#wxurl: https://qyapi.weixin.qq.com/cgi-bin/gettoken
#企业ID
corpid: wwb8a34ddb02c87228
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment