Authored by simba

update

... ... @@ -53,14 +53,25 @@ public class RedisMonitorServiceImpl implements IRedisMonitorService {
width2+=8;
}
}else if(info.getLevel()==2){
buff.append("<set x=\""+width3+"\" y=\"55\" width=\"55\" height=\"40\" name=\""+info.getNodeTo() + "\" color=\""+color+"\" id=\""+info.getNodeTo()+"\" />\\n\\\n");
width3+=4;
if(info.getIsSlave()==0){
buff.append("<set x=\""+width3+"\" y=\"55\" width=\"55\" height=\"40\" name=\""+info.getNodeTo() + "\" color=\""+color+"\" id=\""+info.getNodeTo()+"\" />\\n\\\n");
width3+=4;
}
}
}
buff.append("</dataset>\\n\\\n");
buff.append("<connectors color=\"83C6E1\" stdThickness=\"8\">\\n\\\n");
for(RedisMonitor info : list){
buff.append("<connector strength=\"0.45\" from=\""+info.getNodeFrom()+"\" to=\""+info.getNodeTo()+"\" arrowAtStart=\"0\" arrowAtEnd=\"0\"/>\\n\\\n");
if(info.getIsSlave()==1) {
if(info.getIsFailed()==0){
buff.append("<connector strength=\"0.45\" color=\"FF0000\" from=\"" + info.getNodeFrom() + "\" to=\"" + info.getNodeTo()+"\" arrowAtStart=\"0\" arrowAtEnd=\"0\"/>\\n\\\n");
}else{
buff.append("<connector strength=\"0.45\" color=\"008000\" from=\"" + info.getNodeFrom() + "\" to=\"" + info.getNodeTo()+"\" arrowAtStart=\"0\" arrowAtEnd=\"0\"/>\\n\\\n");
}
}else{
buff.append("<connector strength=\"0.45\" from=\"" + info.getNodeFrom() + "\" to=\"" + info.getNodeTo()+"\" arrowAtStart=\"0\" arrowAtEnd=\"0\"/>\\n\\\n");
}
}
buff.append("</connectors>\\n\\\n</chart>'");
System.out.println(buff.toString());
... ...
... ... @@ -40,12 +40,15 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService
@Override
public void redisMonitor() {
int twemproxyAlarmCount=0;
int redisAlarmCount=0;
int slaveAramCount=0;
/**********************************************************************
*1、处理twemproxy
***********************************************************************/
List<RedisMonitor> redisInfoList=new ArrayList<RedisMonitor>();
redisInfoList.add(new RedisMonitor("AWS","AWS",0,1,null));
redisInfoList.add(new RedisMonitor("Qcloud","Qcloud",0,1,null));
redisInfoList.add(new RedisMonitor("AWS","AWS",0,1,0,null));
redisInfoList.add(new RedisMonitor("Qcloud","Qcloud",0,1,0,null));
RedisMonitor redisMonitor=null;
//List<MObjectInfo> mlist= mObjectInfoMapper.getMoInfosByAlias("com_twemproxy");
MObjectInfo a=new MObjectInfo();
... ... @@ -91,6 +94,7 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService
redisMonitor.setParamMonitor(paramMonitor.toString());
}
}else{
twemproxyAlarmCount++;
redisMonitor.setIsFailed(0);
redisMonitor.setParamMonitor("状态:宕机;");
}
... ... @@ -123,6 +127,7 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService
result= RedisInfoUtil.getRedisInfo(ipConfig[0], Integer.valueOf(ipConfig[1]));
paramMonitor=new StringBuffer();
if(null==result){
redisAlarmCount++;
paramMonitor.append("状态:宕机;");
}else{
isFailed=1;
... ... @@ -130,9 +135,13 @@ public class RedisMonitorHandleServiceImpl implements IRedisMonitorHandleService
paramMonitor.append("角色:"+role+";");
paramMonitor.append("用量:"+result.get("used_memory_rss")+";");
paramMonitor.append("内存碎片比率:" + result.get("mem_fragmentation_ratio") + ";");
// paramMonitor.append(":"+isSlave+";");
if("slave".equals(role)){
//TODO 探测主从
redisInfoList.add(new RedisMonitor(ipStr,result.get("master_host").toString()+":"+result.get("master_port").toString(),2,isFailed,1,null));
}
}
redisInfoList.add(new RedisMonitor(key,ipStr,2,isFailed,paramMonitor.toString()));
redisInfoList.add(new RedisMonitor(key,ipStr,2,isFailed,0,paramMonitor.toString()));
}
}
}
... ...
... ... @@ -12,7 +12,7 @@ public class RedisMonitorTask {
private IRedisMonitorHandleService redisMonitorService;
//@Scheduled(fixedRate=20000)
//@Scheduled(cron="0 0/15 * * * ? ")
//@Scheduled(cron="0 0/2* * * ? ")
public void redisMonitor(){
redisMonitorService.redisMonitor();
}
... ...
... ... @@ -79,7 +79,7 @@ public class ZkMonitorHandleServiceImpl implements IZkMonitorHandleService {
if(CollectionUtils.isEmpty(alarmList)){
return;
}
String alarmMsg="[有货监控]您好,zookeeper挂了"+alarmList.size()+"台,请及时查看!";
String alarmMsg="zookeeper"+alarmList.size()+"台连接失败,请及时查看!";
alarmMsgService.sendSms("zookeeper",alarmMsg, snsMobileConfig.getOpsManagerDeveloper());
log.info("task end...");
}
... ...
... ... @@ -14,6 +14,8 @@ public class RedisMonitor {
private int isFailed;
private int isSlave;
private String paramMonitor;
private String createTime;
... ... @@ -24,12 +26,13 @@ public class RedisMonitor {
super();
}
public RedisMonitor(String nodeFrom,String nodeTo,int level,int isFailed,String paramMonitor) {
public RedisMonitor(String nodeFrom,String nodeTo,int level,int isFailed,int isSlave,String paramMonitor) {
super();
this.nodeFrom = nodeFrom;
this.nodeTo = nodeTo;
this.level = level;
this.isFailed=isFailed;
this.isSlave=isSlave;
this.paramMonitor=paramMonitor;
}
... ...
... ... @@ -20,6 +20,7 @@
FROM type_info ORDER BY id asc
</select>
<!-- <select id="getChildTypesInfo" parameterType="int" resultType="com.model.TypeInfo" resultMap="typeInfoMap">
SELECT * FROM type_info WHERE type_parent_id = #{parentId}
</select>
... ...
... ... @@ -8,11 +8,12 @@
<result column="level" property="level" jdbcType="TINYINT" />
<result column="param_monitor" property="paramMonitor" jdbcType="VARCHAR" />
<result column="is_failed" property="isFailed" jdbcType="TINYINT" />
<result column="is_slave" property="isSlave" jdbcType="TINYINT" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, node_from, node_to, level,is_failed, param_monitor, create_time, update_time
id, node_from, node_to, level, param_monitor, is_failed, is_slave, create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
... ... @@ -26,11 +27,13 @@
</delete>
<insert id="insert" parameterType="com.model.RedisMonitor" >
insert into redis_monitor (id, node_from, node_to,
level,is_failed, param_monitor, create_time,
update_time)
level, param_monitor, is_failed,
is_slave, create_time, update_time
)
values (#{id,jdbcType=BIGINT}, #{nodeFrom,jdbcType=VARCHAR}, #{nodeTo,jdbcType=VARCHAR},
#{level,jdbcType=TINYINT},#{isFailed,jdbcType=TINYINT}, #{paramMonitor,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
#{level,jdbcType=TINYINT}, #{paramMonitor,jdbcType=VARCHAR}, #{isFailed,jdbcType=TINYINT},
#{isSlave,jdbcType=TINYINT}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.model.RedisMonitor" >
insert into redis_monitor
... ... @@ -47,11 +50,14 @@
<if test="level != null" >
level,
</if>
<if test="paramMonitor != null" >
param_monitor,
</if>
<if test="isFailed != null" >
is_failed,
</if>
<if test="paramMonitor != null" >
param_monitor,
<if test="isSlave != null" >
is_slave,
</if>
<if test="createTime != null" >
create_time,
... ... @@ -73,11 +79,14 @@
<if test="level != null" >
#{level,jdbcType=TINYINT},
</if>
<if test="paramMonitor != null" >
#{paramMonitor,jdbcType=VARCHAR},
</if>
<if test="isFailed != null" >
#{isFailed,jdbcType=TINYINT},
</if>
<if test="paramMonitor != null" >
#{paramMonitor,jdbcType=VARCHAR},
<if test="isSlave != null" >
#{isSlave,jdbcType=TINYINT},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
... ... @@ -99,11 +108,14 @@
<if test="level != null" >
level = #{level,jdbcType=TINYINT},
</if>
<if test="paramMonitor != null" >
param_monitor = #{paramMonitor,jdbcType=VARCHAR},
</if>
<if test="isFailed != null" >
is_failed = #{isFailed,jdbcType=TINYINT},
</if>
<if test="paramMonitor != null" >
param_monitor = #{paramMonitor,jdbcType=VARCHAR},
<if test="isSlave != null" >
is_slave = #{isSlave,jdbcType=TINYINT},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
... ... @@ -117,12 +129,13 @@
<update id="updateByPrimaryKey" parameterType="com.model.RedisMonitor" >
update redis_monitor
set node_from = #{nodeFrom,jdbcType=VARCHAR},
node_to = #{nodeTo,jdbcType=VARCHAR},
level = #{level,jdbcType=TINYINT},
is_failed = #{isFailed,jdbcType=TINYINT},
param_monitor = #{paramMonitor,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
node_to = #{nodeTo,jdbcType=VARCHAR},
level = #{level,jdbcType=TINYINT},
param_monitor = #{paramMonitor,jdbcType=VARCHAR},
is_failed = #{isFailed,jdbcType=TINYINT},
is_slave = #{isSlave,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
... ... @@ -132,11 +145,11 @@
<insert id="bachInsertRedisMonitor" parameterType="com.model.RedisMonitor">
insert into redis_monitor
(node_from, node_to,level,is_failed,param_monitor)
(node_from, node_to,level,is_failed,is_slave,param_monitor)
values
<foreach collection="list" item="item" index="index"
separator=",">
(#{item.nodeFrom},#{item.nodeTo},#{item.level},#{item.isFailed},#{item.paramMonitor})
(#{item.nodeFrom},#{item.nodeTo},#{item.level},#{item.isFailed},#{item.isSlave},#{item.paramMonitor})
</foreach>
</insert>
... ...