Authored by simba

update

@@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSONObject; @@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSONObject;
4 import com.model.MObjectInfo; 4 import com.model.MObjectInfo;
5 import com.model.RedisMonitor; 5 import com.model.RedisMonitor;
6 import com.model.TypeInfo; 6 import com.model.TypeInfo;
  7 +import com.monitor.common.config.SnsMobileConfig;
  8 +import com.monitor.common.service.AlarmMsgService;
7 import com.monitor.common.util.HttpRestClient; 9 import com.monitor.common.util.HttpRestClient;
8 import com.monitor.common.util.RedisCommonUtil; 10 import com.monitor.common.util.RedisCommonUtil;
9 import com.monitor.common.util.TelnetUtils; 11 import com.monitor.common.util.TelnetUtils;
@@ -43,6 +45,12 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService @@ -43,6 +45,12 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService
43 45
44 @Autowired 46 @Autowired
45 RedisMonitorMapper redisMonitorMapper; 47 RedisMonitorMapper redisMonitorMapper;
  48 +
  49 + @Autowired
  50 + public AlarmMsgService alarmMsgService;
  51 +
  52 + @Autowired
  53 + private SnsMobileConfig snsMobileConfig;
46 54
47 @Override 55 @Override
48 public void redisMonitor() { 56 public void redisMonitor() {
@@ -199,6 +207,7 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService @@ -199,6 +207,7 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService
199 if(flag){ 207 if(flag){
200 msg="OK"; 208 msg="OK";
201 }else{ 209 }else{
  210 + slaveAramCount++;
202 msg="ERROR"; 211 msg="ERROR";
203 } 212 }
204 redisInfoList.add(new RedisMonitor(ipConfig[0]+":"+ipConfig[1],result.get("master_host").toString()+":"+result.get("master_port").toString(),2,isFailed,1,Integer.valueOf(ipConfig[2]),msg)); 213 redisInfoList.add(new RedisMonitor(ipConfig[0]+":"+ipConfig[1],result.get("master_host").toString()+":"+result.get("master_port").toString(),2,isFailed,1,Integer.valueOf(ipConfig[2]),msg));
@@ -218,5 +227,26 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService @@ -218,5 +227,26 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService
218 redisMonitorMapper.deleteAllRedisMonitor(); 227 redisMonitorMapper.deleteAllRedisMonitor();
219 redisMonitorMapper.bachInsertRedisMonitor(redisInfoList); 228 redisMonitorMapper.bachInsertRedisMonitor(redisInfoList);
220 } 229 }
  230 +
  231 +
  232 + /**********************************************************************
  233 + *4、告警
  234 + ***********************************************************************/
  235 + StringBuffer alrarmMsg=new StringBuffer("");
  236 + if(twemproxyAlarmCount>0){
  237 + alrarmMsg.append("twemproxy:"+twemproxyAlarmCount+"台连接失败;");
  238 + }
  239 +
  240 + if(redisAlarmCount>0){
  241 + alrarmMsg.append("redis:"+redisAlarmCount+"台连接失败;");
  242 + }
  243 +
  244 + if(slaveAramCount>0){
  245 + alrarmMsg.append("redis主从:"+redisAlarmCount+"台连接失败;请及时查看!");
  246 + }
  247 +
  248 + if(StringUtils.isNotBlank(alrarmMsg.toString())){
  249 + alarmMsgService.sendSms("zookeeper", alarmMsgService.toString(), snsMobileConfig.getBaseMobile());
  250 + }
221 } 251 }
222 } 252 }