diff --git a/server/controller/cloud/cloud.go b/server/controller/cloud/cloud.go index 5b87964069b..73c7a976709 100644 --- a/server/controller/cloud/cloud.go +++ b/server/controller/cloud/cloud.go @@ -665,7 +665,7 @@ func (c *Cloud) appendResourceProcess(resource model.Resource) model.Resource { NetnsID: sProcess.NetnsID, ProcessName: processName, CommandLine: sProcess.CMDLine, - UserName: sProcess.User, + UserName: sProcess.UserName, ContainerID: sProcess.ContainerID, StartTime: sProcess.StartTime, OSAPPTags: sProcess.OSAPPTags, diff --git a/server/controller/db/mysql/migrator/schema/rawsql/init.sql b/server/controller/db/mysql/migrator/schema/rawsql/init.sql index 1a108042718..58b34d78ae7 100644 --- a/server/controller/db/mysql/migrator/schema/rawsql/init.sql +++ b/server/controller/db/mysql/migrator/schema/rawsql/init.sql @@ -9,7 +9,7 @@ CREATE TABLE IF NOT EXISTS plugin ( id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(256) NOT NULL, type INTEGER NOT NULL COMMENT '1: wasm 2: so 3: lua', - user INTEGER NOT NULL DEFAULT 1 COMMENT '1: agent 2: server', + user_name INTEGER NOT NULL DEFAULT 1 COMMENT '1: agent 2: server', image LONGBLOB NOT NULL, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME NOT NULL ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP, @@ -1447,7 +1447,7 @@ CREATE TABLE IF NOT EXISTS report_policy ( `data_level` enum('1s','1m') NOT NULL DEFAULT '1m', report_format TINYINT(1) DEFAULT 1 COMMENT 'Type of format (1-html)', report_type TINYINT(1) DEFAULT 1 COMMENT 'Type of reports (0-daily; 1-weekly; 2-monthly)', - `interval` enum('1d','1h') NOT NULL DEFAULT '1h', + `interval_time` enum('1d','1h') NOT NULL DEFAULT '1h', state TINYINT(1) DEFAULT 1 COMMENT '0-disable; 1-enable', push_type TINYINT(1) DEFAULT 1 COMMENT '1-email', push_email TEXT COMMENT 'separated by ,', @@ -1714,7 +1714,7 @@ CREATE TABLE IF NOT EXISTS genesis_process ( name TEXT, process_name TEXT, cmd_line TEXT, - user VARCHAR(256) DEFAULT '', + user_name VARCHAR(256) DEFAULT '', container_id CHAR(64) DEFAULT '', os_app_tags TEXT COMMENT 'separated by ,', node_ip CHAR(48) DEFAULT '', @@ -2083,7 +2083,7 @@ CREATE TABLE IF NOT EXISTS data_source ( data_table_collection CHAR(64), state INTEGER DEFAULT 1 COMMENT '0: Exception 1: Normal', base_data_source_id INTEGER, - `interval` INTEGER NOT NULL COMMENT 'uint: s', + `interval_time` INTEGER NOT NULL COMMENT 'uint: s', retention_time INTEGER NOT NULL COMMENT 'uint: hour', summable_metrics_operator CHAR(64), unsummable_metrics_operator CHAR(64), @@ -2093,67 +2093,67 @@ CREATE TABLE IF NOT EXISTS data_source ( TRUNCATE TABLE data_source; set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, `interval`, retention_time, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, `interval_time`, retention_time, lcuuid) VALUES (1, '网络-指标(秒级)', 'flow_metrics.network*', 1, 1*24, @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, base_data_source_id, `interval`, retention_time, summable_metrics_operator, unsummable_metrics_operator, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, base_data_source_id, `interval_time`, retention_time, summable_metrics_operator, unsummable_metrics_operator, lcuuid) VALUES (2, '网络-指标(分钟级)', 'flow_metrics.network*', 1, 60, 7*24, 'Sum', 'Avg', @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, `interval`, retention_time, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, `interval_time`, retention_time, lcuuid) VALUES (6, '网络-流日志', 'flow_log.l4_flow_log', 0, 3*24, @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, `interval`, retention_time, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, `interval_time`, retention_time, lcuuid) VALUES (7, '应用-指标(秒级)', 'flow_metrics.application*', 1, 1*24, @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, base_data_source_id, `interval`, retention_time, summable_metrics_operator, unsummable_metrics_operator, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, base_data_source_id, `interval_time`, retention_time, summable_metrics_operator, unsummable_metrics_operator, lcuuid) VALUES (8, '应用-指标(分钟级)', 'flow_metrics.application*', 7, 60, 7*24, 'Sum', 'Avg', @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, `interval`, retention_time, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, `interval_time`, retention_time, lcuuid) VALUES (9, '应用-调用日志', 'flow_log.l7_flow_log', 0, 3*24, @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, `interval`, retention_time, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, `interval_time`, retention_time, lcuuid) VALUES (10, '网络-TCP 时序数据', 'flow_log.l4_packet', 0, 3*24, @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, `interval`, retention_time, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, `interval_time`, retention_time, lcuuid) VALUES (11, '网络-PCAP 数据', 'flow_log.l7_packet', 0, 3*24, @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, `interval`, retention_time, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, `interval_time`, retention_time, lcuuid) VALUES (12, '租户侧监控数据', 'deepflow_tenant.*', 0, 7*24, @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, `interval`, retention_time, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, `interval_time`, retention_time, lcuuid) VALUES (13, '外部指标数据', 'ext_metrics.*', 0, 7*24, @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, `interval`, retention_time, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, `interval_time`, retention_time, lcuuid) VALUES (14, 'Prometheus 数据', 'prometheus.*', 0, 7*24, @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, `interval`, retention_time, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, `interval_time`, retention_time, lcuuid) VALUES (15, '事件-资源变更事件', 'event.event', 0, 30*24, @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, `interval`, retention_time, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, `interval_time`, retention_time, lcuuid) VALUES (16, '事件-IO 事件', 'event.perf_event', 0, 7*24, @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, `interval`, retention_time, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, `interval_time`, retention_time, lcuuid) VALUES (17, '事件-告警事件', 'event.alert_event', 0, 30*24, @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, `interval`, retention_time, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, `interval_time`, retention_time, lcuuid) VALUES (18, '应用-性能剖析', 'profile.in_process', 0, 3*24, @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, `interval`, retention_time, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, `interval_time`, retention_time, lcuuid) VALUES (19, '网络-网络策略', 'flow_metrics.traffic_policy', 60, 3*24, @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, `interval`, retention_time, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, `interval_time`, retention_time, lcuuid) VALUES (20, '日志-日志数据', 'application_log.log', 1, 30*24, @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, base_data_source_id, `interval`, retention_time, summable_metrics_operator, unsummable_metrics_operator, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, base_data_source_id, `interval_time`, retention_time, summable_metrics_operator, unsummable_metrics_operator, lcuuid) VALUES (21, '网络-指标(小时级)', 'flow_metrics.network*', 2, 3600, 30*24, 'Sum', 'Avg', @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, base_data_source_id, `interval`, retention_time, summable_metrics_operator, unsummable_metrics_operator, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, base_data_source_id, `interval_time`, retention_time, summable_metrics_operator, unsummable_metrics_operator, lcuuid) VALUES (22, '网络-指标(天级)', 'flow_metrics.network*', 21, 86400, 30*24, 'Sum', 'Avg', @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, base_data_source_id, `interval`, retention_time, summable_metrics_operator, unsummable_metrics_operator, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, base_data_source_id, `interval_time`, retention_time, summable_metrics_operator, unsummable_metrics_operator, lcuuid) VALUES (23, '应用-指标(小时级)', 'flow_metrics.application*', 8, 3600, 30*24, 'Sum', 'Avg', @lcuuid); set @lcuuid = (select uuid()); -INSERT INTO data_source (id, display_name, data_table_collection, base_data_source_id, `interval`, retention_time, summable_metrics_operator, unsummable_metrics_operator, lcuuid) +INSERT INTO data_source (id, display_name, data_table_collection, base_data_source_id, `interval_time`, retention_time, summable_metrics_operator, unsummable_metrics_operator, lcuuid) VALUES (24, '应用-指标(天级)', 'flow_metrics.application*', 23, 86400, 30*24, 'Sum', 'Avg', @lcuuid); CREATE TABLE IF NOT EXISTS voucher ( @@ -2195,7 +2195,7 @@ CREATE TABLE IF NOT EXISTS mail_server ( status int NOT NULL , host TEXT NOT NULL, port int Not NULL, - user TEXT NOT NULL, + user_name TEXT NOT NULL, password TEXT NOT NULL, security TEXT Not NULL, ntlm_enabled int, diff --git a/server/controller/db/mysql/migrator/schema/rawsql/issu/7.0.1.0.sql b/server/controller/db/mysql/migrator/schema/rawsql/issu/7.0.1.0.sql new file mode 100644 index 00000000000..85526f0eb11 --- /dev/null +++ b/server/controller/db/mysql/migrator/schema/rawsql/issu/7.0.1.0.sql @@ -0,0 +1,39 @@ +-- for /db/mysql/migration/script/upgrade_vtap_group_config.go +DROP PROCEDURE IF EXISTS RenameColumnIfExists; + +CREATE PROCEDURE RenameColumnIfExists( + IN tableName VARCHAR(255), + IN oldColName VARCHAR(255), + IN newColName VARCHAR(255), + IN colType VARCHAR(255) +) +BEGIN + DECLARE index_count INT; + + -- check if old column exists + SELECT COUNT(*) + INTO index_count + FROM information_schema.columns + WHERE table_schema = DATABASE() + AND table_name = tableName + AND column_name = newColName; + + -- if new column not exists, rename column + IF index_count = 0 THEN + SET @sql = CONCAT('ALTER TABLE ', tableName, ' CHANGE ', oldColName, ' ', newColName, ' ', colType); + PREPARE stmt FROM @sql; + EXECUTE stmt; + DEALLOCATE PREPARE stmt; + END IF; +END; + +CALL RenameColumnIfExists('mail_server', 'user', 'user_name', 'TEXT NOT NULL'); +CALL RenameColumnIfExists('plugin', 'user', 'user_name', "INTEGER NOT NULL DEFAULT 1 COMMENT '1: agent 2: server'"); +CALL RenameColumnIfExists('genesis_process', 'user', 'user_name', "VARCHAR(256) DEFAULT ''"); +CALL RenameColumnIfExists('data_source', "`interval`", 'interval_time', "INTEGER NOT NULL COMMENT 'uint: s'"); +CALL RenameColumnIfExists('report_policy', '`interval`', 'interval_time', "enum('1d','1h') NOT NULL DEFAULT '1h'"); + +DROP PROCEDURE RenameColumnIfExists; + + +UPDATE db_version SET version='7.0.1.0'; diff --git a/server/controller/db/mysql/migrator/schema/version.go b/server/controller/db/mysql/migrator/schema/version.go index e4363eb03ee..96cfd10da2c 100644 --- a/server/controller/db/mysql/migrator/schema/version.go +++ b/server/controller/db/mysql/migrator/schema/version.go @@ -18,7 +18,7 @@ package schema const ( DB_VERSION_TABLE = "db_version" - DB_VERSION_EXPECTED = "6.6.1.19" + DB_VERSION_EXPECTED = "7.0.1.0" ) const ( diff --git a/server/controller/db/mysql/model/model.go b/server/controller/db/mysql/model/model.go index 0fcd7f688c8..a5bc0974a49 100644 --- a/server/controller/db/mysql/model/model.go +++ b/server/controller/db/mysql/model/model.go @@ -261,7 +261,7 @@ type DataSource struct { DataTableCollection string `gorm:"column:data_table_collection;type:char(64);default:''" json:"DATA_TABLE_COLLECTION"` State int `gorm:"column:state;type:int;default:1" json:"STATE"` BaseDataSourceID int `gorm:"column:base_data_source_id;type:int" json:"BASE_DATA_SOURCE_ID"` - Interval int `gorm:"column:interval;type:int" json:"INTERVAL"` + IntervalTime int `gorm:"column:interval_time;type:int" json:"INTERVAL"` RetentionTime int `gorm:"column:retention_time;type:int" json:"RETENTION_TIME"` // unit: hour SummableMetricsOperator string `gorm:"column:summable_metrics_operator;type:char(64)" json:"SUMMABLE_METRICS_OPERATOR"` UnSummableMetricsOperator string `gorm:"column:unsummable_metrics_operator;type:char(64)" json:"UNSUMMABLE_METRICS_OPERATOR"` @@ -489,8 +489,8 @@ func (VTapRepo) TableName() string { type Plugin struct { ID int `gorm:"primaryKey;column:id;type:int;not null" json:"ID"` Name string `gorm:"column:name;type:varchar(256);not null" json:"NAME"` - Type int `gorm:"column:type;type:int" json:"TYPE"` // 1: wasm 2: so 3: lua - User int `gorm:"column:user;type:int;default:1" json:"USER"` // 1: agent 2: server + Type int `gorm:"column:type;type:int" json:"TYPE"` // 1: wasm 2: so 3: lua + UserName int `gorm:"column:user_name;type:int;default:1" json:"USER"` // 1: agent 2: server Image compressedBytes `gorm:"column:image;type:logblob;not null" json:"IMAGE"` CreatedAt time.Time `gorm:"column:created_at;type:timestamp;not null;default:CURRENT_TIMESTAMP" json:"CREATED_AT"` UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;not null;default:CURRENT_TIMESTAMP" json:"UPDATED_AT"` @@ -505,7 +505,7 @@ type MailServer struct { Status int `gorm:"column:status;type:int;not null" json:"STATUS"` Host string `gorm:"column:host;type:text;not null" json:"HOST"` Port int `gorm:"column:port;type:int;not null" json:"PORT"` - User string `gorm:"column:user;type:text;not null" json:"USER"` + UserName string `gorm:"column:user_name;type:text;not null" json:"USER"` Password string `gorm:"column:password;type:text;not null" json:"PASSWORD"` Security string `gorm:"column:security;type:text;not null" json:"SECURITY"` NtlmEnabled int `gorm:"column:ntlm_enabled;type:int" json:"NTLM_ENABLED"` diff --git a/server/controller/genesis/grpc/server.go b/server/controller/genesis/grpc/server.go index 763c3e859b1..96c9291bacc 100644 --- a/server/controller/genesis/grpc/server.go +++ b/server/controller/genesis/grpc/server.go @@ -542,7 +542,7 @@ func (g *SynchronizerServer) GenesisSharingSync(ctx context.Context, request *co Name: &pData.Name, ProcessName: &pData.ProcessName, CmdLine: &pData.CMDLine, - User: &pData.User, + User: &pData.UserName, ContainerId: &pData.ContainerID, OsAppTags: &pData.OSAPPTags, NodeIp: &pData.NodeIP, diff --git a/server/controller/genesis/store/sync/run.go b/server/controller/genesis/store/sync/run.go index f24302abfb6..f2b5c08b6cf 100644 --- a/server/controller/genesis/store/sync/run.go +++ b/server/controller/genesis/store/sync/run.go @@ -387,7 +387,7 @@ func (g *GenesisSync) GetGenesisSyncResponse(orgID int) (common.GenesisSyncDataR ProcessName: p.GetProcessName(), CMDLine: p.GetCmdLine(), ContainerID: p.GetContainerId(), - User: p.GetUser(), + UserName: p.GetUser(), OSAPPTags: p.GetOsAppTags(), NodeIP: p.GetNodeIp(), StartTime: pStartTime, diff --git a/server/controller/genesis/updater/agent_sync.go b/server/controller/genesis/updater/agent_sync.go index 4dc98ceeadf..13a9e872927 100644 --- a/server/controller/genesis/updater/agent_sync.go +++ b/server/controller/genesis/updater/agent_sync.go @@ -431,7 +431,7 @@ func (v *GenesisSyncRpcUpdater) ParseAgentProcessInfo(orgID int, vtapID uint32, Name: p.GetName(), ProcessName: p.GetProcessName(), CMDLine: p.GetCmdline(), - User: p.GetUser(), + UserName: p.GetUser(), ContainerID: p.GetContainerId(), VtapID: vtapID, NodeIP: v.nodeIP, diff --git a/server/controller/genesis/updater/sync.go b/server/controller/genesis/updater/sync.go index 22bf0cf29ba..3a69f7a59b1 100644 --- a/server/controller/genesis/updater/sync.go +++ b/server/controller/genesis/updater/sync.go @@ -536,7 +536,7 @@ func (v *GenesisSyncRpcUpdater) ParseProcessInfo(orgID int, vtapID uint32, messa Name: p.GetName(), ProcessName: p.GetProcessName(), CMDLine: p.GetCmdline(), - User: p.GetUser(), + UserName: p.GetUser(), ContainerID: p.GetContainerId(), VtapID: vtapID, NodeIP: v.nodeIP, diff --git a/server/controller/http/router/plugin.go b/server/controller/http/router/plugin.go index c652ff4e547..ff789f939f4 100644 --- a/server/controller/http/router/plugin.go +++ b/server/controller/http/router/plugin.go @@ -67,9 +67,9 @@ func createPlugin(c *gin.Context) { return } plugin := &mysqlmodel.Plugin{ - Name: c.PostForm("NAME"), - Type: t, - User: u, + Name: c.PostForm("NAME"), + Type: t, + UserName: u, } // get file diff --git a/server/controller/http/service/data_source.go b/server/controller/http/service/data_source.go index 82c52c5f240..0f691da874b 100644 --- a/server/controller/http/service/data_source.go +++ b/server/controller/http/service/data_source.go @@ -150,13 +150,13 @@ func (d *DataSource) GetDataSources(orgID int, filter map[string]interface{}, sp } } if name, ok := filter["name"]; ok { - interval := convertNameToInterval(name.(string)) - if interval != 0 && interval != dataSource.Interval { + interval_time := convertNameToInterval(name.(string)) + if interval_time != 0 && interval_time != dataSource.IntervalTime { continue } } - name, err := getName(dataSource.Interval, dataSource.DataTableCollection) + name, err := getName(dataSource.IntervalTime, dataSource.DataTableCollection) if err != nil { log.Error(err, dbInfo.LogPrefixORGID) return nil, err @@ -170,7 +170,7 @@ func (d *DataSource) GetDataSources(orgID int, filter map[string]interface{}, sp DataTableCollection: dataSource.DataTableCollection, State: dataSource.State, BaseDataSourceID: dataSource.BaseDataSourceID, - Interval: dataSource.Interval, + IntervalTime: dataSource.IntervalTime, RetentionTime: dataSource.RetentionTime, SummableMetricsOperator: dataSource.SummableMetricsOperator, UnSummableMetricsOperator: dataSource.UnSummableMetricsOperator, @@ -189,13 +189,13 @@ func (d *DataSource) GetDataSources(orgID int, filter map[string]interface{}, sp if specCfg != nil { if dataSource.DataTableCollection == "deepflow_tenant.*" || dataSource.DataTableCollection == "deepflow_admin.*" { - dataSourceResp.Interval = common.DATA_SOURCE_DEEPFLOW_SYSTEM_INTERVAL + dataSourceResp.IntervalTime = common.DATA_SOURCE_DEEPFLOW_SYSTEM_INTERVAL } if dataSource.DataTableCollection == "ext_metrics.*" { - dataSourceResp.Interval = specCfg.DataSourceExtMetricsInterval + dataSourceResp.IntervalTime = specCfg.DataSourceExtMetricsInterval } if dataSource.DataTableCollection == "prometheus.*" { - dataSourceResp.Interval = specCfg.DataSourcePrometheusInterval + dataSourceResp.IntervalTime = specCfg.DataSourcePrometheusInterval } } @@ -222,13 +222,13 @@ func (d *DataSource) CreateDataSource(orgID int, dataSourceCreate *model.DataSou if ret := db.Where( map[string]interface{}{ "data_table_collection": dataSourceCreate.DataTableCollection, - "interval": dataSourceCreate.Interval, + "interval_time": dataSourceCreate.IntervalTime, }, ).First(&dataSource); ret.Error == nil { return model.DataSource{}, NewError( httpcommon.RESOURCE_ALREADY_EXIST, - fmt.Sprintf("data_source with same effect(data_table_collection: %v, interval: %v) already exists", - dataSourceCreate.DataTableCollection, dataSourceCreate.Interval), + fmt.Sprintf("data_source with same effect(data_table_collection: %v, interval_time: %v) already exists", + dataSourceCreate.DataTableCollection, dataSourceCreate.IntervalTime), ) } @@ -256,16 +256,16 @@ func (d *DataSource) CreateDataSource(orgID int, dataSourceCreate *model.DataSou ) } - if baseDataSource.DataTableCollection != dataSourceCreate.DataTableCollection || baseDataSource.Interval == common.INTERVAL_1DAY { + if baseDataSource.DataTableCollection != dataSourceCreate.DataTableCollection || baseDataSource.IntervalTime == common.INTERVAL_1DAY { return model.DataSource{}, NewError( httpcommon.PARAMETER_ILLEGAL, - "base data_source tsdb_type should the same as tsdb and interval should ne 1 day", + "base data_source tsdb_type should the same as tsdb and interval_time should ne 1 day", ) } - if baseDataSource.Interval >= dataSourceCreate.Interval { + if baseDataSource.IntervalTime >= dataSourceCreate.IntervalTime { return model.DataSource{}, NewError( - httpcommon.PARAMETER_ILLEGAL, "interval should gt base data_source interval", + httpcommon.PARAMETER_ILLEGAL, "interval_time should gt base data_source interval_time", ) } @@ -290,7 +290,7 @@ func (d *DataSource) CreateDataSource(orgID int, dataSourceCreate *model.DataSou dataSource.DisplayName = dataSourceCreate.DisplayName dataSource.DataTableCollection = dataSourceCreate.DataTableCollection dataSource.BaseDataSourceID = dataSourceCreate.BaseDataSourceID - dataSource.Interval = dataSourceCreate.Interval + dataSource.IntervalTime = dataSourceCreate.IntervalTime dataSource.RetentionTime = dataSourceCreate.RetentionTime dataSource.SummableMetricsOperator = dataSourceCreate.SummableMetricsOperator dataSource.UnSummableMetricsOperator = dataSourceCreate.UnSummableMetricsOperator @@ -541,10 +541,10 @@ func (d *DataSource) DeleteDataSource(orgID int, lcuuid string) (map[string]stri func (d *DataSource) CallIngesterAPIAddRP(orgID int, ip string, dataSource, baseDataSource mysqlmodel.DataSource) error { var name, baseName string var err error - if name, err = getName(dataSource.Interval, dataSource.DataTableCollection); err != nil { + if name, err = getName(dataSource.IntervalTime, dataSource.DataTableCollection); err != nil { return err } - if baseName, err = getName(baseDataSource.Interval, baseDataSource.DataTableCollection); err != nil { + if baseName, err = getName(baseDataSource.IntervalTime, baseDataSource.DataTableCollection); err != nil { return err } body := map[string]interface{}{ @@ -554,7 +554,7 @@ func (d *DataSource) CallIngesterAPIAddRP(orgID int, ip string, dataSource, base "base-rp": baseName, "summable-metrics-op": strings.ToLower(dataSource.SummableMetricsOperator), "unsummable-metrics-op": strings.ToLower(dataSource.UnSummableMetricsOperator), - "interval": dataSource.Interval / common.INTERVAL_1MINUTE, + "interval": dataSource.IntervalTime / common.INTERVAL_1MINUTE, "retention-time": dataSource.RetentionTime, } if len(d.ipToController) == 0 { @@ -577,7 +577,7 @@ func (d *DataSource) CallIngesterAPIAddRP(orgID int, ip string, dataSource, base } func (d *DataSource) CallIngesterAPIModRP(orgID int, ip string, dataSource mysqlmodel.DataSource) error { - name, err := getName(dataSource.Interval, dataSource.DataTableCollection) + name, err := getName(dataSource.IntervalTime, dataSource.DataTableCollection) if err != nil { return err } @@ -607,7 +607,7 @@ func (d *DataSource) CallIngesterAPIModRP(orgID int, ip string, dataSource mysql } func (d *DataSource) CallIngesterAPIDelRP(orgID int, ip string, dataSource mysqlmodel.DataSource) error { - name, err := getName(dataSource.Interval, dataSource.DataTableCollection) + name, err := getName(dataSource.IntervalTime, dataSource.DataTableCollection) if err != nil { return err } @@ -635,8 +635,8 @@ func (d *DataSource) CallIngesterAPIDelRP(orgID int, ip string, dataSource mysql return err } -func getName(interval int, collection string) (string, error) { - switch interval { +func getName(interval_time int, collection string) (string, error) { + switch interval_time { case 0: // return value: flow_log.l4_flow_log, flow_log.l7_flow_log, // flow_log.l4_packet, flow_log.l7_packet, @@ -652,11 +652,11 @@ func getName(interval int, collection string) (string, error) { case 86400: // one day, 60*60*24 return "1d", nil default: - return "", fmt.Errorf("get name error, interval does not support value: %d", interval) + return "", fmt.Errorf("get name error, interval_time does not support value: %d", interval_time) } } -func convertNameToInterval(name string) (interval int) { +func convertNameToInterval(name string) (interval_time int) { switch name { case "1s": return 1 diff --git a/server/controller/http/service/mail_server.go b/server/controller/http/service/mail_server.go index 091b3b2473f..5ee90758857 100644 --- a/server/controller/http/service/mail_server.go +++ b/server/controller/http/service/mail_server.go @@ -49,7 +49,7 @@ func GetMailServer(filter map[string]interface{}) (resp []model.MailServer, err Status: mail.Status, Host: mail.Host, Port: mail.Port, - User: mail.User, + UserName: mail.UserName, Password: mail.Password, Security: mail.Security, NtlmEnabled: mail.NtlmEnabled, @@ -68,7 +68,7 @@ func CreateMailServer(mailCreate model.MailServerCreate) (model.MailServer, erro mailServer.Status = mailCreate.Status mailServer.Host = mailCreate.Host mailServer.Port = mailCreate.Port - mailServer.User = mailCreate.User + mailServer.UserName = mailCreate.UserName mailServer.Password = mailCreate.Password mailServer.Security = mailCreate.Security mailServer.NtlmEnabled = mailCreate.NtlmEnabled @@ -93,14 +93,16 @@ func UpdateMailServer(lcuuid string, mailServerUpdate map[string]interface{}) (m return model.MailServer{}, NewError(httpcommon.INVALID_PARAMETERS, "must specify lcuuid") } - log.Infof("update mailServer(%s) config %v", mailServer.User, mailServerUpdate) + log.Infof("update mailServer(%s) config %v", mailServer.UserName, mailServerUpdate) - for _, key := range []string{"STATUS", "HOST", "PORT", "USER", "PASSWORD", "SECURITY", "NTLM_ENABLED", "NTLM_NAME", "NTLM_PASSWORD"} { + for _, key := range []string{"STATUS", "HOST", "PORT", "PASSWORD", "SECURITY", "NTLM_ENABLED", "NTLM_NAME", "NTLM_PASSWORD"} { if _, ok := mailServerUpdate[key]; ok { dbUpdateMap[strings.ToLower(key)] = mailServerUpdate[key] } } - + if _, ok := mailServerUpdate["USER"]; ok { + dbUpdateMap["user_name"] = mailServerUpdate["USER"] + } mysql.DefaultDB.Model(&mailServer).Updates(dbUpdateMap) response, err := GetMailServer(map[string]interface{}{"lcuuid": mailServer.Lcuuid}) @@ -114,7 +116,7 @@ func DeleteMailServer(lcuuid string) (map[string]string, error) { return map[string]string{}, NewError(httpcommon.RESOURCE_NOT_FOUND, fmt.Sprintf("mail-server (%s) not found", lcuuid)) } - log.Infof("delete mail server (%s)", mailServer.User) + log.Infof("delete mail server (%s)", mailServer.UserName) mysql.DefaultDB.Delete(&mailServer) return map[string]string{"LCUUID": lcuuid}, nil diff --git a/server/controller/http/service/plugin.go b/server/controller/http/service/plugin.go index 42c620bafe5..9757a023a65 100644 --- a/server/controller/http/service/plugin.go +++ b/server/controller/http/service/plugin.go @@ -71,7 +71,7 @@ func GetPlugin(db *mysql.DB, filter map[string]interface{}) ([]model.Plugin, err Name: plugin.Name, Type: plugin.Type, UpdatedAt: plugin.UpdatedAt.Format(common.GO_BIRTHDAY), - User: plugin.User, + UserName: plugin.UserName, } resp = append(resp, temp) } diff --git a/server/controller/model/model.go b/server/controller/model/model.go index f6d7192eb9d..be455e52ed3 100644 --- a/server/controller/model/model.go +++ b/server/controller/model/model.go @@ -263,7 +263,7 @@ type DataSource struct { State int `json:"STATE"` BaseDataSourceID int `json:"BASE_DATA_SOURCE_ID"` BaseDataSourceDisplayName string `json:"BASE_DATA_SOURCE_NAME"` - Interval int `json:"INTERVAL"` + IntervalTime int `json:"INTERVAL"` RetentionTime int `json:"RETENTION_TIME"` SummableMetricsOperator string `json:"SUMMABLE_METRICS_OPERATOR"` UnSummableMetricsOperator string `json:"UNSUMMABLE_METRICS_OPERATOR"` @@ -276,7 +276,7 @@ type DataSourceCreate struct { DisplayName string `json:"DISPLAY_NAME" binding:"required,min=1,max=10"` DataTableCollection string `json:"DATA_TABLE_COLLECTION" binding:"required,oneof=flow_metrics.network* flow_metrics.application*"` BaseDataSourceID int `json:"BASE_DATA_SOURCE_ID" binding:"required"` - Interval int `json:"INTERVAL" binding:"required"` + IntervalTime int `json:"INTERVAL" binding:"required"` RetentionTime int `json:"RETENTION_TIME" binding:"required,min=1"` SummableMetricsOperator string `json:"SUMMABLE_METRICS_OPERATOR" binding:"required,oneof=Sum Max Min"` UnSummableMetricsOperator string `json:"UNSUMMABLE_METRICS_OPERATOR" binding:"required,oneof=Avg Max Min"` @@ -670,7 +670,7 @@ type GenesisProcess struct { ProcessName string `gorm:"column:process_name;type:text;default:null" json:"PROCESS_NAME"` CMDLine string `gorm:"column:cmd_line;type:text;default:null" json:"CMD_LINE"` ContainerID string `gorm:"column:container_id;type:char(64);default:''" json:"CONTAINER_ID"` - User string `gorm:"column:user;type:varchar(256);default:null" json:"USER"` + UserName string `gorm:"column:user_name;type:varchar(256);default:null" json:"USER"` OSAPPTags string `gorm:"column:os_app_tags;type:text;default:null" json:"OS_APP_TAGS"` NodeIP string `gorm:"primaryKey;column:node_ip;type:char(48)" json:"NODE_IP"` StartTime time.Time `gorm:"column:start_time;type:datetime;not null;default:CURRENT_TIMESTAMP" json:"START_TIME"` @@ -719,7 +719,7 @@ type CSVHeader struct { type Plugin struct { Name string `json:"NAME" binding:"required"` Type int `json:"TYPE" binding:"required"` - User int `json:"USER" binding:"required"` + UserName int `json:"USER" binding:"required"` Image []byte `json:"IMAGE,omitempty" binding:"required"` UpdatedAt string `json:"UPDATED_AT"` } @@ -728,7 +728,7 @@ type MailServerCreate struct { Status int `json:"STATUS"` Host string `json:"HOST" binding:"required"` Port int `json:"PORT" binding:"required"` - User string `json:"USER" binding:"required"` + UserName string `json:"USER" binding:"required"` Password string `json:"PASSWORD" binding:"required"` NtlmEnabled int `json:"NTLM_ENABLED"` NtlmName string `json:"NTLM_NAME"` @@ -740,7 +740,7 @@ type MailServerUpdate struct { Status int `json:"STATUS"` Host string `json:"HOST"` Port int `json:"PORT"` - User string `json:"USER"` + UserName string `json:"USER"` Password string `json:"PASSWORD"` NtlmEnabled int `json:"NTLM_ENABLED"` NtlmName string `json:"NTLM_NAME"` @@ -753,7 +753,7 @@ type MailServer struct { Status int `json:"STATUS"` Host string `json:"HOST"` Port int `json:"PORT"` - User string `json:"USER"` + UserName string `json:"USER"` Password string `json:"PASSWORD"` Security string `json:"SECURITY"` NtlmEnabled int `json:"NTLM_ENABLED"`