Authored by qinchao

mysql监控

... ... @@ -164,7 +164,7 @@ public class MObjectInfoServiceImpl implements IMObjectInfoService {
mysqlMobject.setCloudType("aws");
mysqlMobject.setMoHostIp(mo.getMoHostIp());
mysqlMobject.setMoTags(mo.getMoTags());
mysqlMobject.setMasterFlag("0");
if(mo.getMoTags()!=null&&mo.getMoTags().indexOf(",")>0){
mysqlMobject.setIpAndPort(mo.getMoHostIp()+":"+mo.getMoTags().split(",")[0]);
}else{
... ... @@ -173,6 +173,7 @@ public class MObjectInfoServiceImpl implements IMObjectInfoService {
if(mo.getMoTags()!=null&&mo.getMoTags().toUpperCase().indexOf("MASTER")>=0){
mysqlMobject.setMasterFlag("1");
master_mysqlMobjectList.add(mysqlMobject);
}else{
slave_mysqlMobjectList.add(mysqlMobject);
... ... @@ -192,7 +193,7 @@ public class MObjectInfoServiceImpl implements IMObjectInfoService {
mysqlMobject.setCloudType("qcloud");
mysqlMobject.setMoHostIp(mo.getMoHostIp());
mysqlMobject.setMoTags(mo.getMoTags());
mysqlMobject.setMasterFlag("0");
if(mo.getMoTags()!=null&&mo.getMoTags().indexOf(",")>0){
mysqlMobject.setIpAndPort(mo.getMoHostIp()+":"+mo.getMoTags().split(",")[0]);
}else{
... ... @@ -200,6 +201,7 @@ public class MObjectInfoServiceImpl implements IMObjectInfoService {
}
if(mo.getMoTags()!=null&&mo.getMoTags().toUpperCase().indexOf("MASTER")>=0){
mysqlMobject.setMasterFlag("1");
master_mysqlMobjectList.add(mysqlMobject);
}else{
slave_mysqlMobjectList.add(mysqlMobject);
... ...
... ... @@ -6,42 +6,58 @@ import java.util.Map;
@Data
public class MysqlMetric {
private String second_behind_master;
//当前总连接数
private String total_connect;
//本地连接数
private String inner_connect;
// 当前服务器运行了多长时间
private String uptime;
private String status;
//进程端口状态 0:dead 1:alive
private String port_status;
// 每秒查询数量
private String qps;
private String bytes_sent;
private String slave_host_count;
private String tps;
// 发送给所有客户端的字节数
private String bytes_sent;
// 活动线程(active threads)的数量
private String threads;
//从所有客户端接收到的字节数
private String bytes_received;
//等待的时间,因为日志缓冲区太小
private String innodb_log_waits;
// 外部连接数
private String db_connect;
//当前等待的待锁定的行数
private String innodb_row_lock_waits;
private String tps;
//从库数量
private String slave_host_count;
//显示I/O线程是否被启动并成功地连接到主服务器上,成功为Yes,否则为No。
private String slave_io_running;
//显示I/O线程是否被启动并成功地连接到主服务器上,成功为Yes,否则为No。
private String slave_sql_running;
//表示主从之间延迟的时间,单位是秒
private String second_behind_master;
public void changeFromInfluxQueryResultMap(Map<String, String> map){
if(map==null){
return ;
}
this.setSecond_behind_master(map.get("mysql.second_behind_master"));
this.setTotal_connect(map.get("mysql.total_connect"));
this.setInner_connect(map.get("mysql.inner_connect"));
this.setUptime(map.get("mysql.uptime"));
this.setStatus(map.get("mysql.status"));
this.setPort_status(map.get("mysql.port.status"));
this.setQps(map.get("mysql.qps"));
this.setTps(map.get("mysql.tps"));
this.setBytes_sent(map.get("mysql.Bytes_sent"));
this.setSlave_host_count(map.get("mysql.slave_host.count"));
this.setThreads(map.get("mysql.threads"));
this.setBytes_received(map.get("mysql.Bytes_received"));
this.setInnodb_log_waits(map.get("mysql.Innodb_log_waits"));
this.setDb_connect(map.get("mysql.db_connect"));
this.setInnodb_row_lock_waits(map.get("mysql.Innodb_row_lock_waits"));
this.setTps(map.get("mysql.tps"));
this.setSlave_host_count(map.get("mysql.slave_host.count"));
this.setSlave_io_running(map.get("mysql.slave_io_running"));
this.setSlave_sql_running(map.get("mysql.slave_sql_running"));
this.setSecond_behind_master(map.get("mysql.second_behind_master"));
}
}
... ...
... ... @@ -9,6 +9,7 @@ public class MysqlMobjectRep {
private String moHostIp;
private String moTags;
private String ipAndPort;
private String masterFlag;
private String connectStatus;
... ...