Merge branch 'master' of http://git.yoho.cn/ops/monitor-service
Showing
27 changed files
with
457 additions
and
62 deletions
@@ -96,7 +96,7 @@ public class MObjectInfoCtrl { | @@ -96,7 +96,7 @@ public class MObjectInfoCtrl { | ||
96 | 96 | ||
97 | selectGroupId = sourceGroupList.get(0).getId(); | 97 | selectGroupId = sourceGroupList.get(0).getId(); |
98 | 98 | ||
99 | - List<HostInfo> sourceHostList = hostInfoService.getHostInfosByGroupId(selectGroupId); | 99 | + List<HostInfo> sourceHostList = hostInfoService.getHostInfosByTag(""); |
100 | 100 | ||
101 | if (sourceHostList.size() > 0) { | 101 | if (sourceHostList.size() > 0) { |
102 | selectIp = sourceHostList.get(0).getHostIp(); | 102 | selectIp = sourceHostList.get(0).getHostIp(); |
@@ -109,7 +109,7 @@ public class MObjectInfoCtrl { | @@ -109,7 +109,7 @@ public class MObjectInfoCtrl { | ||
109 | } | 109 | } |
110 | 110 | ||
111 | if (StringUtils.isNotBlank(selectGroup)) { | 111 | if (StringUtils.isNotBlank(selectGroup)) { |
112 | - for (HostInfo info : hostInfoService.getHostInfosByGroupId(selectGroupId)) { | 112 | + for (HostInfo info : hostInfoService.getHostInfosByTag("")) { |
113 | ipList.add(info.getHostIp()); | 113 | ipList.add(info.getHostIp()); |
114 | } | 114 | } |
115 | } | 115 | } |
@@ -154,7 +154,7 @@ public class MObjectInfoCtrl { | @@ -154,7 +154,7 @@ public class MObjectInfoCtrl { | ||
154 | } | 154 | } |
155 | 155 | ||
156 | if (StringUtils.isNotBlank(selectGroup)) { | 156 | if (StringUtils.isNotBlank(selectGroup)) { |
157 | - for (HostInfo info : hostInfoService.getHostInfosByGroupId(selectGroupId)) { | 157 | + for (HostInfo info : hostInfoService.getHostInfosByTag("")) { |
158 | ipList.add(info.getHostIp()); | 158 | ipList.add(info.getHostIp()); |
159 | } | 159 | } |
160 | } | 160 | } |
@@ -73,7 +73,7 @@ public class HostGroupServiceImpl implements IHostGroupService { | @@ -73,7 +73,7 @@ public class HostGroupServiceImpl implements IHostGroupService { | ||
73 | 73 | ||
74 | @Override | 74 | @Override |
75 | public BaseResponse<Integer> delHostGroupById(int id) { | 75 | public BaseResponse<Integer> delHostGroupById(int id) { |
76 | - List<HostInfo> list = hostInfoMapper.selectHostInfosByGroupId(id); | 76 | + List<HostInfo> list = hostInfoMapper.selectHostInfosByTag(""); |
77 | if(list != null && list.size() > 0){ | 77 | if(list != null && list.size() > 0){ |
78 | return new BaseResponse<Integer>("有主机绑定此机组,请先删除主机信息"); | 78 | return new BaseResponse<Integer>("有主机绑定此机组,请先删除主机信息"); |
79 | }else{ | 79 | }else{ |
@@ -46,6 +46,10 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { | @@ -46,6 +46,10 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { | ||
46 | Point.Builder pointBuilder = Point.measurement(InfluxDBContants.YOMO_TB_JAVAAPI) | 46 | Point.Builder pointBuilder = Point.measurement(InfluxDBContants.YOMO_TB_JAVAAPI) |
47 | .tag("api_id", "api_id") | 47 | .tag("api_id", "api_id") |
48 | .tag("mobj_id", "mobj_id") | 48 | .tag("mobj_id", "mobj_id") |
49 | + .tag("api_name", "api_name") | ||
50 | + .tag("api_url", "api_url") | ||
51 | + .tag("mobj_ip", "mobj_ip") | ||
52 | + .tag("is_exception", "is_exception") | ||
49 | .addField("api_id", statics.getIntValue("api_id")) | 53 | .addField("api_id", statics.getIntValue("api_id")) |
50 | .addField("api_name", statics.getString("api_name")) | 54 | .addField("api_name", statics.getString("api_name")) |
51 | .addField("api_type", statics.getIntValue("api_type")) | 55 | .addField("api_type", statics.getIntValue("api_type")) |
@@ -62,13 +66,13 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { | @@ -62,13 +66,13 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { | ||
62 | if (statics.getBooleanValue("is_exception") == true) { | 66 | if (statics.getBooleanValue("is_exception") == true) { |
63 | pointBuilder.addField("exception", statics.getString("exception")); | 67 | pointBuilder.addField("exception", statics.getString("exception")); |
64 | } else { | 68 | } else { |
65 | - pointBuilder.addField("response", statics.getString("response")); | 69 | +// pointBuilder.addField("response", statics.getString("response")); |
66 | } | 70 | } |
67 | 71 | ||
68 | Point point = pointBuilder.build(); | 72 | Point point = pointBuilder.build(); |
69 | batchPoints.point(point); | 73 | batchPoints.point(point); |
70 | 74 | ||
71 | - inluxDBSingle.getInfluxDBByName(InfluxDBContants.AWS).getInfluxDB() | 75 | + inluxDBSingle.getInfluxDBByName(InfluxDBContants.ALARM).getInfluxDB() |
72 | .write(batchPoints); | 76 | .write(batchPoints); |
73 | 77 | ||
74 | 78 | ||
@@ -84,7 +88,7 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { | @@ -84,7 +88,7 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { | ||
84 | sql += " order by time desc limit 1"; | 88 | sql += " order by time desc limit 1"; |
85 | Query query = new Query(sql, InfluxDBContants.APP_ALARM); | 89 | Query query = new Query(sql, InfluxDBContants.APP_ALARM); |
86 | 90 | ||
87 | - QueryResult result = inluxDBSingle.getInfluxDBByName(InfluxDBContants.AWS).getInfluxDB().query(query); | 91 | + QueryResult result = inluxDBSingle.getInfluxDBByName(InfluxDBContants.ALARM).getInfluxDB().query(query); |
88 | 92 | ||
89 | JavaApiStaticsModel javaApiStaticsModel = new JavaApiStaticsModel(); | 93 | JavaApiStaticsModel javaApiStaticsModel = new JavaApiStaticsModel(); |
90 | javaApiStaticsModel.setServiceId(api_id); | 94 | javaApiStaticsModel.setServiceId(api_id); |
@@ -170,7 +174,7 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { | @@ -170,7 +174,7 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { | ||
170 | log.info("sql:{}", sql); | 174 | log.info("sql:{}", sql); |
171 | Query query = new Query(sql, InfluxDBContants.APP_ALARM); | 175 | Query query = new Query(sql, InfluxDBContants.APP_ALARM); |
172 | 176 | ||
173 | - QueryResult result = inluxDBSingle.getInfluxDBByName(InfluxDBContants.AWS).getInfluxDB().query(query); | 177 | + QueryResult result = inluxDBSingle.getInfluxDBByName(InfluxDBContants.ALARM).getInfluxDB().query(query); |
174 | 178 | ||
175 | List<JavaApiStaticsModel> list = new ArrayList<JavaApiStaticsModel>(); | 179 | List<JavaApiStaticsModel> list = new ArrayList<JavaApiStaticsModel>(); |
176 | 180 | ||
@@ -260,7 +264,7 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { | @@ -260,7 +264,7 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { | ||
260 | 264 | ||
261 | Query query = new Query(sql, InfluxDBContants.APP_ALARM); | 265 | Query query = new Query(sql, InfluxDBContants.APP_ALARM); |
262 | 266 | ||
263 | - QueryResult result = inluxDBSingle.getInfluxDBByName(InfluxDBContants.AWS).getInfluxDB().query(query); | 267 | + QueryResult result = inluxDBSingle.getInfluxDBByName(InfluxDBContants.ALARM).getInfluxDB().query(query); |
264 | 268 | ||
265 | return QueryResultUtil.getCount(result); | 269 | return QueryResultUtil.getCount(result); |
266 | } | 270 | } |
@@ -38,6 +38,11 @@ | @@ -38,6 +38,11 @@ | ||
38 | </dependency> | 38 | </dependency> |
39 | <!--项目内部依赖--> | 39 | <!--项目内部依赖--> |
40 | 40 | ||
41 | + <dependency> | ||
42 | + <groupId>commons-collections</groupId> | ||
43 | + <artifactId>commons-collections</artifactId> | ||
44 | + <version>3.2.1</version> | ||
45 | + </dependency> | ||
41 | </dependencies> | 46 | </dependencies> |
42 | 47 | ||
43 | 48 |
1 | package com.monitor.javaserver.client; | 1 | package com.monitor.javaserver.client; |
2 | 2 | ||
3 | +import com.model.HostInfo; | ||
3 | import com.model.JavaApiInfo; | 4 | import com.model.JavaApiInfo; |
5 | +import com.model.MObjectDetails; | ||
4 | import com.model.MObjectInfo; | 6 | import com.model.MObjectInfo; |
7 | +import com.monitor.cmdb.service.IHostInfoService; | ||
5 | import com.monitor.cmdb.service.IJavaApiInfoService; | 8 | import com.monitor.cmdb.service.IJavaApiInfoService; |
6 | import com.monitor.cmdb.service.IMObjectInfoService; | 9 | import com.monitor.cmdb.service.IMObjectInfoService; |
7 | import com.monitor.javaserver.common.JavaApiStatics; | 10 | import com.monitor.javaserver.common.JavaApiStatics; |
11 | +import com.monitor.javaserver.common.JavaApiStatus; | ||
8 | import com.monitor.javaserver.common.JavaApiTask; | 12 | import com.monitor.javaserver.common.JavaApiTask; |
9 | import com.monitor.javaserver.common.JavaApiThreadFactory; | 13 | import com.monitor.javaserver.common.JavaApiThreadFactory; |
10 | import com.monitor.javaserver.handle.IJavaApiHadnler; | 14 | import com.monitor.javaserver.handle.IJavaApiHadnler; |
15 | +import com.monitor.javaserver.handle.impl.PreProcessJavaApiHandler; | ||
16 | +import com.monitor.model.request.HostInfoReq; | ||
17 | +import com.monitor.model.response.PageResponse; | ||
11 | import org.slf4j.Logger; | 18 | import org.slf4j.Logger; |
12 | import org.slf4j.LoggerFactory; | 19 | import org.slf4j.LoggerFactory; |
20 | +import org.springframework.beans.BeanUtils; | ||
13 | import org.springframework.beans.factory.annotation.Autowired; | 21 | import org.springframework.beans.factory.annotation.Autowired; |
14 | import org.springframework.beans.factory.annotation.Qualifier; | 22 | import org.springframework.beans.factory.annotation.Qualifier; |
15 | import org.springframework.stereotype.Component; | 23 | import org.springframework.stereotype.Component; |
@@ -17,6 +25,7 @@ import org.springframework.util.LinkedMultiValueMap; | @@ -17,6 +25,7 @@ import org.springframework.util.LinkedMultiValueMap; | ||
17 | import org.springframework.util.MultiValueMap; | 25 | import org.springframework.util.MultiValueMap; |
18 | import org.springframework.web.client.RestTemplate; | 26 | import org.springframework.web.client.RestTemplate; |
19 | 27 | ||
28 | +import java.util.HashMap; | ||
20 | import java.util.List; | 29 | import java.util.List; |
21 | import java.util.Map; | 30 | import java.util.Map; |
22 | import java.util.concurrent.*; | 31 | import java.util.concurrent.*; |
@@ -36,6 +45,9 @@ public class JavaApiClient { | @@ -36,6 +45,9 @@ public class JavaApiClient { | ||
36 | private IMObjectInfoService mObjectInfoService; | 45 | private IMObjectInfoService mObjectInfoService; |
37 | 46 | ||
38 | @Autowired | 47 | @Autowired |
48 | + private IHostInfoService hostInfoService; | ||
49 | + | ||
50 | + @Autowired | ||
39 | @Qualifier("javaapiRestTemplate") | 51 | @Qualifier("javaapiRestTemplate") |
40 | private RestTemplate restTemplate; | 52 | private RestTemplate restTemplate; |
41 | // | 53 | // |
@@ -46,11 +58,14 @@ public class JavaApiClient { | @@ -46,11 +58,14 @@ public class JavaApiClient { | ||
46 | @Autowired | 58 | @Autowired |
47 | private List<IJavaApiHadnler> javaApiHadnlerList; | 59 | private List<IJavaApiHadnler> javaApiHadnlerList; |
48 | 60 | ||
61 | + @Autowired | ||
62 | + JavaApiStatus javaApiStatus; | ||
63 | + | ||
49 | 64 | ||
50 | //TODO 需要 线程安全 处理 不过一般不会出现并发,任务周期比较长,一般周期内任务能够完成 | 65 | //TODO 需要 线程安全 处理 不过一般不会出现并发,任务周期比较长,一般周期内任务能够完成 |
51 | private Map<String, JavaApiInfo> javaApimap; | 66 | private Map<String, JavaApiInfo> javaApimap; |
52 | 67 | ||
53 | - private MultiValueMap<Integer, MObjectInfo> mObjInfoMap; | 68 | + private MultiValueMap<Integer, MObjectDetails> mObjInfoMap; |
54 | 69 | ||
55 | private ExecutorService executorService; | 70 | private ExecutorService executorService; |
56 | 71 | ||
@@ -64,21 +79,48 @@ public class JavaApiClient { | @@ -64,21 +79,48 @@ public class JavaApiClient { | ||
64 | completionService = new ExecutorCompletionService<JavaApiStatics>(executorService); | 79 | completionService = new ExecutorCompletionService<JavaApiStatics>(executorService); |
65 | 80 | ||
66 | javaApimap = new ConcurrentHashMap<String, JavaApiInfo>(); | 81 | javaApimap = new ConcurrentHashMap<String, JavaApiInfo>(); |
67 | - mObjInfoMap = new LinkedMultiValueMap<Integer, MObjectInfo>(); | 82 | + mObjInfoMap = new LinkedMultiValueMap<Integer, MObjectDetails>(); |
83 | + | ||
84 | + //清理本次统计信息 | ||
85 | + javaApiStatus.clear(); | ||
68 | } | 86 | } |
69 | 87 | ||
70 | public void initApiMonitor() { | 88 | public void initApiMonitor() { |
89 | + //获取JAVA服务信息 | ||
71 | List<JavaApiInfo> apiInfos = javaApiInfoService.queryJavaApiInfo(); | 90 | List<JavaApiInfo> apiInfos = javaApiInfoService.queryJavaApiInfo(); |
72 | 91 | ||
73 | for (JavaApiInfo javaApiInfo : apiInfos) { | 92 | for (JavaApiInfo javaApiInfo : apiInfos) { |
74 | javaApimap.put(javaApiInfo.getApiName(), javaApiInfo); | 93 | javaApimap.put(javaApiInfo.getApiName(), javaApiInfo); |
75 | } | 94 | } |
76 | 95 | ||
96 | + //获取云类型 | ||
97 | + HostInfoReq req = new HostInfoReq(); | ||
98 | + req.setPageSize(1000); | ||
99 | + req.setCurrentPage(0); | ||
100 | + PageResponse<HostInfo> hostInfos = hostInfoService.getHostInfos(req); | ||
101 | + Map<String, Integer> ipCloudMap = new HashMap<String, Integer>(); | ||
102 | + | ||
103 | + if (hostInfos.getTotal() > 0) { | ||
104 | + for (HostInfo hostInfo : hostInfos.getRows()) { | ||
105 | + ipCloudMap.put(hostInfo.getHostIp().trim(), hostInfo.getCloudType()); | ||
106 | + } | ||
107 | + } | ||
108 | + | ||
109 | + | ||
110 | + //获取部署java服务的服务对象 | ||
77 | //TODO 需要删选java服务 | 111 | //TODO 需要删选java服务 |
78 | List<MObjectInfo> mObjectInfos = mObjectInfoService.queryMObjectsInfo(); | 112 | List<MObjectInfo> mObjectInfos = mObjectInfoService.queryMObjectsInfo(); |
79 | 113 | ||
80 | for (MObjectInfo mObjInfo : mObjectInfos) { | 114 | for (MObjectInfo mObjInfo : mObjectInfos) { |
81 | - mObjInfoMap.add(mObjInfo.getMoTypeId(), mObjInfo); | 115 | + MObjectDetails mObjectDetails = new MObjectDetails(); |
116 | + BeanUtils.copyProperties(mObjInfo, mObjectDetails); | ||
117 | + | ||
118 | + if (ipCloudMap.containsKey(mObjInfo.getMoHostIp())) { | ||
119 | + mObjectDetails.setCloudType(ipCloudMap.get(mObjInfo.getMoHostIp().trim())); | ||
120 | + } else { | ||
121 | + mObjectDetails.setCloudType(0); | ||
122 | + } | ||
123 | + mObjInfoMap.add(mObjInfo.getMoTypeId(), mObjectDetails); | ||
82 | } | 124 | } |
83 | 125 | ||
84 | } | 126 | } |
@@ -89,12 +131,12 @@ public class JavaApiClient { | @@ -89,12 +131,12 @@ public class JavaApiClient { | ||
89 | int tastNum = 0; | 131 | int tastNum = 0; |
90 | for (JavaApiInfo javaApiInfo : javaApimap.values()) { | 132 | for (JavaApiInfo javaApiInfo : javaApimap.values()) { |
91 | 133 | ||
92 | - List<MObjectInfo> mObjectInfos = mObjInfoMap.get(javaApiInfo.getServiceType()); | 134 | + List<MObjectDetails> mObjectInfos = mObjInfoMap.get(javaApiInfo.getServiceType()); |
93 | if (mObjectInfos == null) { | 135 | if (mObjectInfos == null) { |
94 | log.warn("type {} has no service object", javaApiInfo.getServiceType()); | 136 | log.warn("type {} has no service object", javaApiInfo.getServiceType()); |
95 | continue; | 137 | continue; |
96 | } | 138 | } |
97 | - for (MObjectInfo mObjectInfo : mObjectInfos) { | 139 | + for (MObjectDetails mObjectInfo : mObjectInfos) { |
98 | completionService.submit(new JavaApiTask(restTemplate, javaApiInfo, mObjectInfo)); | 140 | completionService.submit(new JavaApiTask(restTemplate, javaApiInfo, mObjectInfo)); |
99 | tastNum++; | 141 | tastNum++; |
100 | } | 142 | } |
@@ -119,7 +161,21 @@ public class JavaApiClient { | @@ -119,7 +161,21 @@ public class JavaApiClient { | ||
119 | 161 | ||
120 | 162 | ||
121 | public void handleResult(JavaApiStatics rep) { | 163 | public void handleResult(JavaApiStatics rep) { |
164 | + | ||
165 | + | ||
166 | + //TODO 加开关 控制gateway的检测条件 | ||
167 | + //先做预处理,主要对返回结果格式为{code:200,message:".."}的响应做处理,对code非200的设置异常标志 | ||
168 | + for (IJavaApiHadnler javaApiHadnler : javaApiHadnlerList) { | ||
169 | + if (javaApiHadnler instanceof PreProcessJavaApiHandler) { | ||
170 | + javaApiHadnler.handler(rep); | ||
171 | + break; | ||
172 | + } | ||
173 | + } | ||
174 | + | ||
175 | + | ||
122 | for (IJavaApiHadnler javaApiHadnler : javaApiHadnlerList) { | 176 | for (IJavaApiHadnler javaApiHadnler : javaApiHadnlerList) { |
177 | + if (javaApiHadnler instanceof PreProcessJavaApiHandler) | ||
178 | + continue; | ||
123 | javaApiHadnler.handler(rep); | 179 | javaApiHadnler.handler(rep); |
124 | } | 180 | } |
125 | } | 181 | } |
@@ -135,9 +191,9 @@ public class JavaApiClient { | @@ -135,9 +191,9 @@ public class JavaApiClient { | ||
135 | completionService = new ExecutorCompletionService<JavaApiStatics>(executorService); | 191 | completionService = new ExecutorCompletionService<JavaApiStatics>(executorService); |
136 | 192 | ||
137 | javaApimap = new ConcurrentHashMap<String, JavaApiInfo>(); | 193 | javaApimap = new ConcurrentHashMap<String, JavaApiInfo>(); |
138 | - mObjInfoMap = new LinkedMultiValueMap<Integer, MObjectInfo>(); | 194 | + mObjInfoMap = new LinkedMultiValueMap<Integer, MObjectDetails>(); |
139 | 195 | ||
140 | - MObjectInfo mObj1 = new MObjectInfo(); | 196 | + MObjectDetails mObj1 = new MObjectDetails(); |
141 | mObj1.setMoId(1); | 197 | mObj1.setMoId(1); |
142 | mObj1.setMoHostIp("192.168.102.205"); | 198 | mObj1.setMoHostIp("192.168.102.205"); |
143 | mObj1.setMoTags("8080"); | 199 | mObj1.setMoTags("8080"); |
@@ -155,7 +211,7 @@ public class JavaApiClient { | @@ -155,7 +211,7 @@ public class JavaApiClient { | ||
155 | // | 211 | // |
156 | // mObjInfoMap.add(1, mObj2); | 212 | // mObjInfoMap.add(1, mObj2); |
157 | 213 | ||
158 | - MObjectInfo mObj2 = new MObjectInfo(); | 214 | + MObjectDetails mObj2 = new MObjectDetails(); |
159 | mObj2.setMoId(0); | 215 | mObj2.setMoId(0); |
160 | mObj2.setMoHostIp("localhost"); | 216 | mObj2.setMoHostIp("localhost"); |
161 | mObj2.setMoTags("10080"); | 217 | mObj2.setMoTags("10080"); |
@@ -2,6 +2,7 @@ package com.monitor.javaserver.common; | @@ -2,6 +2,7 @@ package com.monitor.javaserver.common; | ||
2 | 2 | ||
3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
4 | import com.model.JavaApiInfo; | 4 | import com.model.JavaApiInfo; |
5 | +import com.model.MObjectDetails; | ||
5 | import com.model.MObjectInfo; | 6 | import com.model.MObjectInfo; |
6 | import lombok.Data; | 7 | import lombok.Data; |
7 | import org.apache.commons.lang.builder.ReflectionToStringBuilder; | 8 | import org.apache.commons.lang.builder.ReflectionToStringBuilder; |
@@ -15,7 +16,7 @@ public class JavaApiStatics{ | @@ -15,7 +16,7 @@ public class JavaApiStatics{ | ||
15 | 16 | ||
16 | private JavaApiInfo javaApiInfo; | 17 | private JavaApiInfo javaApiInfo; |
17 | 18 | ||
18 | - private MObjectInfo mObjectInfo; | 19 | + private MObjectDetails mObjectDetails; |
19 | 20 | ||
20 | private long startTime; | 21 | private long startTime; |
21 | 22 |
monitor-service-javaserver/src/main/java/com/monitor/javaserver/common/JavaApiStatus.java
0 → 100644
1 | +package com.monitor.javaserver.common; | ||
2 | + | ||
3 | +import com.monitor.common.util.DateFormatUtil; | ||
4 | +import com.monitor.model.response.JavaApiStaticsRep; | ||
5 | +import com.monitor.model.response.JavaApiStatusRep; | ||
6 | +import org.apache.commons.collections.map.MultiKeyMap; | ||
7 | +import org.springframework.stereotype.Component; | ||
8 | + | ||
9 | +import java.util.ArrayList; | ||
10 | +import java.util.Enumeration; | ||
11 | +import java.util.List; | ||
12 | +import java.util.concurrent.ConcurrentHashMap; | ||
13 | +import java.util.concurrent.atomic.AtomicInteger; | ||
14 | +import java.util.concurrent.atomic.AtomicLong; | ||
15 | + | ||
16 | +/** | ||
17 | + * 记录当前java服务概况 | ||
18 | + * Created by fruwei on 2016/6/27. | ||
19 | + */ | ||
20 | +@Component | ||
21 | +public class JavaApiStatus { | ||
22 | + | ||
23 | + /** | ||
24 | + * key: app_id | ||
25 | + * val: error_num | ||
26 | + */ | ||
27 | + private ConcurrentHashMap<String, AtomicInteger> mapStaticsErr = new ConcurrentHashMap<String, AtomicInteger>(); | ||
28 | + private ConcurrentHashMap<String, AtomicInteger> mapStaticsOk = new ConcurrentHashMap<String, AtomicInteger>(); | ||
29 | + | ||
30 | + private ConcurrentHashMap<String, Long> mapUpdateTime = new ConcurrentHashMap<String, Long>(); | ||
31 | + | ||
32 | + public void addError(JavaApiStatics javaApiStatics) { | ||
33 | + int apiType = javaApiStatics.getJavaApiInfo().getServiceType(); | ||
34 | + int cloud = javaApiStatics.getMObjectDetails().getCloudType(); | ||
35 | + String key = cloud + "_" + apiType; | ||
36 | + mapStaticsErr.putIfAbsent(key, new AtomicInteger(0)); | ||
37 | + mapStaticsErr.get(key).getAndIncrement(); | ||
38 | + | ||
39 | + mapUpdateTime.putIfAbsent(key, javaApiStatics.getEndTime()); | ||
40 | + | ||
41 | + } | ||
42 | + | ||
43 | + | ||
44 | + public void addSuccess(JavaApiStatics javaApiStatics) { | ||
45 | + int apiType = javaApiStatics.getJavaApiInfo().getServiceType(); | ||
46 | + int cloud = javaApiStatics.getMObjectDetails().getCloudType(); | ||
47 | + String key = cloud + "_" + apiType; | ||
48 | + mapStaticsOk.putIfAbsent(key, new AtomicInteger(0)); | ||
49 | + mapStaticsOk.get(key).getAndIncrement(); | ||
50 | + | ||
51 | + mapUpdateTime.putIfAbsent(key, javaApiStatics.getEndTime()); | ||
52 | + } | ||
53 | + | ||
54 | + | ||
55 | + public void clear() { | ||
56 | + mapStaticsErr.clear(); | ||
57 | + mapStaticsOk.clear(); | ||
58 | + mapUpdateTime.clear(); | ||
59 | + } | ||
60 | + | ||
61 | + | ||
62 | + public List<JavaApiStaticsRep> getStatusList() { | ||
63 | + | ||
64 | + List<JavaApiStaticsRep> rel = new ArrayList<JavaApiStaticsRep>(); | ||
65 | + | ||
66 | + MultiKeyMap multiKeyMap = new MultiKeyMap(); | ||
67 | + | ||
68 | + | ||
69 | + Enumeration<String> errkeys = mapStaticsErr.keys(); | ||
70 | + while (errkeys.hasMoreElements()) { | ||
71 | + String key = errkeys.nextElement(); | ||
72 | + JavaApiStaticsRep statics = new JavaApiStaticsRep(); | ||
73 | + String[] strKeys = key.split("_"); | ||
74 | + statics.setCloudType(Integer.parseInt(strKeys[0])); | ||
75 | + statics.setServiceType(Integer.parseInt(strKeys[1])); | ||
76 | + | ||
77 | + statics.setErrNum(mapStaticsErr.getOrDefault(key, new AtomicInteger(0)).intValue()); | ||
78 | + multiKeyMap.put(statics.getServiceType(), statics.getServiceType(), statics); | ||
79 | + | ||
80 | + rel.add(statics); | ||
81 | + } | ||
82 | + | ||
83 | + | ||
84 | + Enumeration<String> okeys = mapStaticsOk.keys(); | ||
85 | + while (okeys.hasMoreElements()) { | ||
86 | + String key = okeys.nextElement(); | ||
87 | + JavaApiStaticsRep statics = new JavaApiStaticsRep(); | ||
88 | + String[] strKeys = key.split("_"); | ||
89 | + statics.setCloudType(Integer.parseInt(strKeys[0])); | ||
90 | + statics.setServiceType(Integer.parseInt(strKeys[1])); | ||
91 | + if (multiKeyMap.containsKey(statics.getCloudType(), statics.getServiceType())) { | ||
92 | + statics = (JavaApiStaticsRep) multiKeyMap.get(statics.getCloudType(), statics.getServiceType()); | ||
93 | + } else { | ||
94 | + multiKeyMap.put(statics.getServiceType(), statics.getServiceType(), statics); | ||
95 | + } | ||
96 | + statics.setOkNum(mapStaticsOk.getOrDefault(key, new AtomicInteger(0)).intValue()); | ||
97 | + rel.add(statics); | ||
98 | + } | ||
99 | + | ||
100 | + long time; | ||
101 | + for (JavaApiStaticsRep javaApiStaticsRep : rel) { | ||
102 | + time = mapUpdateTime.get(javaApiStaticsRep.getCloudType() + "_" + javaApiStaticsRep.getServiceType()); | ||
103 | + javaApiStaticsRep.setUpdateTime(DateFormatUtil.parseLongToTimeStr(time)); | ||
104 | + } | ||
105 | + | ||
106 | + return rel; | ||
107 | + } | ||
108 | + | ||
109 | + | ||
110 | +} |
@@ -3,6 +3,7 @@ package com.monitor.javaserver.common; | @@ -3,6 +3,7 @@ package com.monitor.javaserver.common; | ||
3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
4 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
5 | import com.model.JavaApiInfo; | 5 | import com.model.JavaApiInfo; |
6 | +import com.model.MObjectDetails; | ||
6 | import com.model.MObjectInfo; | 7 | import com.model.MObjectInfo; |
7 | import org.slf4j.Logger; | 8 | import org.slf4j.Logger; |
8 | import org.slf4j.LoggerFactory; | 9 | import org.slf4j.LoggerFactory; |
@@ -18,12 +19,12 @@ public class JavaApiTask implements Callable<JavaApiStatics> { | @@ -18,12 +19,12 @@ public class JavaApiTask implements Callable<JavaApiStatics> { | ||
18 | Logger log = LoggerFactory.getLogger(JavaApiTask.class); | 19 | Logger log = LoggerFactory.getLogger(JavaApiTask.class); |
19 | 20 | ||
20 | private JavaApiInfo javaApiInfo; | 21 | private JavaApiInfo javaApiInfo; |
21 | - private MObjectInfo mObjectInfo; | 22 | + private MObjectDetails mObjectInfo; |
22 | 23 | ||
23 | private RestTemplate restTemplate; | 24 | private RestTemplate restTemplate; |
24 | 25 | ||
25 | 26 | ||
26 | - public JavaApiTask(RestTemplate restTemplate, JavaApiInfo javaApiInfo, MObjectInfo mObjectInfo) { | 27 | + public JavaApiTask(RestTemplate restTemplate, JavaApiInfo javaApiInfo, MObjectDetails mObjectInfo) { |
27 | this.javaApiInfo = javaApiInfo; | 28 | this.javaApiInfo = javaApiInfo; |
28 | this.mObjectInfo = mObjectInfo; | 29 | this.mObjectInfo = mObjectInfo; |
29 | this.restTemplate = restTemplate; | 30 | this.restTemplate = restTemplate; |
@@ -42,7 +43,7 @@ public class JavaApiTask implements Callable<JavaApiStatics> { | @@ -42,7 +43,7 @@ public class JavaApiTask implements Callable<JavaApiStatics> { | ||
42 | apiStatics.setStartTime(System.currentTimeMillis()); | 43 | apiStatics.setStartTime(System.currentTimeMillis()); |
43 | apiStatics.setHasException(false); | 44 | apiStatics.setHasException(false); |
44 | apiStatics.setJavaApiInfo(this.javaApiInfo); | 45 | apiStatics.setJavaApiInfo(this.javaApiInfo); |
45 | - apiStatics.setMObjectInfo(this.mObjectInfo); | 46 | + apiStatics.setMObjectDetails(this.mObjectInfo); |
46 | //TODO JSON解析异常 | 47 | //TODO JSON解析异常 |
47 | try { | 48 | try { |
48 | if (javaApiInfo.getApiReqMethod() == 0) { | 49 | if (javaApiInfo.getApiReqMethod() == 0) { |
@@ -6,6 +6,7 @@ import com.monitor.model.page.PageResponse; | @@ -6,6 +6,7 @@ import com.monitor.model.page.PageResponse; | ||
6 | import com.monitor.model.request.JavaApiHisReq; | 6 | import com.monitor.model.request.JavaApiHisReq; |
7 | import com.monitor.model.request.JavaApiStatusReq; | 7 | import com.monitor.model.request.JavaApiStatusReq; |
8 | import com.monitor.model.response.BaseResponse; | 8 | import com.monitor.model.response.BaseResponse; |
9 | +import com.monitor.model.response.JavaApiStaticsRep; | ||
9 | import com.monitor.model.response.JavaApiStatusRep; | 10 | import com.monitor.model.response.JavaApiStatusRep; |
10 | import org.slf4j.Logger; | 11 | import org.slf4j.Logger; |
11 | import org.slf4j.LoggerFactory; | 12 | import org.slf4j.LoggerFactory; |
@@ -105,7 +106,7 @@ public class JavaAppInfoStaticsCtrl { | @@ -105,7 +106,7 @@ public class JavaAppInfoStaticsCtrl { | ||
105 | } | 106 | } |
106 | 107 | ||
107 | if (req.getEndTime() == 0) | 108 | if (req.getEndTime() == 0) |
108 | - req.setEndTime( System.currentTimeMillis()); | 109 | + req.setEndTime(System.currentTimeMillis()); |
109 | 110 | ||
110 | 111 | ||
111 | BaseResponse baseResponse = new BaseResponse(); | 112 | BaseResponse baseResponse = new BaseResponse(); |
@@ -130,4 +131,23 @@ public class JavaAppInfoStaticsCtrl { | @@ -130,4 +131,23 @@ public class JavaAppInfoStaticsCtrl { | ||
130 | 131 | ||
131 | } | 132 | } |
132 | 133 | ||
134 | + @RequestMapping("/queryAll") | ||
135 | + @ResponseBody | ||
136 | + public BaseResponse getAllJavaApiStatus() { | ||
137 | + | ||
138 | + BaseResponse baseResponse = new BaseResponse(); | ||
139 | + try { | ||
140 | + List<JavaApiStaticsRep> staticsReps = javaApiStatusService.getAllJavaApiStatus(); | ||
141 | + baseResponse.setData(staticsReps); | ||
142 | + } catch (Exception e) { | ||
143 | + log.warn("query his failed req", e); | ||
144 | + baseResponse.setCode(400); | ||
145 | + baseResponse.setMessage(e.getMessage()); | ||
146 | + } | ||
147 | + | ||
148 | + return baseResponse; | ||
149 | + | ||
150 | + } | ||
151 | + | ||
152 | + | ||
133 | } | 153 | } |
@@ -2,6 +2,7 @@ package com.monitor.javaserver.handle.impl; | @@ -2,6 +2,7 @@ package com.monitor.javaserver.handle.impl; | ||
2 | 2 | ||
3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
4 | import com.model.JavaApiInfo; | 4 | import com.model.JavaApiInfo; |
5 | +import com.model.MObjectDetails; | ||
5 | import com.model.MObjectInfo; | 6 | import com.model.MObjectInfo; |
6 | import com.monitor.influxdb.mapper.impl.JavaApiStaticsMapper; | 7 | import com.monitor.influxdb.mapper.impl.JavaApiStaticsMapper; |
7 | import com.monitor.javaserver.common.JavaApiStatics; | 8 | import com.monitor.javaserver.common.JavaApiStatics; |
@@ -34,7 +35,7 @@ public class InfluxDBJavaApiHandler implements IJavaApiHadnler { | @@ -34,7 +35,7 @@ public class InfluxDBJavaApiHandler implements IJavaApiHadnler { | ||
34 | jsonObject.put("api_type", javaApiInfo.getServiceType()); | 35 | jsonObject.put("api_type", javaApiInfo.getServiceType()); |
35 | jsonObject.put("api_url", javaApiInfo.getApiUrl()); | 36 | jsonObject.put("api_url", javaApiInfo.getApiUrl()); |
36 | 37 | ||
37 | - MObjectInfo mobjInfo = javaApiStatics.getMObjectInfo(); | 38 | + MObjectDetails mobjInfo = javaApiStatics.getMObjectDetails(); |
38 | 39 | ||
39 | jsonObject.put("mobj_name", mobjInfo.getMoName()); | 40 | jsonObject.put("mobj_name", mobjInfo.getMoName()); |
40 | jsonObject.put("mobj_ip", mobjInfo.getMoHostIp()); | 41 | jsonObject.put("mobj_ip", mobjInfo.getMoHostIp()); |
@@ -52,8 +53,8 @@ public class InfluxDBJavaApiHandler implements IJavaApiHadnler { | @@ -52,8 +53,8 @@ public class InfluxDBJavaApiHandler implements IJavaApiHadnler { | ||
52 | jsonObject.put("exception", ExceptionUtils.getStackTrace(javaApiStatics.getException())); | 53 | jsonObject.put("exception", ExceptionUtils.getStackTrace(javaApiStatics.getException())); |
53 | 54 | ||
54 | } else { | 55 | } else { |
55 | - JSONObject rep = javaApiStatics.getResponse(); | ||
56 | - jsonObject.put("response", javaApiStatics.getResponse()); | 56 | +// JSONObject rep = javaApiStatics.getResponse(); |
57 | +// jsonObject.put("response", javaApiStatics.getResponse()); | ||
57 | } | 58 | } |
58 | 59 | ||
59 | javaApiStaticsMapper.insertJavaApiStatics(null, jsonObject); | 60 | javaApiStaticsMapper.insertJavaApiStatics(null, jsonObject); |
1 | package com.monitor.javaserver.handle.impl; | 1 | package com.monitor.javaserver.handle.impl; |
2 | 2 | ||
3 | import com.model.JavaApiInfo; | 3 | import com.model.JavaApiInfo; |
4 | +import com.model.MObjectDetails; | ||
4 | import com.model.MObjectInfo; | 5 | import com.model.MObjectInfo; |
5 | import com.monitor.common.config.SnsMobileConfig; | 6 | import com.monitor.common.config.SnsMobileConfig; |
6 | import com.monitor.common.service.AlarmMsgService; | 7 | import com.monitor.common.service.AlarmMsgService; |
@@ -26,7 +27,9 @@ public class MsgJavaApiHandler implements IJavaApiHadnler { | @@ -26,7 +27,9 @@ public class MsgJavaApiHandler implements IJavaApiHadnler { | ||
26 | public AlarmMsgService alarmMsgService; | 27 | public AlarmMsgService alarmMsgService; |
27 | @Autowired | 28 | @Autowired |
28 | private SnsMobileConfig snsMobileConfig; | 29 | private SnsMobileConfig snsMobileConfig; |
29 | - | 30 | + /** |
31 | + * 应该不会出现并发情况 | ||
32 | + */ | ||
30 | private ConcurrentHashMap<String, AtomicInteger> mapStatics = new ConcurrentHashMap<String, AtomicInteger>(); | 33 | private ConcurrentHashMap<String, AtomicInteger> mapStatics = new ConcurrentHashMap<String, AtomicInteger>(); |
31 | 34 | ||
32 | 35 | ||
@@ -42,13 +45,8 @@ public class MsgJavaApiHandler implements IJavaApiHadnler { | @@ -42,13 +45,8 @@ public class MsgJavaApiHandler implements IJavaApiHadnler { | ||
42 | } | 45 | } |
43 | 46 | ||
44 | int num = 0; | 47 | int num = 0; |
45 | - if (mapStatics.containsKey(key)) { | ||
46 | - AtomicInteger errNums = mapStatics.get(key); | ||
47 | - num = errNums.incrementAndGet(); | ||
48 | - } else { | ||
49 | - mapStatics.put(key, new AtomicInteger(1)); | ||
50 | - num = 1; | ||
51 | - } | 48 | + mapStatics.putIfAbsent(key, new AtomicInteger(0)); |
49 | + num = mapStatics.get(key).incrementAndGet(); | ||
52 | 50 | ||
53 | JavaApiInfo javaApiInfo = javaApiStatics.getJavaApiInfo(); | 51 | JavaApiInfo javaApiInfo = javaApiStatics.getJavaApiInfo(); |
54 | if (javaApiInfo.getApiWarnTrigger() > 0 && | 52 | if (javaApiInfo.getApiWarnTrigger() > 0 && |
@@ -65,14 +63,14 @@ public class MsgJavaApiHandler implements IJavaApiHadnler { | @@ -65,14 +63,14 @@ public class MsgJavaApiHandler implements IJavaApiHadnler { | ||
65 | 63 | ||
66 | public String buildKey(JavaApiStatics javaApiStatics) { | 64 | public String buildKey(JavaApiStatics javaApiStatics) { |
67 | String key; | 65 | String key; |
68 | - key = javaApiStatics.getJavaApiInfo().getServiceId() + "_" + javaApiStatics.getMObjectInfo().getMoId(); | 66 | + key = javaApiStatics.getJavaApiInfo().getServiceId() + "_" + javaApiStatics.getMObjectDetails().getMoId(); |
69 | return key; | 67 | return key; |
70 | } | 68 | } |
71 | 69 | ||
72 | 70 | ||
73 | public String buildErrMsg(int num, JavaApiStatics javaApiStatics) { | 71 | public String buildErrMsg(int num, JavaApiStatics javaApiStatics) { |
74 | JavaApiInfo javaApiInfo = javaApiStatics.getJavaApiInfo(); | 72 | JavaApiInfo javaApiInfo = javaApiStatics.getJavaApiInfo(); |
75 | - MObjectInfo mObjectInfo = javaApiStatics.getMObjectInfo(); | 73 | + MObjectDetails mObjectInfo = javaApiStatics.getMObjectDetails(); |
76 | 74 | ||
77 | StringBuilder msgBuilder = new StringBuilder(); | 75 | StringBuilder msgBuilder = new StringBuilder(); |
78 | msgBuilder.append("Java API Error ") | 76 | msgBuilder.append("Java API Error ") |
1 | +package com.monitor.javaserver.handle.impl; | ||
2 | + | ||
3 | +import com.monitor.javaserver.common.JavaApiStatics; | ||
4 | +import com.monitor.javaserver.handle.IJavaApiHadnler; | ||
5 | +import org.springframework.stereotype.Component; | ||
6 | + | ||
7 | +/** | ||
8 | + * 预处理,主要对返回结果格式为{code:200,message:".."}的响应做处理,对code非200的设置异常标志 | ||
9 | + * Created by fruwei on 2016/6/28. | ||
10 | + */ | ||
11 | +@Component | ||
12 | +public class PreProcessJavaApiHandler implements IJavaApiHadnler { | ||
13 | + @Override | ||
14 | + public void handler(JavaApiStatics javaApiStatics) { | ||
15 | + | ||
16 | + if (javaApiStatics.getJavaApiInfo().getApiToggle() == 0) | ||
17 | + return; | ||
18 | + | ||
19 | + if (javaApiStatics.isHasException() == true || javaApiStatics.getResponse() == null) | ||
20 | + return; | ||
21 | + | ||
22 | + if (!javaApiStatics.getResponse().containsKey("code")) { | ||
23 | + return; | ||
24 | + } | ||
25 | + | ||
26 | + int code; | ||
27 | + try { | ||
28 | + code = javaApiStatics.getResponse().getInteger("code"); | ||
29 | + if (code == 200) { | ||
30 | + return; | ||
31 | + } | ||
32 | + } catch (Exception e) { | ||
33 | + return; | ||
34 | + } | ||
35 | + | ||
36 | + //code!=200 说明有异常 | ||
37 | + javaApiStatics.setHasException(true); | ||
38 | + | ||
39 | + | ||
40 | + String msg = "code:" + code; | ||
41 | + if (javaApiStatics.getResponse().containsKey("message")) { | ||
42 | + msg += " msg:" + javaApiStatics.getResponse().getString("message"); | ||
43 | + } | ||
44 | + javaApiStatics.setException(new Exception(msg)); | ||
45 | + | ||
46 | + } | ||
47 | +} |
1 | +package com.monitor.javaserver.handle.impl; | ||
2 | + | ||
3 | +import com.monitor.javaserver.common.JavaApiStatics; | ||
4 | +import com.monitor.javaserver.common.JavaApiStatus; | ||
5 | +import com.monitor.javaserver.handle.IJavaApiHadnler; | ||
6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
7 | +import org.springframework.stereotype.Component; | ||
8 | + | ||
9 | +import java.util.concurrent.ConcurrentHashMap; | ||
10 | +import java.util.concurrent.atomic.AtomicInteger; | ||
11 | + | ||
12 | +/** | ||
13 | + * 统计信息处理 | ||
14 | + * Created by fruwei on 2016/6/27. | ||
15 | + */ | ||
16 | +@Component | ||
17 | +public class StaticsJavaApiHandler implements IJavaApiHadnler { | ||
18 | + | ||
19 | + @Autowired | ||
20 | + JavaApiStatus javaApiStatus; | ||
21 | + | ||
22 | + | ||
23 | + @Override | ||
24 | + public void handler(JavaApiStatics javaApiStatics) { | ||
25 | + | ||
26 | + if(javaApiStatics.getJavaApiInfo().getApiToggle()==0){ | ||
27 | + return; | ||
28 | + } | ||
29 | + if (javaApiStatics.isHasException()) { | ||
30 | + javaApiStatus.addError(javaApiStatics); | ||
31 | + } else { | ||
32 | + javaApiStatus.addSuccess(javaApiStatics); | ||
33 | + } | ||
34 | + | ||
35 | + } | ||
36 | + | ||
37 | + | ||
38 | +} |
@@ -2,6 +2,7 @@ package com.monitor.javaserver.service; | @@ -2,6 +2,7 @@ package com.monitor.javaserver.service; | ||
2 | 2 | ||
3 | import com.monitor.model.request.JavaApiHisReq; | 3 | import com.monitor.model.request.JavaApiHisReq; |
4 | import com.monitor.model.request.JavaApiStatusReq; | 4 | import com.monitor.model.request.JavaApiStatusReq; |
5 | +import com.monitor.model.response.JavaApiStaticsRep; | ||
5 | import com.monitor.model.response.JavaApiStatusRep; | 6 | import com.monitor.model.response.JavaApiStatusRep; |
6 | 7 | ||
7 | import java.util.List; | 8 | import java.util.List; |
@@ -22,5 +23,7 @@ public interface IJavaApiStatusService { | @@ -22,5 +23,7 @@ public interface IJavaApiStatusService { | ||
22 | 23 | ||
23 | public int countJavaApiStatusHisByTime(JavaApiHisReq req); | 24 | public int countJavaApiStatusHisByTime(JavaApiHisReq req); |
24 | 25 | ||
26 | + public List<JavaApiStaticsRep> getAllJavaApiStatus(); | ||
27 | + | ||
25 | 28 | ||
26 | } | 29 | } |
@@ -3,10 +3,12 @@ package com.monitor.javaserver.service.impl; | @@ -3,10 +3,12 @@ package com.monitor.javaserver.service.impl; | ||
3 | import com.monitor.common.contants.PaginationContants; | 3 | import com.monitor.common.contants.PaginationContants; |
4 | import com.monitor.common.util.DateFormatUtil; | 4 | import com.monitor.common.util.DateFormatUtil; |
5 | import com.monitor.influxdb.mapper.impl.JavaApiStaticsMapper; | 5 | import com.monitor.influxdb.mapper.impl.JavaApiStaticsMapper; |
6 | +import com.monitor.javaserver.common.JavaApiStatus; | ||
6 | import com.monitor.javaserver.service.IJavaApiStatusService; | 7 | import com.monitor.javaserver.service.IJavaApiStatusService; |
7 | import com.monitor.model.domain.JavaApiStaticsModel; | 8 | import com.monitor.model.domain.JavaApiStaticsModel; |
8 | import com.monitor.model.request.JavaApiHisReq; | 9 | import com.monitor.model.request.JavaApiHisReq; |
9 | import com.monitor.model.request.JavaApiStatusReq; | 10 | import com.monitor.model.request.JavaApiStatusReq; |
11 | +import com.monitor.model.response.JavaApiStaticsRep; | ||
10 | import com.monitor.model.response.JavaApiStatusRep; | 12 | import com.monitor.model.response.JavaApiStatusRep; |
11 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Autowired; |
12 | import org.springframework.stereotype.Component; | 14 | import org.springframework.stereotype.Component; |
@@ -24,6 +26,10 @@ public class JavaAppiStatusServiceImpl implements IJavaApiStatusService { | @@ -24,6 +26,10 @@ public class JavaAppiStatusServiceImpl implements IJavaApiStatusService { | ||
24 | @Autowired | 26 | @Autowired |
25 | JavaApiStaticsMapper javaApiStaticsMapper; | 27 | JavaApiStaticsMapper javaApiStaticsMapper; |
26 | 28 | ||
29 | + @Autowired | ||
30 | + JavaApiStatus javaApiStatus; | ||
31 | + | ||
32 | + | ||
27 | @Override | 33 | @Override |
28 | public JavaApiStatusRep getJavaApiStatus(JavaApiStatusReq req) { | 34 | public JavaApiStatusRep getJavaApiStatus(JavaApiStatusReq req) { |
29 | JavaApiStatusRep rep = new JavaApiStatusRep(); | 35 | JavaApiStatusRep rep = new JavaApiStatusRep(); |
@@ -82,7 +88,7 @@ public class JavaAppiStatusServiceImpl implements IJavaApiStatusService { | @@ -82,7 +88,7 @@ public class JavaAppiStatusServiceImpl implements IJavaApiStatusService { | ||
82 | long start = System.currentTimeMillis(); | 88 | long start = System.currentTimeMillis(); |
83 | long end = start; | 89 | long end = start; |
84 | start = start - 1000 * 60 * 60; //一小时之内 | 90 | start = start - 1000 * 60 * 60; //一小时之内 |
85 | - JavaApiHisReq req=new JavaApiHisReq(); | 91 | + JavaApiHisReq req = new JavaApiHisReq(); |
86 | req.setPageSize(10); | 92 | req.setPageSize(10); |
87 | req.setApiId(api_id); | 93 | req.setApiId(api_id); |
88 | req.setMobjId(mobj_id); | 94 | req.setMobjId(mobj_id); |
@@ -131,5 +137,12 @@ public class JavaAppiStatusServiceImpl implements IJavaApiStatusService { | @@ -131,5 +137,12 @@ public class JavaAppiStatusServiceImpl implements IJavaApiStatusService { | ||
131 | return count; | 137 | return count; |
132 | } | 138 | } |
133 | 139 | ||
140 | + @Override | ||
141 | + public List<JavaApiStaticsRep> getAllJavaApiStatus() { | ||
142 | + | ||
143 | + return javaApiStatus.getStatusList(); | ||
144 | + | ||
145 | + } | ||
146 | + | ||
134 | 147 | ||
135 | } | 148 | } |
@@ -37,7 +37,7 @@ public class InfluxComp implements Runnable { | @@ -37,7 +37,7 @@ public class InfluxComp implements Runnable { | ||
37 | 37 | ||
38 | influxDBClient = InfluxDBFactory.connect(this.influxUrl, this.influxUser, this.influxPwd); | 38 | influxDBClient = InfluxDBFactory.connect(this.influxUrl, this.influxUser, this.influxPwd); |
39 | 39 | ||
40 | - InterVar.EXECUTOR_SERVICE.submit(this); | 40 | +// InterVar.EXECUTOR_SERVICE.submit(this); |
41 | } | 41 | } |
42 | 42 | ||
43 | public void doService() { | 43 | public void doService() { |
@@ -26,7 +26,7 @@ import static com.monitor.middleware.rabbitmq.constant.InterVar.EXECUTOR_SERVICE | @@ -26,7 +26,7 @@ import static com.monitor.middleware.rabbitmq.constant.InterVar.EXECUTOR_SERVICE | ||
26 | @Component | 26 | @Component |
27 | public class RabbitMonitTask { | 27 | public class RabbitMonitTask { |
28 | 28 | ||
29 | - @Scheduled(cron = "* 0/3 * * * ? ") | 29 | +// @Scheduled(cron = "* 0/3 * * * ? ") |
30 | public void doTask() { | 30 | public void doTask() { |
31 | for (Map.Entry<Integer, MObjectInfo> entry : InterVar.moMaps.entrySet()) { | 31 | for (Map.Entry<Integer, MObjectInfo> entry : InterVar.moMaps.entrySet()) { |
32 | EXECUTOR_SERVICE.submit(new OneJob(new ClusterViewJob(entry.getKey()))); | 32 | EXECUTOR_SERVICE.submit(new OneJob(new ClusterViewJob(entry.getKey()))); |
@@ -29,7 +29,7 @@ public class RabbitScanTask { | @@ -29,7 +29,7 @@ public class RabbitScanTask { | ||
29 | ITypeInfoService typeService; | 29 | ITypeInfoService typeService; |
30 | 30 | ||
31 | //自动发现rabbit监控对象 | 31 | //自动发现rabbit监控对象 |
32 | - @Scheduled(cron = "* 0/1 * * * ? ") | 32 | +// @Scheduled(cron = "* 0/1 * * * ? ") |
33 | public void doTask() { | 33 | public void doTask() { |
34 | 34 | ||
35 | List<TypeInfo> typeInfosList = typeService.queryAllTypesInfo(); | 35 | List<TypeInfo> typeInfosList = typeService.queryAllTypesInfo(); |
1 | +package com.monitor.model.response; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by fruwei on 2016/6/27. | ||
7 | + */ | ||
8 | +@Data | ||
9 | +public class JavaApiStaticsRep { | ||
10 | + | ||
11 | + | ||
12 | + private int serviceType; | ||
13 | + | ||
14 | + private int cloudType; | ||
15 | + | ||
16 | + private int errNum; | ||
17 | + | ||
18 | + private int okNum; | ||
19 | + | ||
20 | + private String updateTime; | ||
21 | + | ||
22 | +} |
1 | +package com.model; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | + | ||
5 | +import java.io.Serializable; | ||
6 | + | ||
7 | +/** | ||
8 | + * Created by yoho on 2016/6/14. | ||
9 | + */ | ||
10 | +@Data | ||
11 | +public class MObjectDetails implements Serializable { | ||
12 | + private int moId = 0; | ||
13 | + | ||
14 | + private String moName; | ||
15 | + | ||
16 | + private String moHostIp; | ||
17 | + | ||
18 | + private int moTypeId; | ||
19 | + | ||
20 | + private String moTags; | ||
21 | + | ||
22 | + private String moUrl; | ||
23 | + | ||
24 | + private int cloudType; | ||
25 | + | ||
26 | +} |
@@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
16 | http://www.springframework.org/schema/task | 16 | http://www.springframework.org/schema/task |
17 | http://www.springframework.org/schema/task/spring-task.xsd"> | 17 | http://www.springframework.org/schema/task/spring-task.xsd"> |
18 | 18 | ||
19 | - <context:property-placeholder location="classpath:/product/*.properties" /> | 19 | + <context:property-placeholder location="classpath:test/*.properties" /> |
20 | 20 | ||
21 | <context:component-scan base-package="com.monitor" /> | 21 | <context:component-scan base-package="com.monitor" /> |
22 | 22 |
1 | # ******************** influxdb common configs ******************** | 1 | # ******************** influxdb common configs ******************** |
2 | -influxdb.num=2 | ||
3 | -influxdb.name=aws;qcloud | ||
4 | -influxdb.ip=http://192.168.102.162:8086;http://10.66.4.25:8086 | ||
5 | -influxdb.user=root;root | ||
6 | -influxdb.pwd=root;root | ||
7 | -influxdb.connect.timeout=15;15 | ||
8 | -influxdb.read.timeout=40;40 | ||
9 | -influxdb.write.timeout=20;20 | 2 | +influxdb.num=3 |
3 | +influxdb.name=aws;qcloud;alarm | ||
4 | +influxdb.ip=http://127.0.0.1:8086;http://10.66.4.25:8086;http://172.31.31.170:8086 | ||
5 | +influxdb.user=root;root;root | ||
6 | +influxdb.pwd=root;root;root | ||
7 | +influxdb.connect.timeout=15;15;15 | ||
8 | +influxdb.read.timeout=40;40;40 | ||
9 | +influxdb.write.timeout=20;20;20 | ||
10 | 10 | ||
11 | -aws.influxdb.url=http://123.206.79.151:8086 | 11 | +aws.influxdb.url=http://172.31.31.170:8086 |
12 | aws.influxdb.user=root | 12 | aws.influxdb.user=root |
13 | aws.influxdb.pwd=root | 13 | aws.influxdb.pwd=root |
1 | #---------jdbc config---------- | 1 | #---------jdbc config---------- |
2 | -local.jdbc.url=jdbc:mysql://172.16.6.234:3306/yh_ops?characterEncoding=utf-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull | ||
3 | -local.jdbc.user=root | 2 | +local.jdbc.url=jdbc:mysql://localhost:3306/yh_ops?characterEncoding=utf-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull |
3 | +local.jdbc.user=ops | ||
4 | local.jdbc.password=123456 | 4 | local.jdbc.password=123456 |
5 | #---------jdbc config---------- | 5 | #---------jdbc config---------- |
@@ -13,17 +13,9 @@ | @@ -13,17 +13,9 @@ | ||
13 | <!-- 日志最大的文件大小 10MB--> | 13 | <!-- 日志最大的文件大小 10MB--> |
14 | <property name="maxFileSize" value="10MB"/> | 14 | <property name="maxFileSize" value="10MB"/> |
15 | 15 | ||
16 | - <!-- ConsoleAppender 控制台输出日志 --> | ||
17 | - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
18 | - <!-- 对日志进行格式化 --> | ||
19 | - <encoder> | ||
20 | - <pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger -%msg%n</pattern> | ||
21 | - </encoder> | ||
22 | - </appender> | ||
23 | - | ||
24 | <!-- WARN级别日志 appender --> | 16 | <!-- WARN级别日志 appender --> |
25 | <appender name="WARN" class="ch.qos.logback.core.rolling.RollingFileAppender"> | 17 | <appender name="WARN" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
26 | - <file>${catalina.home}/logs/warn-log</file> | 18 | + <file>/Data/tomcat_logs/monitor/warn-log</file> |
27 | <!-- 过滤器,过滤掉 TRACE 和 DEBUG 和 INFO 级别的日志 --> | 19 | <!-- 过滤器,过滤掉 TRACE 和 DEBUG 和 INFO 级别的日志 --> |
28 | <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> | 20 | <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
29 | <level>WARN</level> | 21 | <level>WARN</level> |
@@ -44,7 +36,7 @@ | @@ -44,7 +36,7 @@ | ||
44 | 36 | ||
45 | <!-- DEBUG级别日志 appender --> | 37 | <!-- DEBUG级别日志 appender --> |
46 | <appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender"> | 38 | <appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
47 | - <file>${catalina.home}/logs/debug-log</file> | 39 | + <file>/Data/tomcat_logs/monitor/debug-log</file> |
48 | <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> | 40 | <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
49 | <level>INFO</level> | 41 | <level>INFO</level> |
50 | </filter> | 42 | </filter> |
1 | +# ******************** send sms common configs ******************** | ||
2 | +sendsms.url=http://www.ztsms.cn/sendSms.do | ||
3 | +sendsms.username=youhuo | ||
4 | +sendsms.pwd=I8vX4MtK | ||
5 | +sendsms.notice.productid=333333 | ||
6 | + | ||
7 | +base_mobile=15905144483,18751986615,18652008443 | ||
8 | + | ||
9 | +#------------------------------------------支付回调手机号------------------------------------------------ | ||
10 | +sendsms.alarm.paycallback=15905144483,18751986615,18652008443 | ||
11 | +#------------------------------------------支付回调手机号------------------------------------------------ | ||
12 | + | ||
13 | +#------------------------------------------订单异常手机号------------------------------------------------ | ||
14 | +sendsms.alarm.mobile.orderexception=15905144483,13585196262,18652008443 | ||
15 | +#------------------------------------------订单异常手机号------------------------------------------------ | ||
16 | + | ||
17 | +#------------------------------------------用户行为异常手机号------------------------------------------------ | ||
18 | +sendsms.alarm.mobile.userbehaviour=15905144483,18001582955 | ||
19 | +#------------------------------------------用户行为异常手机号------------------------------------------------ | ||
20 | + | ||
21 | +#------------------------------------------数据库异常手机号------------------------------------------------ | ||
22 | +sendsms.alarm.mobile.dbexception=15905144483,18652008443,18751986615,13811102093 | ||
23 | +#------------------------------------------数据库异常手机号------------------------------------------------ | ||
24 | + | ||
25 | +#-------------------------------------------服务异常告警手机号---------------------------------------------------- | ||
26 | + | ||
27 | +sendsms.alarm.mobile.serviceexception.product=15905144483,18652925653,13451938602,18751986615,18652008443 | ||
28 | +sendsms.alarm.mobile.serviceexception.search=15905144483,18551640215,18652925653,18751986615,18652008443 | ||
29 | +sendsms.alarm.mobile.serviceexception.guang=15905144483,18001582955,18652925653,18751986615,18652008443,18551607734,15651035157,13951882433 | ||
30 | +sendsms.alarm.mobile.serviceexception.users=15905144483,18001582955,18652925653,18751986615,18652008443,13951882433,15651035157,18551607734 | ||
31 | +sendsms.alarm.mobile.serviceexception.order=15905144483,15950561359,13951634768,18652925653,18751986615,18652008443 | ||
32 | +sendsms.alarm.mobile.serviceexception.sns=15905144483,13451938602,18652925653,18751986615,18652008443 | ||
33 | +sendsms.alarm.mobile.serviceexception.promotion=15905144483,18652925653,13451938602,18751986615,18652008443 | ||
34 | +sendsms.alarm.mobile.serviceexception.message=15905144483,18001582955,18652925653,18751986615,18652008443 | ||
35 | +sendsms.alarm.mobile.serviceexception.resources=15905144483,15950561359,18652925653,18751986615,18652008443 | ||
36 | + | ||
37 | +#-------------服务异常告警手机号------------------- | ||
38 | + | ||
39 | +#---------------------Monitor异常数据告警手机号------------------ | ||
40 | +sendsms.alarm.mobile.monitor.exception=15905144483,18751986615 | ||
41 | +#---------------------Monitor异常数据告警手机号------------------ | ||
42 | + | ||
43 | +#-----------------------------Logs告警模块--------------------------- | ||
44 | +#短信发送失败量超过阀值 告警手机号 | ||
45 | +sendsms.alarm.mobile.logs.sns_send_failed=15905144483,18751986615,18652008443,18001582955 | ||
46 | +#-----------------------------Logs告警模块-------------------------- | ||
47 | + | ||
48 | +#-----------------------------监控系统开发人员-------------------------- | ||
49 | +sendsms.alarm.mobile.ops_manager.developer=13914772123,15150551036 | ||
50 | +#-----------------------------监控系统开发人员-------------------------- | ||
51 | + | ||
52 | +dnspod.mobile=15905144483,18652008443,18751986615 | ||
53 | + | ||
54 | +jmxtrans.mobile=15905144483,18751986615 | ||
55 | + | ||
56 | +nginx.config.switch.mobile=15905144483,18652008443,18751986615 | ||
57 | +#订单校验失败 | ||
58 | +orderinfocheck.mobile=15905144483,18652008443,15950561359,13902496867,18511020499 | ||
59 | + |
-
Please register or login to post a comment