Authored by zhengyouwei

project

... ... @@ -28,6 +28,7 @@ public class InfluxDBContants {
public static final String MONITOR_SYSTEM = "monitor_system";
public static final String JAVA_PROJECT="java_project";
/**
* influxdb 表
... ... @@ -40,6 +41,7 @@ public class InfluxDBContants {
public static final String USER_OPERATE= "user_operate";
public static final String JAVA_PROJECT_STATUS="java_project_status";
}
\ No newline at end of file
... ...
package com.monitor.influxdb.mapper;
import com.monitor.influxdb.model.ZkInfo;
import com.monitor.model.domain.JavaProjectStatus;
import com.monitor.model.domain.PageBean;
import java.util.List;
/**
* Created by yoho on 2016/6/21.
*/
public interface JavaProjectMapper {
void insert(JavaProjectStatus javaProjectStatus);
}
... ...
package com.monitor.influxdb.mapper.impl;
import com.monitor.influxdb.InfluxDBQuery;
import com.monitor.influxdb.InluxDBSingle;
import com.monitor.influxdb.contants.InfluxDBContants;
import com.monitor.influxdb.mapper.JavaProjectMapper;
import com.monitor.model.domain.JavaProjectStatus;
import org.influxdb.dto.Point;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Random;
import java.util.concurrent.TimeUnit;
/**
* Created by yoho on 2016/6/21.
*/
public class JavaProjectMapperImpl extends InfluxDBQuery implements JavaProjectMapper {
Logger log = LoggerFactory.getLogger(JavaProjectMapperImpl.class);
@Autowired
private InluxDBSingle inluxDBSingle;
Random random = new Random();
@Override
public void insert(JavaProjectStatus javaProjectStatus) {
Point point = Point.measurement(InfluxDBContants.JAVA_PROJECT_STATUS)
.tag("name", javaProjectStatus.getName())
.tag("ip", javaProjectStatus.getIp())
.tag("status", javaProjectStatus.getStatus())
.addField("lastStart",javaProjectStatus.getLastStart() == null? "1":javaProjectStatus.getLastStart())
.time(System.currentTimeMillis() * 1000000 + random.nextInt(999999), TimeUnit.NANOSECONDS)
.build();
inluxDBSingle.getInfluxDBByName(InfluxDBContants.AWS).getInfluxDB()
.write(InfluxDBContants.MONITOR_SYSTEM, "default", point);
}
}
... ...
package com.monitor.model.domain;
import lombok.Data;
/**
* Created by zhengyouwei on 2016/10/17.
*/
@Data
public class JavaProjectStatus {
private String name;
private String ip;
private String status;
private String lastStart;
}
... ...
package com.monitor.other.projectRestart.common;
/**
* Created by zhengyouwei on 2016/6/29.
*/
public class Project {
private String order;//顺序
private String name;
private String projectid;
private String group;
public Project(){
}
public Project(String order, String name, String projectid, String group){
this.order = order;
this.name = name;
this.projectid = projectid;
this.group = group;
}
public String getOrder() {
return order;
}
public void setOrder(String order) {
this.order = order;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getProjectid() {
return projectid;
}
public void setProjectid(String projectid) {
this.projectid = projectid;
}
public String getGroup() {
return group;
}
public void setGroup(String group) {
this.group = group;
}
}
... ...
package com.monitor.other.projectRestart.common;
import java.util.ArrayList;
import java.util.List;
public class ProjectOnline {
private static List<Project> JAVA_LIST = new ArrayList<Project>();
static{
JAVA_LIST.add(new Project("1","yoho-sns","125","yoho30"));
JAVA_LIST.add(new Project("1","yoho-message","123","yoho30"));
JAVA_LIST.add(new Project("1","uic","439","yoho30"));
JAVA_LIST.add(new Project("1","yoho-users","134","yoho30"));
JAVA_LIST.add(new Project("1","yohobuy-resources","122","yoho30"));
JAVA_LIST.add(new Project("1","yohobuy-promotion","140","yoho30"));
JAVA_LIST.add(new Project("1","yohobuy-product","143","yoho30"));
JAVA_LIST.add(new Project("1","yohobuy-order","124","yoho30"));
JAVA_LIST.add(new Project("1","yoho-push","137","yoho30"));
JAVA_LIST.add(new Project("1","cms_push","514","yoho30"));
JAVA_LIST.add(new Project("1","mars_push","494","yoho30"));
JAVA_LIST.add(new Project("1","yohobuy-shops","490","yoho30"));
JAVA_LIST.add(new Project("1","yoho-social","353","yoho30"));
JAVA_LIST.add(new Project("1","yohobuy-union","133","yoho30"));
JAVA_LIST.add(new Project("1","yohobuy-activity","129","yoho30"));
JAVA_LIST.add(new Project("1","yohobuy-crm","275","yoho30"));
JAVA_LIST.add(new Project("1","yohobuy-task","138","yoho30"));
JAVA_LIST.add(new Project("1","yohobuy-wechat","248","yoho30"));
JAVA_LIST.add(new Project("1","yohobuy-brower","131","yoho30"));
JAVA_LIST.add(new Project("1","yohobuy-bigdata","144","yoho30"));
JAVA_LIST.add(new Project("1","yoho-gateway","126","yoho30"));
JAVA_LIST.add(new Project("2","yoho-search-service","12","yoho-search"));
JAVA_LIST.add(new Project("2","yoho-search-consumer","8","yoho-search"));
JAVA_LIST.add(new Project("2","yoho-search-producer","7","yoho-search"));
JAVA_LIST.add(new Project("2","yohomars-search-service","554","yoho-search"));
JAVA_LIST.add(new Project("2","yoho-search-adaptor","13","yoho-search"));
JAVA_LIST.add(new Project("3","yohobuy-platform","110","platform"));
}
public static List<Project> getJavaList() {
return JAVA_LIST;
}
}
... ...
package com.monitor.other.projectRestart.task;
import com.monitor.other.projectRestart.common.Project;
import com.monitor.other.projectRestart.common.ProjectOnline;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/**
* Created by zhengyouwei on 2016/10/17.
*/
public class ProjectStatusTask {
private static Logger logger = LoggerFactory.getLogger(ProjectStatusTask.class);
@Scheduled(cron = "${cron_task_project_status}")
public void check(){
for (Project project :ProjectOnline.getJavaList()){
String name = project.getName();
String commond = "ssh master@10.66.4.25 /home/master/.java_pm/java_restart.sh checkstatus mix " + name;
List<String> list = exe(commond);
}
}
public List<String> exe(String commond) {
Process process;
List<String> list = new ArrayList<>();
BufferedReader input = null;
try {
process = Runtime.getRuntime().exec(commond);
input = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = "";
while ((line = input.readLine()) != null) {
list.add(line);
}
} catch (Exception e) {
logger.error("process exe failed!", e);
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
logger.error("process exe failed!", e);
}
}
}
return list;
}
}
... ...
... ... @@ -99,6 +99,7 @@ public class UserCtrl {
try {
Mail.Builder builder = new Mail.Builder("YOHO!运维平台密码");
builder.receiver(user.getEmail());
builder.message("您的用户名:" + user.getName());
builder.message("您的密码:" + user.getPwd());
mailService.sendHTMLMail(builder.build());
String pwd = MD5Util.encryption(user.getPwd());
... ... @@ -129,6 +130,7 @@ public class UserCtrl {
try {
Mail.Builder builder = new Mail.Builder("YOHO!运维平台密码");
builder.receiver(user.getEmail());
builder.message("您的用户名:" + user.getName());
builder.message("您的密码:" + user.getPwd());
mailService.sendHTMLMail(builder.build());
String pwd = MD5Util.encryption(user.getPwd());
... ...
... ... @@ -12,3 +12,6 @@ cron_task_rabbit_scan=0 0/1 * * * ?
cron_task_dns_monit=0 1/5 * * * ?
cron_task_project_status=0 0/2 * * * ?
... ...
... ... @@ -17,4 +17,6 @@ cron_task_rabbit_monit=0 0 0 * * ?
cron_task_rabbit_scan=0 0 0 * * ?
#cron_task_dns_monit=0 0/1 * * * ?
cron_task_dns_monit=0 0 0 * * ?
\ No newline at end of file
cron_task_dns_monit=0 0 0 * * ?
cron_task_project_status=0 0 0 * * ?
... ...