Authored by fanzelei

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

@@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.*; @@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.*;
25 25
26 import java.util.ArrayList; 26 import java.util.ArrayList;
27 import java.util.List; 27 import java.util.List;
  28 +import java.util.Random;
28 29
29 /** 30 /**
30 * Created by yoho on 2016/6/15. 31 * Created by yoho on 2016/6/15.
@@ -36,6 +37,8 @@ public class MObjectInfoCtrl { @@ -36,6 +37,8 @@ public class MObjectInfoCtrl {
36 37
37 public static final String SPLITOP = ","; 38 public static final String SPLITOP = ",";
38 39
  40 + public static final String AWS_PREFIX = "172.";
  41 +
39 @Autowired 42 @Autowired
40 IMObjectInfoService mobjectService; 43 IMObjectInfoService mobjectService;
41 44
@@ -55,15 +58,13 @@ public class MObjectInfoCtrl { @@ -55,15 +58,13 @@ public class MObjectInfoCtrl {
55 58
56 BaseResponse response = null; 59 BaseResponse response = null;
57 60
58 - if (0 == request.getIsGroup()) {  
59 - response = queryMHostInfoByIp(request);  
60 - } else {  
61 response = queryMHostInfoByGroup(request); 61 response = queryMHostInfoByGroup(request);
62 - } 62 +
63 return response; 63 return response;
64 } 64 }
65 65
66 - private BaseResponse queryMHostInfoByIp(MObjectHostInfoReq request) { 66 +
  67 + private BaseResponse queryMHostInfoByGroup(MObjectHostInfoReq request) {
67 BaseResponse response = new BaseResponse(); 68 BaseResponse response = new BaseResponse();
68 69
69 MObjectHostInfoModel model = new MObjectHostInfoModel(); 70 MObjectHostInfoModel model = new MObjectHostInfoModel();
@@ -74,97 +75,42 @@ public class MObjectInfoCtrl { @@ -74,97 +75,42 @@ public class MObjectInfoCtrl {
74 75
75 String selectIp = ""; 76 String selectIp = "";
76 77
77 - String selectGroup = "";  
78 -  
79 - int selectGroupId = 0; 78 + String selectTag = "";
80 79
81 List<HostGroup> sourceGroupList = groupService.getListGroups(); 80 List<HostGroup> sourceGroupList = groupService.getListGroups();
82 81
83 - if (!StringUtils.equals("0", request.getSelectIp())) {  
84 - HostInfo info = hostInfoService.getHostInfoByHostIp(request.getSelectIp());  
85 -  
86 - selectIp = info.getHostIp(); 82 + //add blank tag
87 83
88 - selectGroupId = info.getGroupId(); 84 + HostGroup hostGroup = new HostGroup();
89 85
90 - selectGroup = groupService.getHostGroupById(selectGroupId).getData().getGroupName(); 86 + hostGroup.setGroupName(StringUtils.EMPTY);
91 87
  88 + sourceGroupList.add(hostGroup);
92 89
93 - } else {  
94 - if (sourceGroupList.size() > 0) {  
95 - selectGroup = sourceGroupList.get(0).getGroupName();  
96 -  
97 - selectGroupId = sourceGroupList.get(0).getId();  
98 -  
99 - List<HostInfo> sourceHostList = hostInfoService.getHostInfosByTag("");  
100 -  
101 - if (sourceHostList.size() > 0) {  
102 - selectIp = sourceHostList.get(0).getHostIp();  
103 - }  
104 - }  
105 - } 90 + selectTag = request.getSelectGroup();
106 91
107 for (HostGroup group : sourceGroupList) { 92 for (HostGroup group : sourceGroupList) {
108 groupList.add(group.getGroupName()); 93 groupList.add(group.getGroupName());
109 } 94 }
110 95
111 - if (StringUtils.isNotBlank(selectGroup)) {  
112 - for (HostInfo info : hostInfoService.getHostInfosByTag("")) {  
113 - ipList.add(info.getHostIp());  
114 - }  
115 - }  
116 -  
117 - model.setSelectIp(selectIp);  
118 - model.setSelectGroup(selectGroup);  
119 - model.setIpList(ipList);  
120 - model.setGroupList(groupList);  
121 -  
122 - response.setData(model);  
123 -  
124 - return response;  
125 - }  
126 -  
127 -  
128 - private BaseResponse queryMHostInfoByGroup(MObjectHostInfoReq request) {  
129 - BaseResponse response = new BaseResponse();  
130 -  
131 - MObjectHostInfoModel model = new MObjectHostInfoModel();  
132 -  
133 - List<String> groupList = new ArrayList<>();  
134 -  
135 - List<String> ipList = new ArrayList<>(); 96 + List<HostInfo> hostInfos = hostInfoService.getHostInfosByTag(selectTag);
136 97
137 - String selectIp = "";  
138 -  
139 - String selectGroup = "";  
140 -  
141 - int selectGroupId = 0;  
142 -  
143 - List<HostGroup> sourceGroupList = groupService.getListGroups();  
144 -  
145 - for (HostGroup group : sourceGroupList) {  
146 - if (StringUtils.equals(group.getGroupName(), request.getSelectGroup())) {  
147 - selectGroupId = group.getId();  
148 - selectGroup = group.getGroupName();  
149 - }  
150 - }  
151 -  
152 - for (HostGroup group : sourceGroupList) {  
153 - groupList.add(group.getGroupName());  
154 - }  
155 -  
156 - if (StringUtils.isNotBlank(selectGroup)) {  
157 - for (HostInfo info : hostInfoService.getHostInfosByTag("")) { 98 + for (HostInfo info : hostInfos) {
158 ipList.add(info.getHostIp()); 99 ipList.add(info.getHostIp());
159 } 100 }
160 - }  
161 101
162 selectIp = ipList.get(0); 102 selectIp = ipList.get(0);
  103 +
163 model.setSelectIp(selectIp); 104 model.setSelectIp(selectIp);
164 - model.setSelectGroup(selectGroup); 105 +
  106 + model.setSelectGroup(selectTag);
  107 +
165 model.setIpList(ipList); 108 model.setIpList(ipList);
  109 +
166 model.setGroupList(groupList); 110 model.setGroupList(groupList);
  111 +
167 response.setData(model); 112 response.setData(model);
  113 +
168 return response; 114 return response;
169 } 115 }
170 116
@@ -336,6 +282,8 @@ public class MObjectInfoCtrl { @@ -336,6 +282,8 @@ public class MObjectInfoCtrl {
336 282
337 BeanUtils.copyProperties(request, info); 283 BeanUtils.copyProperties(request, info);
338 284
  285 + info.setMoName(buildMoName(request));
  286 +
339 mobjectService.addMObjectInfo(info); 287 mobjectService.addMObjectInfo(info);
340 } 288 }
341 } catch (Exception e) { 289 } catch (Exception e) {
@@ -351,6 +299,32 @@ public class MObjectInfoCtrl { @@ -351,6 +299,32 @@ public class MObjectInfoCtrl {
351 299
352 } 300 }
353 301
  302 +
  303 + public String buildMoName(MObjectInfoReq infoReq) {
  304 + String name = infoReq.getMoTypeName();
  305 +
  306 + Random random = new Random();
  307 +
  308 + if (infoReq.getMoHostIp().startsWith(AWS_PREFIX)) {
  309 + name = name.concat("_aws_");
  310 + } else {
  311 + name = name.concat("_qq_");
  312 + }
  313 +
  314 + String tmpName = String.copyValueOf(name.toCharArray());
  315 +
  316 + tmpName = tmpName.concat(Integer.toString(random.nextInt(100)));
  317 +
  318 + while (mobjectService.checkMoNameExist(tmpName)) {
  319 +
  320 + tmpName = String.copyValueOf(name.toCharArray());
  321 +
  322 + tmpName = tmpName.concat(Integer.toString(random.nextInt(100)));
  323 + }
  324 +
  325 + return tmpName;
  326 + }
  327 +
354 @RequestMapping(value = "/delete", method = RequestMethod.POST) 328 @RequestMapping(value = "/delete", method = RequestMethod.POST)
355 public BaseResponse deleteMObject(@RequestBody MObjectInfoReq request) { 329 public BaseResponse deleteMObject(@RequestBody MObjectInfoReq request) {
356 330
@@ -23,7 +23,7 @@ public interface IMObjectInfoService { @@ -23,7 +23,7 @@ public interface IMObjectInfoService {
23 23
24 void updateMObjectInfo(MObjectInfo info); 24 void updateMObjectInfo(MObjectInfo info);
25 25
26 - 26 + boolean checkMoNameExist(String name);
27 27
28 List<MObjectInfo> queryMObjectsInfoByTypes(List<Integer> typeIds); 28 List<MObjectInfo> queryMObjectsInfoByTypes(List<Integer> typeIds);
29 29
@@ -105,6 +105,17 @@ public class MObjectInfoServiceImpl implements IMObjectInfoService { @@ -105,6 +105,17 @@ public class MObjectInfoServiceImpl implements IMObjectInfoService {
105 } 105 }
106 106
107 @Override 107 @Override
  108 + public boolean checkMoNameExist(String name) {
  109 + List<MObjectInfo> mObjectInfoList = mObjectInfoMapper.getMoInfosByAlias(name);
  110 +
  111 + if (0 != mObjectInfoList.size()) {
  112 + return true;
  113 + } else {
  114 + return false;
  115 + }
  116 + }
  117 +
  118 + @Override
108 public List<MObjectInfo> queryMObjectsInfoByTypes(List<Integer> typeIds) { 119 public List<MObjectInfo> queryMObjectsInfoByTypes(List<Integer> typeIds) {
109 return mObjectInfoMapper.selectMObjectsInfoByTypes(typeIds); 120 return mObjectInfoMapper.selectMObjectsInfoByTypes(typeIds);
110 } 121 }
@@ -9,195 +9,9 @@ import org.springframework.stereotype.Component; @@ -9,195 +9,9 @@ import org.springframework.stereotype.Component;
9 @Component("snsMobileConfig") 9 @Component("snsMobileConfig")
10 public class SnsMobileConfig { 10 public class SnsMobileConfig {
11 11
12 - /********************** 支付回调手机号 **********************/  
13 -  
14 - @Value("${sendsms.alarm.paycallback}")  
15 - private String payCallBack;  
16 -  
17 - /********************** 支付回调手机号 ********************/  
18 -  
19 - /********************* 订单异常手机号 ***********************/  
20 -  
21 - @Value("${sendsms.alarm.mobile.orderexception}")  
22 - private String orderException;  
23 -  
24 - /********************* 订单异常手机号 ***********************/  
25 -  
26 - /******************* 用户行为异常手机号 ***************/  
27 -  
28 - @Value("${sendsms.alarm.mobile.userbehaviour}")  
29 - private String userBehaviour;  
30 -  
31 - /******************** 用户行为异常手机号 **************/  
32 -  
33 - /******************** 数据库异常手机号 *************/  
34 - @Value("${sendsms.alarm.mobile.dbexception}")  
35 - private String dbException;  
36 -  
37 - /******************* 数据库异常手机号 **************/  
38 -  
39 - /****************** 服务异常告警手机号 ***************/  
40 - @Value("${sendsms.alarm.mobile.serviceexception.product}")  
41 - private String serviceExcptnProduct;  
42 -  
43 - @Value("${sendsms.alarm.mobile.serviceexception.search}")  
44 - private String serviceExcptnSearch;  
45 -  
46 - @Value("${sendsms.alarm.mobile.serviceexception.guang}")  
47 - private String serviceExcptnGuang;  
48 -  
49 - @Value("${sendsms.alarm.mobile.serviceexception.users}")  
50 - private String serviceExcptnUsers;  
51 -  
52 - @Value("${sendsms.alarm.mobile.serviceexception.order}")  
53 - private String serviceExcptnOrder;  
54 -  
55 - @Value("${sendsms.alarm.mobile.serviceexception.sns}")  
56 - private String serviceExcptnSns;  
57 -  
58 - @Value("${sendsms.alarm.mobile.serviceexception.promotion}")  
59 - private String serviceExcptnPromotion;  
60 -  
61 - @Value("${sendsms.alarm.mobile.serviceexception.message}")  
62 - private String serviceExcptnMessage;  
63 -  
64 - @Value("${sendsms.alarm.mobile.serviceexception.resources}")  
65 - private String serviceExcptnResources;  
66 -  
67 - /******************** 服务异常告警手机号 ******************/  
68 -  
69 - /********************Monitor模块告警手机号************************/  
70 - @Value("${sendsms.alarm.mobile.monitor.exception}")  
71 - private String monitorException;  
72 - /********************Monitor模块告警手机号************************/  
73 -  
74 - /*******************Logs模块告警手机号************************/  
75 - @Value("${sendsms.alarm.mobile.logs.sns_send_failed}")  
76 - private String logsSnsSendFailed;  
77 - /*******************Logs模块告警手机号************************/  
78 -  
79 - /*********************OpsManager开发程序员 手机号***************************/  
80 - @Value("${sendsms.alarm.mobile.ops_manager.developer}")  
81 - private String opsManagerDeveloper;  
82 - /*********************OpsManager开发程序员 手机号***************************/  
83 -  
84 -  
85 - /**  
86 - * dnspod sms  
87 - */  
88 - @Value("${dnspod.mobile}")  
89 - private String dnspodMobile;  
90 -  
91 - /**  
92 - * switch nginxConfig sms  
93 - */  
94 - @Value("${nginx.config.switch.mobile}")  
95 - private String switchNginxConfigMobile;  
96 -  
97 - /**  
98 - * jmxtrans sms  
99 - */  
100 - @Value("${jmxtrans.mobile}")  
101 - private String jmxtransMobile;  
102 -  
103 - @Value("${orderinfocheck.mobile}")  
104 - private String orderinfocheckMobile;  
105 -  
106 @Value("${base_mobile}") 12 @Value("${base_mobile}")
107 private String baseMobile; 13 private String baseMobile;
108 14
109 - public String getOrderinfocheckMobile() {  
110 - return orderinfocheckMobile;  
111 - }  
112 -  
113 - public String getPayCallBack() {  
114 - return payCallBack;  
115 - }  
116 -  
117 - public String getOrderException() {  
118 - return orderException;  
119 - }  
120 -  
121 - public String getUserBehaviour() {  
122 - return userBehaviour;  
123 - }  
124 -  
125 - public String getDbException() {  
126 - return dbException;  
127 - }  
128 -  
129 - public String getServiceExcptnProduct() {  
130 - return serviceExcptnProduct;  
131 - }  
132 -  
133 - public String getServiceExcptnSearch() {  
134 - return serviceExcptnSearch;  
135 - }  
136 -  
137 - public String getServiceExcptnGuang() {  
138 - return serviceExcptnGuang;  
139 - }  
140 -  
141 - public String getServiceExcptnUsers() {  
142 - return serviceExcptnUsers;  
143 - }  
144 -  
145 - public String getServiceExcptnOrder() {  
146 - return serviceExcptnOrder;  
147 - }  
148 -  
149 - public String getServiceExcptnSns() {  
150 - return serviceExcptnSns;  
151 - }  
152 -  
153 - public String getServiceExcptnPromotion() {  
154 - return serviceExcptnPromotion;  
155 - }  
156 -  
157 - public String getServiceExcptnMessage() {  
158 - return serviceExcptnMessage;  
159 - }  
160 -  
161 - public String getServiceExcptnResources() {  
162 - return serviceExcptnResources;  
163 - }  
164 -  
165 - public String getDnspodMobile() {  
166 - return dnspodMobile;  
167 - }  
168 -  
169 - public void setDnspodMobile(String dnspodMobile) {  
170 - this.dnspodMobile = dnspodMobile;  
171 - }  
172 -  
173 - public String getJmxtransMobile() {  
174 - return jmxtransMobile;  
175 - }  
176 -  
177 - public void setJmxtransMobile(String jmxtransMobile) {  
178 - this.jmxtransMobile = jmxtransMobile;  
179 - }  
180 -  
181 - public String getSwitchNginxConfigMobile() {  
182 - return switchNginxConfigMobile;  
183 - }  
184 -  
185 - public void setSwitchNginxConfigMobile(String switchNginxConfigMobile) {  
186 - this.switchNginxConfigMobile = switchNginxConfigMobile;  
187 - }  
188 -  
189 - public String getOpsManagerDeveloper() {  
190 - return opsManagerDeveloper;  
191 - }  
192 -  
193 - public String getMonitorException() {  
194 - return monitorException;  
195 - }  
196 -  
197 - public String getLogsSnsSendFailed() {  
198 - return logsSnsSendFailed;  
199 - }  
200 -  
201 public String getBaseMobile() { 15 public String getBaseMobile() {
202 return baseMobile; 16 return baseMobile;
203 } 17 }
@@ -94,7 +94,7 @@ public class AlarmMsgServiceImpl implements AlarmMsgService { @@ -94,7 +94,7 @@ public class AlarmMsgServiceImpl implements AlarmMsgService {
94 if (result == null || !("01" .equals(result.split(",")[0]) || "00" .equals(result.split(",")[0]) || "03" .equals(result.split(",")[0]))) { 94 if (result == null || !("01" .equals(result.split(",")[0]) || "00" .equals(result.split(",")[0]) || "03" .equals(result.split(",")[0]))) {
95 logger.error("发送短信失败,短信内容|" + JSONArray.toJSONString(smsMap)); 95 logger.error("发送短信失败,短信内容|" + JSONArray.toJSONString(smsMap));
96 smsMap.put("Content", URLEncoder.encode("【有货运维】发送短信告警失败!!!", "UTF-8")); 96 smsMap.put("Content", URLEncoder.encode("【有货运维】发送短信告警失败!!!", "UTF-8"));
97 - smsMap.put("DesMobile", snsMobileConfig.getOpsManagerDeveloper()); 97 + smsMap.put("DesMobile", snsMobileConfig.getBaseMobile());
98 // 短信发送失败 发送短信给开发回来改bug 98 // 短信发送失败 发送短信给开发回来改bug
99 httpRestClientService.get(sendsmsConfig.getSendsmsUrl(), smsMap, String.class); 99 httpRestClientService.get(sendsmsConfig.getSendsmsUrl(), smsMap, String.class);
100 return false; 100 return false;
@@ -11,6 +11,28 @@ import java.util.Map; @@ -11,6 +11,28 @@ import java.util.Map;
11 11
12 public class RedisCommonUtil { 12 public class RedisCommonUtil {
13 13
  14 + public static long getRedisMaxMemory(String host,int port){
  15 + Map<String,Object> result=null;
  16 + Jedis client =null;
  17 + try {
  18 + client=new Jedis(host, port);
  19 + result=new HashMap<String, Object>();
  20 + List<String> configList=client.configGet("maxmemory");
  21 + long maxmemory=0;
  22 + if(!CollectionUtils.isEmpty(configList)&&configList.size()==2){
  23 + maxmemory=Long.valueOf(configList.get(1));
  24 + }
  25 + return maxmemory;
  26 + }catch (Exception e){
  27 + return 0;
  28 + }finally {
  29 + if(client!=null){
  30 + client.close();
  31 + }
  32 + }
  33 + }
  34 +
  35 +
14 public static Map<String,Object> getRedisInfo(String host,int port){ 36 public static Map<String,Object> getRedisInfo(String host,int port){
15 Map<String,Object> result=null; 37 Map<String,Object> result=null;
16 Jedis client =null; 38 Jedis client =null;
@@ -21,12 +43,6 @@ public class RedisCommonUtil { @@ -21,12 +43,6 @@ public class RedisCommonUtil {
21 return null; 43 return null;
22 } 44 }
23 result=new HashMap<String, Object>(); 45 result=new HashMap<String, Object>();
24 - List<String> configList=client.configGet("maxmemory");  
25 - int maxmemory=0;  
26 - if(!CollectionUtils.isEmpty(configList)&&configList.size()==2){  
27 - maxmemory=Integer.valueOf(configList.get(1));  
28 - }  
29 - result.put("maxmemory",maxmemory);  
30 String[] arr = redisInfo.split("\r\n"); 46 String[] arr = redisInfo.split("\r\n");
31 for (String str : arr) { 47 for (String str : arr) {
32 if (str.startsWith("#")||str.startsWith("\r\n")) { 48 if (str.startsWith("#")||str.startsWith("\r\n")) {
@@ -44,6 +44,8 @@ public class NginxScanTask { @@ -44,6 +44,8 @@ public class NginxScanTask {
44 } 44 }
45 } 45 }
46 46
  47 + InterVar.moMaps.clear();
  48 +
47 for (MObjectInfo info : mObjectInfoList) { 49 for (MObjectInfo info : mObjectInfoList) {
48 50
49 InterVar.moMaps.put(info.getMoId(), info); 51 InterVar.moMaps.put(info.getMoId(), info);
@@ -18,7 +18,7 @@ public class AlarmMsgComp { @@ -18,7 +18,7 @@ public class AlarmMsgComp {
18 SnsMobileConfig snsMobileConfig; 18 SnsMobileConfig snsMobileConfig;
19 19
20 public void doAlarm(String subject, String content) { 20 public void doAlarm(String subject, String content) {
21 - alarmMsgService.sendSms(subject, content, snsMobileConfig.getOpsManagerDeveloper()); 21 + alarmMsgService.sendSms(subject, content, snsMobileConfig.getBaseMobile());
22 } 22 }
23 23
24 } 24 }
@@ -96,19 +96,17 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService @@ -96,19 +96,17 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService
96 List<String> ipList=null; 96 List<String> ipList=null;
97 for(MObjectInfo obj:redisProxymList){ 97 for(MObjectInfo obj:redisProxymList){
98 paramMonitor=new StringBuffer(); 98 paramMonitor=new StringBuffer();
99 - String[] ports=null;  
100 - if(StringUtils.isBlank(obj.getMoTags())){  
101 - ports=obj.getMoTags().split(",");  
102 - } 99 + String[] ports=obj.getMoTags().split(",");;
  100 + log.info("two port is {}",obj.getMoTags());
103 String result= TelnetUtils.getResult(obj.getMoHostIp(),Integer.valueOf(ports[0])); 101 String result= TelnetUtils.getResult(obj.getMoHostIp(),Integer.valueOf(ports[0]));
104 redisMonitor = new RedisMonitor(); 102 redisMonitor = new RedisMonitor();
105 if(StringUtils.isNotBlank(result)){ 103 if(StringUtils.isNotBlank(result)){
106 paramMonitor.append("1,"); 104 paramMonitor.append("1,");
107 boolean proxyFlag=RedisCommonUtil.getRedisIsSlave(obj.getMoHostIp(),Integer.valueOf(ports[1])); 105 boolean proxyFlag=RedisCommonUtil.getRedisIsSlave(obj.getMoHostIp(),Integer.valueOf(ports[1]));
108 if(proxyFlag){ 106 if(proxyFlag){
109 - paramMonitor.append("OK,"); 107 + paramMonitor.append("探测成功;");
110 }else{ 108 }else{
111 - paramMonitor.append("ERROR,"); 109 + paramMonitor.append("探测失败;");
112 } 110 }
113 //取舍成功重新设为1 111 //取舍成功重新设为1
114 JSONObject response=JSONObject.parseObject(result); 112 JSONObject response=JSONObject.parseObject(result);
@@ -117,10 +115,10 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService @@ -117,10 +115,10 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService
117 int curr_connections=(Integer)response.get("curr_connections"); 115 int curr_connections=(Integer)response.get("curr_connections");
118 if(total_connections>0){ 116 if(total_connections>0){
119 //总连接数 117 //总连接数
120 - paramMonitor.append(total_connections+","); 118 + paramMonitor.append("总连接数:"+total_connections+";");
121 } 119 }
122 if (total_connections > 0) { 120 if (total_connections > 0) {
123 - paramMonitor.append(curr_connections+","); 121 + paramMonitor.append("当前连接数:"+curr_connections+";");
124 } 122 }
125 //查看代理下的redis 123 //查看代理下的redis
126 JSONObject alpha=response.getJSONObject("alpha"); 124 JSONObject alpha=response.getJSONObject("alpha");
@@ -131,7 +129,7 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService @@ -131,7 +129,7 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService
131 ipList.add(key+":"+obj.getMoTypeId()); 129 ipList.add(key+":"+obj.getMoTypeId());
132 } 130 }
133 } 131 }
134 - tMap.put(obj.getMoHostIp()+":"+obj.getMoTags(),ipList); 132 + tMap.put(obj.getMoHostIp()+":"+ports[1],ipList);
135 redisMonitor.setIsFailed(1); 133 redisMonitor.setIsFailed(1);
136 redisMonitor.setParamMonitor(paramMonitor.toString()); 134 redisMonitor.setParamMonitor(paramMonitor.toString());
137 } 135 }
@@ -141,7 +139,7 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService @@ -141,7 +139,7 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService
141 redisMonitor.setParamMonitor("0,"); 139 redisMonitor.setParamMonitor("0,");
142 } 140 }
143 redisMonitor.setNodeFrom(redisTweproxyMap.get(obj.getMoTypeId())); 141 redisMonitor.setNodeFrom(redisTweproxyMap.get(obj.getMoTypeId()));
144 - redisMonitor.setNodeTo(obj.getMoHostIp()+":"+obj.getMoTags()); 142 + redisMonitor.setNodeTo(obj.getMoHostIp()+":"+ports[1]);
145 redisMonitor.setLevel(1); 143 redisMonitor.setLevel(1);
146 redisMonitor.setRedisType(obj.getMoTypeId()); 144 redisMonitor.setRedisType(obj.getMoTypeId());
147 redisInfoList.add(redisMonitor); 145 redisInfoList.add(redisMonitor);
@@ -172,16 +170,22 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService @@ -172,16 +170,22 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService
172 paramMonitor.append("0,"); 170 paramMonitor.append("0,");
173 }else{ 171 }else{
174 isFailed=1; 172 isFailed=1;
  173 + paramMonitor.append("1,");
175 String role=(String)result.get("role"); 174 String role=(String)result.get("role");
176 paramMonitor.append(role+","); 175 paramMonitor.append(role+",");
177 try { 176 try {
178 - BigDecimal maxmemory=BigDecimal.valueOf(Long.valueOf(result.get("maxmemory").toString())); 177 + long maxmemory=RedisCommonUtil.getRedisMaxMemory(ipConfig[0], Integer.valueOf(ipConfig[1]));
  178 + if(maxmemory==0){
  179 + paramMonitor.append("最大内存为0");
  180 + }else{
179 BigDecimal byteDang=BigDecimal.valueOf(Long.valueOf(1024*1024)); 181 BigDecimal byteDang=BigDecimal.valueOf(Long.valueOf(1024*1024));
180 - BigDecimal maxMemoryMb = maxmemory.divide(byteDang,2,4); 182 + BigDecimal maxMemoryMb = BigDecimal.valueOf(maxmemory).divide(byteDang,2,4);
181 paramMonitor.append(maxMemoryMb+"M,"); 183 paramMonitor.append(maxMemoryMb+"M,");
  184 +
182 BigDecimal used_memory=BigDecimal.valueOf(Long.valueOf(result.get("used_memory").toString())); 185 BigDecimal used_memory=BigDecimal.valueOf(Long.valueOf(result.get("used_memory").toString()));
183 - BigDecimal useProportion = used_memory.divide(maxmemory,2,4);  
184 - paramMonitor.append(useProportion+"%,"); 186 + BigDecimal useProportion = used_memory.divide(BigDecimal.valueOf(maxmemory),2,4);
  187 + paramMonitor.append(useProportion.multiply(new BigDecimal(100))+"%,");
  188 + }
185 }catch (Exception e){ 189 }catch (Exception e){
186 log.error("计算Redis使用率错误",e); 190 log.error("计算Redis使用率错误",e);
187 paramMonitor.append("0.00%,"); 191 paramMonitor.append("0.00%,");
@@ -13,7 +13,7 @@ public class RedisMonitorTask { @@ -13,7 +13,7 @@ public class RedisMonitorTask {
13 private IRedisMonitorHandleService redisMonitorService; 13 private IRedisMonitorHandleService redisMonitorService;
14 14
15 //@Scheduled(fixedRate=20000) 15 //@Scheduled(fixedRate=20000)
16 - @Scheduled(cron="0 0/5 * * * ? ") 16 + @Scheduled(cron="0 0/3 * * * ? ")
17 public void redisMonitor(){ 17 public void redisMonitor(){
18 redisMonitorService.redisMonitor(); 18 redisMonitorService.redisMonitor();
19 } 19 }
@@ -80,7 +80,7 @@ public class ZkMonitorHandleServiceImpl implements IZkMonitorHandleService { @@ -80,7 +80,7 @@ public class ZkMonitorHandleServiceImpl implements IZkMonitorHandleService {
80 return; 80 return;
81 } 81 }
82 String alarmMsg="zookeeper"+alarmList.size()+"台连接失败,请及时查看!"; 82 String alarmMsg="zookeeper"+alarmList.size()+"台连接失败,请及时查看!";
83 - alarmMsgService.sendSms("zookeeper",alarmMsg, snsMobileConfig.getOpsManagerDeveloper()); 83 + alarmMsgService.sendSms("zookeeper",alarmMsg, snsMobileConfig.getBaseMobile());
84 log.info("task end..."); 84 log.info("task end...");
85 } 85 }
86 86
1 package com.monitor.model.request; 1 package com.monitor.model.request;
2 2
3 import lombok.Data; 3 import lombok.Data;
  4 +import org.apache.commons.lang.StringUtils;
4 5
5 /** 6 /**
6 * Created by yoho on 2016/6/20. 7 * Created by yoho on 2016/6/20.
@@ -9,7 +10,7 @@ import lombok.Data; @@ -9,7 +10,7 @@ import lombok.Data;
9 public class MObjectHostInfoReq { 10 public class MObjectHostInfoReq {
10 String selectIp; 11 String selectIp;
11 12
12 - String selectGroup; 13 + String selectGroup = StringUtils.EMPTY;
13 14
14 int isGroup = 0; 15 int isGroup = 0;
15 } 16 }
@@ -4,59 +4,7 @@ sendsms.username=yohoyw @@ -4,59 +4,7 @@ sendsms.username=yohoyw
4 sendsms.pwd=NCftHmJ9 4 sendsms.pwd=NCftHmJ9
5 sendsms.notice.productid=8 5 sendsms.notice.productid=8
6 6
7 -base_mobile=15905144483,18751986615,18652008443 7 +base_mobile=15905144483,18751986615,18502542319
8 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=15905144483  
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 -  
60 -nginx.error.mobile=15905144483,18502542319,18751986615  
61 9
62 10
@@ -4,65 +4,7 @@ sendsms.username=yoho @@ -4,65 +4,7 @@ sendsms.username=yoho
4 sendsms.pwd=E 4 sendsms.pwd=E
5 sendsms.notice.productid=8 5 sendsms.notice.productid=8
6 6
7 -#---------------国都短信业务api参数----------------------  
8 -sendsms.guodu.Url=http://221.179.180.158:9007/QxtSms/QxtFirewall  
9 -sendsms.guodu.OperID=yoho  
10 -sendsms.guodu.OperPass=EMKVpwoJ  
11 -#---------------国都短信业务api参数---------------------- 7 +base_mobile=15905144483
12 8
13 -base_mobile=15905144483,18751986615,18652008443  
14 -  
15 -#------------------------------------------支付回调手机号------------------------------------------------  
16 -sendsms.alarm.paycallback=15905144483,18751986615,18652008443  
17 -#------------------------------------------支付回调手机号------------------------------------------------  
18 -  
19 -#------------------------------------------订单异常手机号------------------------------------------------  
20 -sendsms.alarm.mobile.orderexception=15905144483,13585196262,18652008443  
21 -#------------------------------------------订单异常手机号------------------------------------------------  
22 -  
23 -#------------------------------------------用户行为异常手机号------------------------------------------------  
24 -sendsms.alarm.mobile.userbehaviour=15905144483,18001582955  
25 -#------------------------------------------用户行为异常手机号------------------------------------------------  
26 -  
27 -#------------------------------------------数据库异常手机号------------------------------------------------  
28 -sendsms.alarm.mobile.dbexception=15905144483,18652008443,18751986615,13811102093  
29 -#------------------------------------------数据库异常手机号------------------------------------------------  
30 -  
31 -#-------------------------------------------服务异常告警手机号----------------------------------------------------  
32 -  
33 -sendsms.alarm.mobile.serviceexception.product=15905144483,18652925653,13451938602,18751986615,18652008443  
34 -sendsms.alarm.mobile.serviceexception.search=15905144483,18551640215,18652925653,18751986615,18652008443  
35 -sendsms.alarm.mobile.serviceexception.guang=15905144483,18001582955,18652925653,18751986615,18652008443,18551607734,15651035157,13951882433  
36 -sendsms.alarm.mobile.serviceexception.users=15905144483,18001582955,18652925653,18751986615,18652008443,13951882433,15651035157,18551607734  
37 -sendsms.alarm.mobile.serviceexception.order=15905144483,15950561359,13951634768,18652925653,18751986615,18652008443  
38 -sendsms.alarm.mobile.serviceexception.sns=15905144483,13451938602,18652925653,18751986615,18652008443  
39 -sendsms.alarm.mobile.serviceexception.promotion=15905144483,18652925653,13451938602,18751986615,18652008443  
40 -sendsms.alarm.mobile.serviceexception.message=15905144483,18001582955,18652925653,18751986615,18652008443  
41 -sendsms.alarm.mobile.serviceexception.resources=15905144483,15950561359,18652925653,18751986615,18652008443  
42 -  
43 -#-------------服务异常告警手机号-------------------  
44 -  
45 -#---------------------Monitor异常数据告警手机号------------------  
46 -sendsms.alarm.mobile.monitor.exception=15905144483,18751986615  
47 -#---------------------Monitor异常数据告警手机号------------------  
48 -  
49 -#-----------------------------Logs告警模块---------------------------  
50 -#短信发送失败量超过阀值 告警手机号  
51 -sendsms.alarm.mobile.logs.sns_send_failed=15905144483,18751986615,18652008443,18001582955  
52 -#-----------------------------Logs告警模块--------------------------  
53 -  
54 -#-----------------------------监控系统开发人员--------------------------  
55 -sendsms.alarm.mobile.ops_manager.developer=15905144483  
56 -#-----------------------------监控系统开发人员--------------------------  
57 -  
58 -dnspod.mobile=15905144483,18652008443,18751986615  
59 -  
60 -jmxtrans.mobile=15905144483,18751986615  
61 -  
62 -nginx.config.switch.mobile=15905144483,18652008443,18751986615  
63 -#订单校验失败  
64 -orderinfocheck.mobile=15905144483,18652008443,15950561359,13902496867,18511020499  
65 -  
66 -nginx.error.mobile=15905144483,18502542319,18751986615  
67 9
68 10
@@ -27,7 +27,7 @@ public class MessageTest { @@ -27,7 +27,7 @@ public class MessageTest {
27 @Test 27 @Test
28 public void testSendMsg(){ 28 public void testSendMsg(){
29 29
30 - alarmMsgService.sendSms("java_api","test", snsMobileConfig.getOpsManagerDeveloper()); 30 + alarmMsgService.sendSms("java_api","test", snsMobileConfig.getBaseMobile());
31 31
32 } 32 }
33 } 33 }