lua

package
v0.0.149 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const TriggerTypeCron = "cron"

TriggerTypeCron 表示定时触发

View Source
const TriggerTypeManual = "manual"

TriggerTypeManual 表示手动触发

Variables

This section is empty.

Functions

func InitClusterInspection

func InitClusterInspection()

Types

type CheckEvent

type CheckEvent struct {
	Status     string                 `json:"status"` // 检查状态(如“正常”、“失败”)
	Msg        string                 `json:"msg"`
	Extra      map[string]interface{} `json:"extra,omitempty"`
	ScriptName string                 `json:"scriptName"` // 检测脚本名称
	Kind       string                 `json:"kind"`       // 检查的资源类型
	CheckDesc  string                 `json:"checkDesc"`  // 检查脚本内容描述
	Namespace  string                 `json:"ns"`         // 资源命名空间
	Name       string                 `json:"name"`       // 资源名称
}

CheckEvent 用于记录每次检测的详细信息,包括检测状态、消息、额外上下文、脚本名称、资源类型、描述、命名空间和资源名。

type CheckResult

type CheckResult struct {
	Name         string
	StartTime    time.Time
	EndTime      time.Time
	LuaRunOutput string
	LuaRunError  error
	Events       []CheckEvent
}

type Inspection

type Inspection struct {
	Cluster string // 集群名称

	Schedule *models.InspectionSchedule // 巡检计划ID
	// contains filtered or unexported fields
}

func NewLuaInspection

func NewLuaInspection(schedule *models.InspectionSchedule, cluster string) *Inspection

func (*Inspection) Start

func (p *Inspection) Start() []CheckResult

type Kubectl

type Kubectl struct {
	// contains filtered or unexported fields
}

type ScheduleBackground

type ScheduleBackground struct {
}

func (*ScheduleBackground) Add

func (s *ScheduleBackground) Add(scheduleID uint)

func (*ScheduleBackground) GetSummaryMsg added in v0.0.132

func (s *ScheduleBackground) GetSummaryMsg(recordID uint) (map[string]any, error)

func (*ScheduleBackground) IsEventStatusPass

func (s *ScheduleBackground) IsEventStatusPass(status string) bool

IsEventStatusPass 判断事件状态是否为通过 这里的通过状态包括:正常、pass、ok、success、通过 入库前将状态描述文字统一为正常、失败两种

func (*ScheduleBackground) PushToHooksByRecordID added in v0.0.130

func (s *ScheduleBackground) PushToHooksByRecordID(recordID uint) ([]*webhook.SendResult, error)

func (*ScheduleBackground) Remove

func (s *ScheduleBackground) Remove(scheduleID uint)

func (*ScheduleBackground) RunByCluster

func (s *ScheduleBackground) RunByCluster(ctx context.Context, scheduleID *uint, cluster string, triggerType string) (*models.InspectionRecord, error)

RunByCluster 启动一次巡检任务,并记录执行及每个脚本的结果到数据库 scheduleID: 可选,定时任务ID(手动触发时为nil) cluster: 目标集群 triggerType: 触发类型(manual/cron)

func (*ScheduleBackground) SaveSummaryBack added in v0.0.132

func (s *ScheduleBackground) SaveSummaryBack(id uint, summary string) error

func (*ScheduleBackground) StartFromDB

func (s *ScheduleBackground) StartFromDB()

StartFromDB 后台自动执行调度

func (*ScheduleBackground) SummaryAndPushToHooksByRecordID added in v0.0.130

func (s *ScheduleBackground) SummaryAndPushToHooksByRecordID(ctx context.Context, recordID uint) ([]*webhook.SendResult, error)

func (*ScheduleBackground) SummaryByAI added in v0.0.130

func (s *ScheduleBackground) SummaryByAI(ctx context.Context, msg map[string]any, format string) (string, error)

SummaryByAI 参数:format 自定义格式

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL