Documentation
¶
Overview ¶
Package monitor provides process monitoring and auto-restart functionality. Package monitor 提供进程监控和自动重启功能。
Index ¶
- Variables
- type AgentConfigSender
- type ClusterNodeProvider
- type Handler
- type MonitorConfig
- type NodeInfoForMonitor
- type ProcessEvent
- type ProcessEventFilter
- type ProcessEventType
- type ProcessEventWithHost
- type Repository
- func (r *Repository) CountEventsByType(ctx context.Context, clusterID uint, eventType ProcessEventType, ...) (int64, error)
- func (r *Repository) CreateConfig(ctx context.Context, config *MonitorConfig) error
- func (r *Repository) CreateEvent(ctx context.Context, event *ProcessEvent) error
- func (r *Repository) DeleteConfigByClusterID(ctx context.Context, clusterID uint) error
- func (r *Repository) DeleteEventsByClusterID(ctx context.Context, clusterID uint) error
- func (r *Repository) GetConfigByClusterID(ctx context.Context, clusterID uint) (*MonitorConfig, error)
- func (r *Repository) GetEventByID(ctx context.Context, id uint) (*ProcessEvent, error)
- func (r *Repository) GetLatestEventByNodeID(ctx context.Context, nodeID uint) (*ProcessEvent, error)
- func (r *Repository) GetLatestEventByNodeIDAndTypes(ctx context.Context, nodeID uint, eventTypes []ProcessEventType) (*ProcessEvent, error)
- func (r *Repository) HasNodeEventAfter(ctx context.Context, nodeID uint, after time.Time, ...) (bool, *ProcessEvent, error)
- func (r *Repository) ListEvents(ctx context.Context, filter *ProcessEventFilter) ([]*ProcessEvent, int64, error)
- func (r *Repository) ListEventsByClusterID(ctx context.Context, clusterID uint, limit int) ([]*ProcessEvent, error)
- func (r *Repository) ListEventsWithHost(ctx context.Context, filter *ProcessEventFilter) ([]*ProcessEventWithHost, int64, error)
- func (r *Repository) UpdateConfig(ctx context.Context, config *MonitorConfig) error
- type Service
- func (s *Service) DeleteClusterEvents(ctx context.Context, clusterID uint) error
- func (s *Service) DeleteConfig(ctx context.Context, clusterID uint) error
- func (s *Service) GetConfig(ctx context.Context, clusterID uint) (*MonitorConfig, error)
- func (s *Service) GetEvent(ctx context.Context, id uint) (*ProcessEvent, error)
- func (s *Service) GetEventStats(ctx context.Context, clusterID uint, since *time.Time) (map[ProcessEventType]int64, error)
- func (s *Service) GetLatestNodeEvent(ctx context.Context, nodeID uint) (*ProcessEvent, error)
- func (s *Service) GetLatestNodeEventByTypes(ctx context.Context, nodeID uint, eventTypes []ProcessEventType) (*ProcessEvent, error)
- func (s *Service) GetOrCreateConfig(ctx context.Context, clusterID uint) (*MonitorConfig, error)
- func (s *Service) HasNodeEventAfter(ctx context.Context, nodeID uint, after time.Time, ...) (bool, *ProcessEvent, error)
- func (s *Service) ListClusterEvents(ctx context.Context, clusterID uint, limit int) ([]*ProcessEvent, error)
- func (s *Service) ListEvents(ctx context.Context, filter *ProcessEventFilter) ([]*ProcessEventWithHost, int64, error)
- func (s *Service) MarkConfigSynced(ctx context.Context, clusterID uint) error
- func (s *Service) PushDisableConfigForCluster(ctx context.Context, clusterID uint)
- func (s *Service) RecordEvent(ctx context.Context, event *ProcessEvent) error
- func (s *Service) RecordEventFromReport(ctx context.Context, clusterID, nodeID, hostID uint, ...) error
- func (s *Service) SetConfigSender(sender AgentConfigSender)
- func (s *Service) SetNodeProvider(provider ClusterNodeProvider)
- func (s *Service) SetOnEventRecorded(fn func(context.Context, *ProcessEvent) error)
- func (s *Service) UpdateConfig(ctx context.Context, clusterID uint, req *UpdateMonitorConfigRequest) (*MonitorConfig, error)
- type TrackedProcessInfo
- type UpdateMonitorConfigRequest
Constants ¶
This section is empty.
Variables ¶
var ( // ErrConfigNotFound indicates the monitor config was not found. // ErrConfigNotFound 表示监控配置未找到。 ErrConfigNotFound = errors.New("monitor config not found / 监控配置未找到") // ErrInvalidMonitorInterval indicates the monitor interval is invalid. // ErrInvalidMonitorInterval 表示监控间隔无效。 ErrInvalidMonitorInterval = errors.New("monitor interval must be between 1 and 60 seconds / 监控间隔必须在 1-60 秒之间") // ErrInvalidRestartDelay indicates the restart delay is invalid. // ErrInvalidRestartDelay 表示重启延迟无效。 ErrInvalidRestartDelay = errors.New("restart delay must be between 1 and 300 seconds / 重启延迟必须在 1-300 秒之间") // ErrInvalidMaxRestarts indicates the max restarts is invalid. // ErrInvalidMaxRestarts 表示最大重启次数无效。 ErrInvalidMaxRestarts = errors.New("max restarts must be between 1 and 10 / 最大重启次数必须在 1-10 之间") // ErrInvalidTimeWindow indicates the time window is invalid. // ErrInvalidTimeWindow 表示时间窗口无效。 ErrInvalidTimeWindow = errors.New("time window must be between 60 and 3600 seconds / 时间窗口必须在 60-3600 秒之间") // ErrInvalidCooldownPeriod indicates the cooldown period is invalid. // ErrInvalidCooldownPeriod 表示冷却时间无效。 ErrInvalidCooldownPeriod = errors.New("cooldown period must be between 60 and 86400 seconds / 冷却时间必须在 60-86400 秒之间") // ErrEventNotFound indicates the process event was not found. // ErrEventNotFound 表示进程事件未找到。 ErrEventNotFound = errors.New("process event not found / 进程事件未找到") )
Error definitions for monitor package. 监控包的错误定义。
Functions ¶
This section is empty.
Types ¶
type AgentConfigSender ¶
type AgentConfigSender interface {
// SendMonitorConfig sends monitor config and tracked processes to agent.
// SendMonitorConfig 向 Agent 发送监控配置和跟踪的进程列表。
SendMonitorConfig(ctx context.Context, agentID string, config *MonitorConfig, processes []*TrackedProcessInfo) error
}
AgentConfigSender defines the interface for sending config to agents. AgentConfigSender 定义向 Agent 发送配置的接口。
type ClusterNodeProvider ¶
type ClusterNodeProvider interface {
// GetNodesByClusterID returns all nodes for a cluster.
// GetNodesByClusterID 返回集群的所有节点。
GetNodesByClusterID(ctx context.Context, clusterID uint) ([]*NodeInfoForMonitor, error)
}
ClusterNodeProvider defines the interface for getting cluster node information. ClusterNodeProvider 定义获取集群节点信息的接口。
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles HTTP requests for monitor configuration and events. Handler 处理监控配置和事件的 HTTP 请求。
func NewHandler ¶
NewHandler creates a new monitor handler. NewHandler 创建新的监控处理器。
func (*Handler) GetEventStats ¶
GetEventStats handles GET /api/v1/clusters/:id/events/stats GetEventStats 处理 GET /api/v1/clusters/:id/events/stats @Summary Get event statistics for a cluster @Description Get event statistics for a specific cluster @Tags Monitor @Accept json @Produce json @Param id path int true "Cluster ID" @Param since query string false "Since time (RFC3339)" @Success 200 {object} map[string]int64 @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Router /api/v1/clusters/{id}/events/stats [get]
func (*Handler) GetMonitorConfig ¶
GetMonitorConfig handles GET /api/v1/clusters/:id/monitor-config GetMonitorConfig 处理 GET /api/v1/clusters/:id/monitor-config @Summary Get monitor configuration for a cluster @Description Get the monitoring configuration for a specific cluster @Tags Monitor @Accept json @Produce json @Param id path int true "Cluster ID" @Success 200 {object} MonitorConfig @Failure 400 {object} map[string]string @Failure 404 {object} map[string]string @Router /api/v1/clusters/{id}/monitor-config [get]
func (*Handler) ListProcessEvents ¶
ListProcessEvents handles GET /api/v1/clusters/:id/events ListProcessEvents 处理 GET /api/v1/clusters/:id/events @Summary List process events for a cluster @Description Get a list of process events for a specific cluster @Tags Monitor @Accept json @Produce json @Param id path int true "Cluster ID" @Param event_type query string false "Event type filter" @Param node_id query int false "Node ID filter" @Param start_time query string false "Start time (RFC3339)" @Param end_time query string false "End time (RFC3339)" @Param page query int false "Page number" default(1) @Param page_size query int false "Page size" default(20) @Success 200 {object} map[string]interface{} @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Router /api/v1/clusters/{id}/events [get]
func (*Handler) UpdateMonitorConfig ¶
UpdateMonitorConfig handles PUT /api/v1/clusters/:id/monitor-config UpdateMonitorConfig 处理 PUT /api/v1/clusters/:id/monitor-config @Summary Update monitor configuration for a cluster @Description Update the monitoring configuration for a specific cluster @Tags Monitor @Accept json @Produce json @Param id path int true "Cluster ID" @Param config body UpdateMonitorConfigRequest true "Monitor config update" @Success 200 {object} MonitorConfig @Failure 400 {object} map[string]string @Failure 500 {object} map[string]string @Router /api/v1/clusters/{id}/monitor-config [put]
type MonitorConfig ¶
type MonitorConfig struct {
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
ClusterID uint `json:"cluster_id" gorm:"uniqueIndex;not null"` // 关联的集群 ID / Associated cluster ID
AutoMonitor bool `json:"auto_monitor" gorm:"default:true"` // 是否启用自动监控 / Whether auto monitoring is enabled
AutoRestart bool `json:"auto_restart" gorm:"default:true"` // 是否启用自动拉起 / Whether auto restart is enabled
MonitorInterval int `json:"monitor_interval" gorm:"default:5"` // 监控间隔(秒)/ Monitor interval (seconds)
RestartDelay int `json:"restart_delay" gorm:"default:10"` // 重启延迟(秒)/ Restart delay (seconds)
MaxRestarts int `json:"max_restarts" gorm:"default:3"` // 最大重启次数 / Max restart count
TimeWindow int `json:"time_window" gorm:"default:300"` // 时间窗口(秒,5分钟)/ Time window (seconds, 5 minutes)
CooldownPeriod int `json:"cooldown_period" gorm:"default:1800"` // 冷却时间(秒,30分钟)/ Cooldown period (seconds, 30 minutes)
ConfigVersion int `json:"config_version" gorm:"default:1"` // 配置版本号 / Config version number
LastSyncAt *time.Time `json:"last_sync_at"` // 最后同步时间 / Last sync time
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}
MonitorConfig represents the monitoring configuration for a cluster. MonitorConfig 表示集群的监控配置。 Requirements: 5.2 - Monitor configuration model
func DefaultMonitorConfig ¶
func DefaultMonitorConfig(clusterID uint) *MonitorConfig
DefaultMonitorConfig returns the default monitor configuration. DefaultMonitorConfig 返回默认的监控配置。 Requirements: 5.2 - Default config for new clusters **Feature: seatunnel-process-monitor, Property 14: 新集群默认配置** **Validates: Requirements 5.2**
func (MonitorConfig) TableName ¶
func (MonitorConfig) TableName() string
TableName specifies the table name for MonitorConfig. TableName 指定 MonitorConfig 的表名。
type NodeInfoForMonitor ¶
type NodeInfoForMonitor struct {
HostID uint `json:"host_id"`
AgentID string `json:"agent_id"`
InstallDir string `json:"install_dir"`
Role string `json:"role"`
ProcessPID int `json:"process_pid"`
}
NodeInfoForMonitor represents node info needed for monitoring. NodeInfoForMonitor 表示监控所需的节点信息。
type ProcessEvent ¶
type ProcessEvent struct {
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
ClusterID uint `json:"cluster_id" gorm:"index"` // 关联的集群 ID / Associated cluster ID
NodeID uint `json:"node_id" gorm:"index"` // 关联的节点 ID / Associated node ID
HostID uint `json:"host_id" gorm:"index"` // 关联的主机 ID / Associated host ID
EventType ProcessEventType `json:"event_type" gorm:"size:30;index"` // 事件类型 / Event type
PID int `json:"pid"` // 进程 PID / Process PID
ProcessName string `json:"process_name" gorm:"size:100"` // 进程名称 / Process name
InstallDir string `json:"install_dir" gorm:"size:255"` // 安装目录 / Install directory
Role string `json:"role" gorm:"size:20"` // 节点角色 / Node role
Details string `json:"details" gorm:"type:text"` // 事件详情(JSON)/ Event details (JSON)
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime;index"` // 事件时间 / Event time
}
ProcessEvent represents a process lifecycle event. ProcessEvent 表示进程生命周期事件。 Requirements: 6.1, 6.2 - Process event model
func (ProcessEvent) TableName ¶
func (ProcessEvent) TableName() string
TableName specifies the table name for ProcessEvent. TableName 指定 ProcessEvent 的表名。
type ProcessEventFilter ¶
type ProcessEventFilter struct {
ClusterID uint `json:"cluster_id"`
NodeID uint `json:"node_id"`
HostID uint `json:"host_id"`
EventType ProcessEventType `json:"event_type"`
StartTime *time.Time `json:"start_time"`
EndTime *time.Time `json:"end_time"`
Page int `json:"page"`
PageSize int `json:"page_size"`
}
ProcessEventFilter represents filter criteria for querying process events. ProcessEventFilter 表示查询进程事件的过滤条件。
type ProcessEventType ¶
type ProcessEventType string
ProcessEventType represents the type of process event. ProcessEventType 表示进程事件类型。
const ( // EventTypeStarted indicates the process has started. // EventTypeStarted 表示进程已启动。 EventTypeStarted ProcessEventType = "started" // EventTypeStopped indicates the process has stopped normally. // EventTypeStopped 表示进程已正常停止。 EventTypeStopped ProcessEventType = "stopped" // EventTypeCrashed indicates the process has crashed unexpectedly. // EventTypeCrashed 表示进程意外崩溃。 EventTypeCrashed ProcessEventType = "crashed" // EventTypeRestarted indicates the process has been auto-restarted. // EventTypeRestarted 表示进程已被自动重启。 EventTypeRestarted ProcessEventType = "restarted" // EventTypeRestartFailed indicates the auto-restart attempt failed. // EventTypeRestartFailed 表示自动重启尝试失败。 EventTypeRestartFailed ProcessEventType = "restart_failed" // EventTypeRestartLimitReached indicates the restart limit has been reached. // EventTypeRestartLimitReached 表示已达到重启次数上限。 EventTypeRestartLimitReached ProcessEventType = "restart_limit_reached" // EventTypeClusterRestartRequested indicates a manual cluster restart request was issued. // EventTypeClusterRestartRequested 表示触发了一次手动重启请求(集群或节点)。 EventTypeClusterRestartRequested ProcessEventType = "cluster_restart_requested" // EventTypeNodeRestartRequested indicates a manual node restart request was issued. // EventTypeNodeRestartRequested 表示触发了一次手动节点重启请求。 EventTypeNodeRestartRequested ProcessEventType = "node_restart_requested" // EventTypeNodeStopRequested indicates a manual node stop request was issued. // EventTypeNodeStopRequested 表示触发了一次手动节点停止请求。 EventTypeNodeStopRequested ProcessEventType = "node_stop_requested" // EventTypeNodeOffline indicates one managed node has remained unavailable beyond the grace window. // EventTypeNodeOffline 表示某个受管节点在宽限窗口后仍处于不可用状态。 EventTypeNodeOffline ProcessEventType = "node_offline" // EventTypeNodeRecovered indicates one node-offline episode has ended and the node is healthy again. // EventTypeNodeRecovered 表示某个节点离线告警阶段已经结束,节点重新恢复健康。 EventTypeNodeRecovered ProcessEventType = "node_recovered" )
type ProcessEventWithHost ¶
type ProcessEventWithHost struct {
ProcessEvent
Hostname string `json:"hostname"` // 主机名 / Hostname
IP string `json:"ip"` // 主机 IP / Host IP
}
ProcessEventWithHost represents a process event with host information. ProcessEventWithHost 表示带有主机信息的进程事件。
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository provides data access for monitor configurations and events. Repository 提供监控配置和事件的数据访问。
func NewRepository ¶
func NewRepository(db *gorm.DB) *Repository
NewRepository creates a new monitor repository. NewRepository 创建新的监控仓库。
func (*Repository) CountEventsByType ¶
func (r *Repository) CountEventsByType(ctx context.Context, clusterID uint, eventType ProcessEventType, since *time.Time) (int64, error)
CountEventsByType counts events by type for a cluster within a time range. CountEventsByType 统计集群在时间范围内按类型分组的事件数量。
func (*Repository) CreateConfig ¶
func (r *Repository) CreateConfig(ctx context.Context, config *MonitorConfig) error
CreateConfig creates a new monitor configuration. CreateConfig 创建新的监控配置。
func (*Repository) CreateEvent ¶
func (r *Repository) CreateEvent(ctx context.Context, event *ProcessEvent) error
CreateEvent creates a new process event. CreateEvent 创建新的进程事件。
func (*Repository) DeleteConfigByClusterID ¶
func (r *Repository) DeleteConfigByClusterID(ctx context.Context, clusterID uint) error
DeleteConfigByClusterID deletes monitor config by cluster ID. DeleteConfigByClusterID 根据集群 ID 删除监控配置。
func (*Repository) DeleteEventsByClusterID ¶
func (r *Repository) DeleteEventsByClusterID(ctx context.Context, clusterID uint) error
DeleteEventsByClusterID deletes all events for a cluster. DeleteEventsByClusterID 删除集群的所有事件。
func (*Repository) GetConfigByClusterID ¶
func (r *Repository) GetConfigByClusterID(ctx context.Context, clusterID uint) (*MonitorConfig, error)
GetConfigByClusterID retrieves monitor config by cluster ID. GetConfigByClusterID 根据集群 ID 获取监控配置。
func (*Repository) GetEventByID ¶
func (r *Repository) GetEventByID(ctx context.Context, id uint) (*ProcessEvent, error)
GetEventByID retrieves a process event by ID. GetEventByID 根据 ID 获取进程事件。
func (*Repository) GetLatestEventByNodeID ¶
func (r *Repository) GetLatestEventByNodeID(ctx context.Context, nodeID uint) (*ProcessEvent, error)
GetLatestEventByNodeID retrieves the latest event for a node. GetLatestEventByNodeID 获取节点的最新事件。
func (*Repository) GetLatestEventByNodeIDAndTypes ¶
func (r *Repository) GetLatestEventByNodeIDAndTypes(ctx context.Context, nodeID uint, eventTypes []ProcessEventType) (*ProcessEvent, error)
GetLatestEventByNodeIDAndTypes retrieves the latest event for one node limited to specific event types. GetLatestEventByNodeIDAndTypes 获取某节点在指定事件类型集合中的最新事件。
func (*Repository) HasNodeEventAfter ¶
func (r *Repository) HasNodeEventAfter(ctx context.Context, nodeID uint, after time.Time, eventTypes []ProcessEventType) (bool, *ProcessEvent, error)
HasNodeEventAfter checks whether one node has any matching event after the specified time, returning the earliest matching event in that range. HasNodeEventAfter 检查某节点在指定时间之后是否存在匹配事件,并返回该时间段内最早的一条。
func (*Repository) ListEvents ¶
func (r *Repository) ListEvents(ctx context.Context, filter *ProcessEventFilter) ([]*ProcessEvent, int64, error)
ListEvents retrieves process events with filtering and pagination. ListEvents 获取带过滤和分页的进程事件列表。
func (*Repository) ListEventsByClusterID ¶
func (r *Repository) ListEventsByClusterID(ctx context.Context, clusterID uint, limit int) ([]*ProcessEvent, error)
ListEventsByClusterID retrieves all events for a cluster. ListEventsByClusterID 获取集群的所有事件。
func (*Repository) ListEventsWithHost ¶
func (r *Repository) ListEventsWithHost(ctx context.Context, filter *ProcessEventFilter) ([]*ProcessEventWithHost, int64, error)
ListEventsWithHost retrieves process events with host information. ListEventsWithHost 获取带主机信息的进程事件列表。
func (*Repository) UpdateConfig ¶
func (r *Repository) UpdateConfig(ctx context.Context, config *MonitorConfig) error
UpdateConfig updates an existing monitor configuration. UpdateConfig 更新现有的监控配置。
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides monitor configuration and event management. Service 提供监控配置和事件管理。
func NewService ¶
func NewService(repo *Repository) *Service
NewService creates a new monitor service. NewService 创建新的监控服务。
func (*Service) DeleteClusterEvents ¶
DeleteClusterEvents deletes all events for a cluster. DeleteClusterEvents 删除集群的所有事件。
func (*Service) DeleteConfig ¶
DeleteConfig deletes monitor config for a cluster. DeleteConfig 删除集群的监控配置。
func (*Service) GetConfig ¶
GetConfig retrieves monitor config for a cluster. GetConfig 获取集群的监控配置。 Requirements: 5.2 - Get monitor config
func (*Service) GetEventStats ¶
func (s *Service) GetEventStats(ctx context.Context, clusterID uint, since *time.Time) (map[ProcessEventType]int64, error)
GetEventStats retrieves event statistics for a cluster. GetEventStats 获取集群的事件统计。
func (*Service) GetLatestNodeEvent ¶
GetLatestNodeEvent retrieves the latest event for a node. GetLatestNodeEvent 获取节点的最新事件。
func (*Service) GetLatestNodeEventByTypes ¶
func (s *Service) GetLatestNodeEventByTypes(ctx context.Context, nodeID uint, eventTypes []ProcessEventType) (*ProcessEvent, error)
GetLatestNodeEventByTypes retrieves the latest node event within the given event types. GetLatestNodeEventByTypes 获取某节点在指定事件类型集合中的最新事件。
func (*Service) GetOrCreateConfig ¶
GetOrCreateConfig retrieves or creates default monitor config for a cluster. GetOrCreateConfig 获取或创建集群的默认监控配置。 Requirements: 5.2, 5.7 - Get or create default config **Feature: seatunnel-process-monitor, Property 14: 新集群默认配置** **Validates: Requirements 5.2**
func (*Service) HasNodeEventAfter ¶
func (s *Service) HasNodeEventAfter(ctx context.Context, nodeID uint, after time.Time, eventTypes []ProcessEventType) (bool, *ProcessEvent, error)
HasNodeEventAfter returns whether one node has any matching event after the given time. HasNodeEventAfter 返回某节点在给定时间之后是否存在匹配事件。
func (*Service) ListClusterEvents ¶
func (s *Service) ListClusterEvents(ctx context.Context, clusterID uint, limit int) ([]*ProcessEvent, error)
ListClusterEvents retrieves recent events for a cluster. ListClusterEvents 获取集群的最近事件。
func (*Service) ListEvents ¶
func (s *Service) ListEvents(ctx context.Context, filter *ProcessEventFilter) ([]*ProcessEventWithHost, int64, error)
ListEvents retrieves process events with filtering. ListEvents 获取带过滤的进程事件列表。 Requirements: 6.4 - List process events
func (*Service) MarkConfigSynced ¶
MarkConfigSynced marks the config as synced to agents. MarkConfigSynced 标记配置已同步到 Agent。
func (*Service) PushDisableConfigForCluster ¶
PushDisableConfigForCluster pushes a config with auto_monitor=false and auto_restart=false to all agents that have nodes in this cluster, so they stop monitoring and won't restart processes. Call before deleting the cluster so agents are notified. PushDisableConfigForCluster 向该集群下所有 Agent 推送关闭监控的配置,使 Agent 停止监控且不再重启进程;删除集群前调用以通知 Agent。
func (*Service) RecordEvent ¶
func (s *Service) RecordEvent(ctx context.Context, event *ProcessEvent) error
RecordEvent records a new process event. RecordEvent 记录新的进程事件。 Requirements: 6.1 - Record process events
func (*Service) RecordEventFromReport ¶
func (s *Service) RecordEventFromReport(ctx context.Context, clusterID, nodeID, hostID uint, eventType ProcessEventType, pid int, processName, installDir, role string, details map[string]string) error
RecordEventFromReport records an event from agent report. RecordEventFromReport 从 Agent 上报记录事件。 Requirements: 3.4, 3.5 - Process event from agent
func (*Service) SetConfigSender ¶
func (s *Service) SetConfigSender(sender AgentConfigSender)
SetConfigSender sets the agent config sender. SetConfigSender 设置 Agent 配置发送器。
func (*Service) SetNodeProvider ¶
func (s *Service) SetNodeProvider(provider ClusterNodeProvider)
SetNodeProvider sets the cluster node provider. SetNodeProvider 设置集群节点提供者。
func (*Service) SetOnEventRecorded ¶
func (s *Service) SetOnEventRecorded(fn func(context.Context, *ProcessEvent) error)
SetOnEventRecorded sets an optional hook invoked after a process event is persisted. SetOnEventRecorded 设置进程事件落库后的可选回调。
func (*Service) UpdateConfig ¶
func (s *Service) UpdateConfig(ctx context.Context, clusterID uint, req *UpdateMonitorConfigRequest) (*MonitorConfig, error)
UpdateConfig updates monitor config for a cluster. UpdateConfig 更新集群的监控配置。 Requirements: 5.4 - Update monitor config **Feature: seatunnel-process-monitor, Property 13: 配置热更新** **Validates: Requirements 5.5**
type TrackedProcessInfo ¶
type TrackedProcessInfo struct {
PID int `json:"pid"` // 进程 PID / Process PID
Name string `json:"name"` // 进程名称 / Process name (e.g., "seatunnel-master")
InstallDir string `json:"install_dir"` // 安装目录 / Install directory
Role string `json:"role"` // 节点角色 / Node role
}
TrackedProcessInfo represents a process to be tracked by the agent. TrackedProcessInfo 表示需要被 Agent 跟踪的进程信息。
type UpdateMonitorConfigRequest ¶
type UpdateMonitorConfigRequest struct {
AutoMonitor *bool `json:"auto_monitor"`
AutoRestart *bool `json:"auto_restart"`
MonitorInterval *int `json:"monitor_interval"`
RestartDelay *int `json:"restart_delay"`
MaxRestarts *int `json:"max_restarts"`
TimeWindow *int `json:"time_window"`
CooldownPeriod *int `json:"cooldown_period"`
}
UpdateMonitorConfigRequest represents a request to update monitor config. UpdateMonitorConfigRequest 表示更新监控配置的请求。 Requirements: 5.3 - Update monitor config request
func (*UpdateMonitorConfigRequest) Validate ¶
func (r *UpdateMonitorConfigRequest) Validate() error
Validate validates the update request. Validate 验证更新请求。 Requirements: 5.7 - Config validation **Feature: seatunnel-process-monitor, Property 12: 监控配置验证** **Validates: Requirements 5.7**