diff --git a/internal/db/models/http_access_log_dao.go b/internal/db/models/http_access_log_dao.go index c86560f6..ff29d1bf 100644 --- a/internal/db/models/http_access_log_dao.go +++ b/internal/db/models/http_access_log_dao.go @@ -110,7 +110,7 @@ func (this *HTTPAccessLogDAO) CreateHTTPAccessLogsWithDAO(daoWrapper *HTTPAccess } // 读取往前的 单页访问日志 -func (this *HTTPAccessLogDAO) ListAccessLogs(lastRequestId string, size int64, day string, serverId int64, reverse bool) (result []*HTTPAccessLog, nextLastRequestId string, hasMore bool, err error) { +func (this *HTTPAccessLogDAO) ListAccessLogs(lastRequestId string, size int64, day string, serverId int64, reverse bool, hasError bool) (result []*HTTPAccessLog, nextLastRequestId string, hasMore bool, err error) { if len(day) != 8 { return } @@ -120,18 +120,18 @@ func (this *HTTPAccessLogDAO) ListAccessLogs(lastRequestId string, size int64, d size = 1000 } - result, nextLastRequestId, err = this.listAccessLogs(lastRequestId, size, day, serverId, reverse) + result, nextLastRequestId, err = this.listAccessLogs(lastRequestId, size, day, serverId, reverse, hasError) if err != nil || int64(len(result)) < size { return } - moreResult, _, _ := this.listAccessLogs(nextLastRequestId, 1, day, serverId, reverse) + moreResult, _, _ := this.listAccessLogs(nextLastRequestId, 1, day, serverId, reverse, hasError) hasMore = len(moreResult) > 0 return } // 读取往前的单页访问日志 -func (this *HTTPAccessLogDAO) listAccessLogs(lastRequestId string, size int64, day string, serverId int64, reverse bool) (result []*HTTPAccessLog, nextLastRequestId string, err error) { +func (this *HTTPAccessLogDAO) listAccessLogs(lastRequestId string, size int64, day string, serverId int64, reverse bool, hasError bool) (result []*HTTPAccessLog, nextLastRequestId string, err error) { if size <= 0 { return nil, lastRequestId, nil } @@ -177,6 +177,9 @@ func (this *HTTPAccessLogDAO) listAccessLogs(lastRequestId string, size int64, d if serverId > 0 { query.Attr("serverId", serverId) } + if hasError { + query.Where("status>400") + } // offset if len(lastRequestId) > 0 { diff --git a/internal/db/models/node_dao.go b/internal/db/models/node_dao.go index 3d236968..40d8c03f 100644 --- a/internal/db/models/node_dao.go +++ b/internal/db/models/node_dao.go @@ -491,7 +491,7 @@ func (this *NodeDAO) ComposeNodeConfig(nodeId int64) (*nodeconfigs.NodeConfig, e // 全局设置 // TODO 根据用户的不同读取不同的全局设置 - settingJSON, err := SharedSysSettingDAO.ReadSetting(SettingCodeGlobalConfig) + settingJSON, err := SharedSysSettingDAO.ReadSetting(SettingCodeServerGlobalConfig) if err != nil { return nil, err } diff --git a/internal/db/models/sys_setting_dao.go b/internal/db/models/sys_setting_dao.go index 4b636e95..f187cc4f 100644 --- a/internal/db/models/sys_setting_dao.go +++ b/internal/db/models/sys_setting_dao.go @@ -13,7 +13,9 @@ type SysSettingDAO dbs.DAO type SettingCode = string const ( - SettingCodeGlobalConfig SettingCode = "globalConfig" + SettingCodeServerGlobalConfig SettingCode = "serverGlobalConfig" // 服务相关全局设置 + SettingCodeNodeMonitor SettingCode = "nodeMonitor" // 监控节点状态 + SettingCodeClusterHealthCheck SettingCode = "clusterHealthCheck" // 集群健康检查 ) func NewSysSettingDAO() *SysSettingDAO { diff --git a/internal/rpc/services/service_http_access_log.go b/internal/rpc/services/service_http_access_log.go index 7af53a23..b1c47ebf 100644 --- a/internal/rpc/services/service_http_access_log.go +++ b/internal/rpc/services/service_http_access_log.go @@ -39,7 +39,7 @@ func (this *HTTPAccessLogService) ListHTTPAccessLogs(ctx context.Context, req *p return nil, err } - accessLogs, requestId, hasMore, err := models.SharedHTTPAccessLogDAO.ListAccessLogs(req.RequestId, req.Size, req.Day, req.ServerId, req.Reverse) + accessLogs, requestId, hasMore, err := models.SharedHTTPAccessLogDAO.ListAccessLogs(req.RequestId, req.Size, req.Day, req.ServerId, req.Reverse, req.HasError) if err != nil { return nil, err } diff --git a/internal/tasks/health_check_cluster_task.go b/internal/tasks/health_check_cluster_task.go index d49098b4..1b83c2c7 100644 --- a/internal/tasks/health_check_cluster_task.go +++ b/internal/tasks/health_check_cluster_task.go @@ -87,7 +87,7 @@ func (this *HealthCheckClusterTask) Stop() { // 单个循环任务 func (this *HealthCheckClusterTask) loop(seconds int64) error { // 检查上次运行时间,防止重复运行 - settingKey := "cluster_health_check_%d" + numberutils.FormatInt64(this.clusterId) + settingKey := models.SettingCodeClusterHealthCheck + numberutils.FormatInt64(this.clusterId) timestamp := time.Now().Unix() c, err := models.SharedSysSettingDAO.CompareInt64Setting(settingKey, timestamp-seconds) if err != nil { diff --git a/internal/tasks/node_monitor_task.go b/internal/tasks/node_monitor_task.go index fcd2b5f8..75632c55 100644 --- a/internal/tasks/node_monitor_task.go +++ b/internal/tasks/node_monitor_task.go @@ -40,7 +40,7 @@ func (this *NodeMonitorTask) Run() { func (this *NodeMonitorTask) loop() error { // 检查上次运行时间,防止重复运行 - settingKey := "node_monitor" + settingKey := models.SettingCodeNodeMonitor timestamp := time.Now().Unix() c, err := models.SharedSysSettingDAO.CompareInt64Setting(settingKey, timestamp-int64(this.intervalSeconds)) if err != nil {