Authored by fanzelei

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