From 0c568d25bc7fcd87df43e5b02f7dd12eda31ab4c Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Sat, 13 Nov 2021 22:36:22 +0800 Subject: [PATCH] =?UTF-8?q?[monitor]=20=E8=AE=BE=E8=AE=A1=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=AE=9A=E4=B9=89=E5=8F=82=E6=95=B0=E5=80=BC=E8=A1=A8?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E5=8F=8A=E7=9B=B8=E5=BA=94=E5=AE=9E=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/usthe/common/entity/job/Job.java | 4 +- .../com/usthe/manager/pojo/entity/Param.java | 62 +++++++++++++ .../manager/pojo/entity/ParamDefine.java | 91 +++++++++++++++++++ manager/src/main/resources/db/schema.sql | 33 ++++--- 4 files changed, 173 insertions(+), 17 deletions(-) create mode 100644 manager/src/main/java/com/usthe/manager/pojo/entity/Param.java create mode 100644 manager/src/main/java/com/usthe/manager/pojo/entity/ParamDefine.java diff --git a/common/src/main/java/com/usthe/common/entity/job/Job.java b/common/src/main/java/com/usthe/common/entity/job/Job.java index 666e99b..c9723b3 100644 --- a/common/src/main/java/com/usthe/common/entity/job/Job.java +++ b/common/src/main/java/com/usthe/common/entity/job/Job.java @@ -38,7 +38,7 @@ public class Job { /** * 监控ID 应用ID */ - private long appId; + private long monitorId; /** * 监控的类型 eg: linux | mysql | jvm */ @@ -143,7 +143,7 @@ public class Job { } if (!metricsSet.remove(metrics)) { log.error("Job {} appId {} app {} metrics {} remove empty error in priorMetrics.", - id, appId, app, metrics.getName()); + id, monitorId, app, metrics.getName()); } if (metricsSet.isEmpty()) { priorMetrics.remove(0); diff --git a/manager/src/main/java/com/usthe/manager/pojo/entity/Param.java b/manager/src/main/java/com/usthe/manager/pojo/entity/Param.java new file mode 100644 index 0000000..c7dcc1c --- /dev/null +++ b/manager/src/main/java/com/usthe/manager/pojo/entity/Param.java @@ -0,0 +1,62 @@ +package com.usthe.manager.pojo.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import java.time.LocalDateTime; + +/** + * 监控参数值 + * @author tomsun28 + * @date 2021/11/13 22:19 + */ +@Entity +@Table(name = "param") +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class Param { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + /** + * 监控ID + */ + private Long monitorId; + + /** + * 参数字段标识符 + */ + private String field; + + /** + * 参数值 + */ + private String value; + + /** + * 参数类型 0:数字 1:字符串 2:加密串 + */ + private byte type; + + /** + * 记录创建时间 + */ + private LocalDateTime gmtCreate; + + /** + * 记录最新修改时间 + */ + private LocalDateTime gmtUpdate; + +} diff --git a/manager/src/main/java/com/usthe/manager/pojo/entity/ParamDefine.java b/manager/src/main/java/com/usthe/manager/pojo/entity/ParamDefine.java new file mode 100644 index 0000000..614e95d --- /dev/null +++ b/manager/src/main/java/com/usthe/manager/pojo/entity/ParamDefine.java @@ -0,0 +1,91 @@ +package com.usthe.manager.pojo.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import java.time.LocalDateTime; + +/** + * 监控参数定义 + * @author tomsun28 + * @date 2021/11/13 21:49 + */ +@Entity +@Table(name = "param_define") +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ParamDefine { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + /** + * 监控应用类型名称 + */ + private String app; + + /** + * 参数字段对外显示名称 + */ + private String name; + + /** + * 参数字段标识符 + */ + private String field; + + /** + * 字段类型,样式(大部分映射input标签type属性) + */ + private String type; + + /** + * 当type为number时,用range表示范围 eg: 0-233 + */ + @Column(name = "param_range") + private String range; + + /** + * 当type为text时,用limit表示字符串限制大小.最大255 + */ + @Column(name = "param_limit") + private short limit; + + /** + * 当type为radio单选框,checkbox复选框时,option表示可选项值列表 + * eg: param3,param4,param5 + */ + @Column(name = "param_option") + private String option; + + /** + * 此条记录创建者 + */ + private String creator; + + /** + * 此条记录最新修改者 + */ + private String modifier; + + /** + * 记录创建时间 + */ + private LocalDateTime gmtCreate; + + /** + * 记录最新修改时间 + */ + private LocalDateTime gmtUpdate; +} diff --git a/manager/src/main/resources/db/schema.sql b/manager/src/main/resources/db/schema.sql index 8be0e5f..b90f07f 100644 --- a/manager/src/main/resources/db/schema.sql +++ b/manager/src/main/resources/db/schema.sql @@ -12,8 +12,8 @@ CREATE TABLE monitor app varchar(100) not null comment '监控的类型:linux,mysql,jvm...', host varchar(100) not null comment '监控的对端host:ipv4,ipv6,域名', intervals int not null default 600 comment '监控的采集间隔时间,单位秒', - status smallint(4) not null default 1 comment '监控状态 0:未监控,1:可用,2:不可用,3:不可达,4:挂起', - description varchar(255) comment '监控描述信息', + status tinyint not null default 1 comment '监控状态 0:未监控,1:可用,2:不可用,3:不可达,4:挂起', + description varchar(255) comment '描述备注信息', creator varchar(100) comment '创建者', modifier varchar(100) comment '最新修改者', gmt_create timestamp default current_timestamp comment 'create time', @@ -29,10 +29,9 @@ CREATE TABLE param ( id bigint not null auto_increment comment '参数ID', monitor_id bigint not null comment '监控ID', - param_name varchar(100) not null comment '参数显示名称', - param_key varchar(100) not null comment '参数标识符', - param_value varchar(255) not null comment '参数值', - param_type smallint(4) not null default 0 comment '参数类型 0:数字 1:字符串 2:加密串', + field varchar(100) not null comment '参数标识符', + value varchar(255) not null comment '参数值,最大字符长度255', + type tinyint not null default 0 comment '参数类型 0:数字 1:字符串 2:加密串', gmt_create timestamp default current_timestamp comment 'create time', gmt_update datetime default current_timestamp on update current_timestamp comment 'update time', primary key (id), @@ -45,14 +44,18 @@ CREATE TABLE param DROP TABLE IF EXISTS param_define ; CREATE TABLE param_define ( - id bigint not null auto_increment comment '参数ID', - monitor_id bigint not null comment '监控ID', - param_name varchar(100) not null comment '参数显示名称', - param_key varchar(100) not null comment '参数标识符', - param_value varchar(255) not null comment '参数值', - param_type smallint(4) not null default 0 comment '参数类型 0:数字 1:字符串 2:加密串', - gmt_create timestamp default current_timestamp comment 'create time', - gmt_update datetime default current_timestamp on update current_timestamp comment 'update time', + id bigint not null auto_increment comment '参数ID', + app varchar(100) not null comment '监控的类型:linux,mysql,jvm...', + name varchar(100) not null comment '参数字段对外显示名称', + field varchar(100) not null comment '参数字段标识符', + type varchar(20) not null default 'text' comment '字段类型,样式(大部分映射input标签type属性)', + param_range varchar(100) not null comment '当type为number时,用range表示范围 eg: 0-233', + param_limit tinyint unsigned not null comment '当type为text时,用limit表示字符串限制大小.最大255', + param_option varchar(255) not null comment '当type为radio单选框,checkbox复选框时,option表示可选项值列表', + creator varchar(100) comment '创建者', + modifier varchar(100) comment '最新修改者', + gmt_create timestamp default current_timestamp comment 'create time', + gmt_update datetime default current_timestamp on update current_timestamp comment 'update time', primary key (id), - index monitor_id (monitor_id) + index app_index (app) ) ENGINE = InnoDB DEFAULT CHARSET=utf8mb4; \ No newline at end of file