Authored by qinchao

docker monitor

... ... @@ -7,6 +7,7 @@ import com.util.GetUsersInfoUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
... ... @@ -38,11 +39,18 @@ public class ResourcesSimplePiceAlarm {
@Resource(name = "javaapiRestTemplate")
private RestTemplate restTemplate;
//当前环境
@Value("${system.envi}")
private String env;
/**
* 3分钟监控一次
*/
@Scheduled(cron = "0 2/3 * * * ?")
public void alarm() {
if("test1".equals(env)){
return ;
}
//发送拦截短信
String mobile_user = "13770338135";//耿超的电话//getUsersInfoUtil.getMobileByAlarmGroup(AlarmGroupContants.GROUP_NAME_USER_LOGIN);
try {
... ...
... ... @@ -9,6 +9,7 @@ import com.monitor.mysql.mapper.DockerMonitorServiceMapper;
import com.monitor.other.worksystem.dock.qq.DockerServerDeployService;
import com.util.GetUsersInfoUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
... ... @@ -42,6 +43,10 @@ public class DockerMonitorTask {
@Autowired
GetUsersInfoUtil getUsersInfoUtil;
//当前环境
@Value("${system.envi}")
private String env;
private Map<String,String> map=new ConcurrentHashMap<>();
private Map<String, Long> msgSentLogMap = new HashMap<>();
private String mobile;
... ... @@ -56,6 +61,10 @@ public class DockerMonitorTask {
@Scheduled(cron = "${cron_task_docker_pod_scan}")
public void monitor() {
if("test1".equals(env)){
return ;
}
synchronized (LOCK.intern()) {
List<DockerMonitorServiceModel> serviceModels = dockerMonitorServiceMapper.selectAllMonitor();
for(DockerMonitorServiceModel model:serviceModels){
... ...