Commit 762400ae authored by gaozhentao's avatar gaozhentao

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

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