Authored by mlge

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

package com.monitor.common.contants;
public class AlarmSystemConstant {
public static final String SYSTEM_IDC="yohops_aws";
public static final String SYSTEM_IDC="yohops_aws_docker";
}
... ...
... ... @@ -30,7 +30,7 @@ public class MysqlMonitorTask {
@Autowired
MysqlMonitorServiceImpl mysqlMonitorService;
@Scheduled(cron = "${cron_task_mysql_monit}")
//@Scheduled(cron = "${cron_task_mysql_monit}")
public void monitor() {
synchronized (lockStr.intern()) {
List<MysqlMobjectRep> mysqlMobjectReps= mobjectService.getMysqlMobject();
... ...
... ... @@ -70,6 +70,9 @@ public class NodePm2Task {
logger.info("cron_task_node_mem for ip {} ,name {} ",ip,pythonEnv.getName());
String result = httpRestClientService.doGet("http://" + ip + ":9615", null);
if(result==null){
continue;
}
JSONObject resultJSONObject = JSON.parseObject(result);
JSONObject monit = resultJSONObject.getJSONObject("monit");
long freeMem = monit.getLongValue("free_mem")/(1024 * 1024);
... ...
... ... @@ -7,16 +7,18 @@ JavaApiExecutorPoolMaxSize=50
nginxsync.agent=172.31.16.167:6060
#zookeeper.address=yoho-ops-zookeeper:2181
zookeeper.address=172.31.50.139:2181
zookeeper.address=yoho-ops-zookeeper:2181
#zookeeper.address=172.31.50.139:2181
aws.redis.proxy.address=172.31.31.170
#aws.redis.proxy.address=yoho-ops-redis
zkAddress=yoho-ops-zookeeper:2181
#zkAddress=172.31.50.139:2181
#aws.redis.proxy.address=172.31.31.170
aws.redis.proxy.address=yoho-ops-redis
aws.redis.proxy.port=6379
aws.redis.proxy.auth=
#zkAddress=yoho-ops-zookeeper:2181
zkAddress=172.31.50.139:2181
search.aws.url=http://internal-search-1492740248.cn-north-1.elb.amazonaws.com.cn/
search.qq.url=http://10.66.4.30/
... ...
datasources:
yh_ops:
servers:
- 172.31.50.75:3306
- 172.31.50.75:3306
- 10.66.233.13:3306
- 10.66.233.13:3306
username: ops
password: t5/oMgwUCmO/GeMHBAQ2Cg==
password: eDSKt8NPhLIswOCsMW3kfA==
maxConnections: 50
minIdle: 10
maxIdle: 50
... ...
#---------jdbc config----------
local.jdbc.url=jdbc:mysql://172.31.50.75: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
... ...
... ... @@ -12,4 +12,4 @@ java_service_alarm_flag=true
java_service_alarm_cost_threshold=300
java_service_alarm_count_threshold=50
SWITCH_DB_URL=http://172.31.56.59:8011/switchdb/switchMysql
\ No newline at end of file
SWITCH_DB_URL=http://10.66.4.28:8011/switchdb/switchMysql
\ No newline at end of file
... ...
#---------jdbc config----------
local.jdbc.url=jdbc:mysql://10.66.0.191:3308/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
... ...
#---------jdbc config----------
local.jdbc.url=jdbc:mysql://127.0.0.1:3306/yh_ops?characterEncoding=utf-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull
local.jdbc.user=root
local.jdbc.password=123456
#---------jdbc config----------
\ No newline at end of file
... ...
package com.monitor;
import com.model.JavaApiInfo;
import com.monitor.cmdb.service.IJavaApiInfoService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.List;
/**
* Created by fruwei on 2016/6/17.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
"classpath*:META-INF/spring/spring*.xml"})
@PropertySource({"classpath:jdbc.properties",
"classpath:*.properties"})
public class JavaApiDBTest {
Logger logger = LoggerFactory.getLogger("test");
@Autowired
IJavaApiInfoService javaApiInfoService;
@Test
public void testAdd() {
JavaApiInfo javaApiInfo = new JavaApiInfo();
javaApiInfo.setApiName("test");
javaApiInfo.setServiceType(1);
javaApiInfo.setApiUrl("1111111");
javaApiInfoService.saveJavaApiInfo(javaApiInfo);
}
@Test
public void testQuery() {
List<JavaApiInfo> list = javaApiInfoService.queryJavaApiInfo();
for (JavaApiInfo javaApiInfo : list) {
logger.info(javaApiInfo.getApiName());
}
}
@Test
public void testDel() {
}
@Test
public void testUpdate() {
javaApiInfoService.delJavaApiInfo(1);
}
}
package com.monitor;
import com.alibaba.fastjson.JSON;
import com.monitor.influxdb.mapper.impl.JavaApiStaticsMapper;
import com.monitor.javaserver.common.JavaApiStatics;
import com.monitor.model.domain.JavaApiStaticsModel;
import com.monitor.model.request.JavaApiStatusReq;
import com.monitor.model.response.JavaApiStatusRep;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by fruwei on 2016/6/22.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
"classpath*:META-INF/spring/spring*.xml"})
@PropertySource({"classpath:jdbc.properties",
"classpath:*.properties"})
public class JavaApiInfluxDBTest {
Logger logger = LoggerFactory.getLogger("test");
@Autowired
JavaApiStaticsMapper javaApiStaticsMapper;
@Test
public void testQuery() {
JavaApiStatusReq param = new JavaApiStatusReq();
param.setServiceId(21);
param.setServiceId(43);
JavaApiStaticsModel rel = javaApiStaticsMapper.selectlatestJavaApiStatics(null, param);
logger.info(rel.toString());
}
@Test
public void testBatchQuery() {
List<JavaApiStatusReq> listParam = new ArrayList<>();
for (int i = 0; i < 30; i++) {
JavaApiStatusReq param1 = new JavaApiStatusReq();
param1.setServiceId(19);
param1.setMObjectId(24);
listParam.add(param1);
}
long start = System.currentTimeMillis();
logger.info("############################################start...");
List<JavaApiStaticsModel> rel = javaApiStaticsMapper.selectlatestJavaApiStaticsList(null, listParam);
long end = System.currentTimeMillis();
logger.info("###########################################end... cost : {}", (end - start));
logger.info("############################################rel: {}", JSON.toJSON(rel));
logger.info(rel.toString());
}
}
package com.monitor;
import com.monitor.common.config.SnsMobileConfig;
import com.monitor.common.service.AlarmMsgService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Created by fruwei on 2016/6/22.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
"classpath*:META-INF/spring/spring*.xml"})
@PropertySource({"classpath:jdbc.properties",
"classpath:*.properties"})
public class MessageTest {
@Autowired
public AlarmMsgService alarmMsgService;
@Autowired
private SnsMobileConfig snsMobileConfig;
@Test
public void testSendMsg(){
alarmMsgService.sendSms("java_api","test", snsMobileConfig.getBaseMobile());
}
}