Files
aiops/backend/internal/models/ops_modules.go
T
attacker 5949ec5d0c feat: Agent采集uptime, 后端持久化kernel/uptime/diskIO, 前端磁盘BPS+IOPS展示
- Agent: system.go 添加 readUptime(), SystemStat 携带 Uptime
- Backend: Server 模型新增 Kernel 字段, ReceiveReport 持久化 kernel+uptime
- Backend: /agent/latest 返回 kernel/uptime/port_info/disk_io_info/disk_total
- Frontend: 磁盘监控改为 BPS+IOPS (4张卡片), 系统信息修复内核/运行时长/监听端口/磁盘容量
- 图表单位从 MB/s 改为 KB/s, 添加 formatBPS 工具函数
2026-06-19 01:10:00 +00:00

85 lines
3.8 KiB
Go

package models
import (
"time"
)
// AnsiblePlaybook Playbook 模型 // Logan.Li
type AnsiblePlaybook struct {
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:255;not null" json:"name"`
Description string `gorm:"type:text" json:"description"`
Content string `gorm:"type:text;not null" json:"content"` // YAML 内容
Tags string `gorm:"size:500" json:"tags"` // 逗号分隔
Category string `gorm:"size:100" json:"category"` // deployment/maintenance/etc
CreatedBy string `gorm:"size:255" json:"created_by"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (AnsiblePlaybook) TableName() string { return "ops_ansible_playbooks" }
// AnsibleJob 执行任务记录 // Logan.Li
type AnsibleJob struct {
ID uint `gorm:"primarykey" json:"id"`
PlaybookID uint `gorm:"not null" json:"playbook_id"`
PlaybookName string `gorm:"size:255" json:"playbook_name"`
Status string `gorm:"size:20;default:pending" json:"status"` // pending/running/success/failed
TargetHosts string `gorm:"type:text" json:"target_hosts"` // JSON 数组
Variables string `gorm:"type:text" json:"variables"` // JSON
Output string `gorm:"type:text" json:"output"`
Duration int64 `gorm:"default:0" json:"duration"` // 毫秒
TriggeredBy string `gorm:"size:255" json:"triggered_by"`
StartedAt *time.Time `json:"started_at"`
CompletedAt *time.Time `json:"completed_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (AnsibleJob) TableName() string { return "ops_ansible_jobs" }
// AnsibleInventory 主机清单 // Logan.Li
type AnsibleInventory struct {
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:255;not null" json:"name"`
Description string `gorm:"type:text" json:"description"`
Hosts string `gorm:"type:text" json:"hosts"` // JSON 数组 [{name,ip,port,user,os}]
CreatedBy string `gorm:"size:255" json:"created_by"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (AnsibleInventory) TableName() string { return "ops_ansible_inventories" }
// LogSource 日志源 // Logan.Li
type LogSource struct {
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:255;not null" json:"name"`
Type string `gorm:"size:50;not null" json:"type"` // application/syslog/docker/kubernetes
Status string `gorm:"size:20;default:active" json:"status"`
Config string `gorm:"type:text" json:"config"` // JSON {path/pattern}
LogCount int64 `gorm:"default:0" json:"log_count"`
LastSeen *time.Time `json:"last_seen"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (LogSource) TableName() string { return "sys_log_sources" }
// LogEntry 日志条目 // Logan.Li
type LogEntry struct {
ID uint `gorm:"primarykey" json:"id"`
SourceID uint `gorm:"index" json:"source_id"`
Timestamp time.Time `gorm:"index" json:"timestamp"`
Level string `gorm:"size:20;index" json:"level"` // error/warn/info/debug
Service string `gorm:"size:255;index" json:"service"`
Host string `gorm:"size:255;index" json:"host"`
Message string `gorm:"type:text" json:"message"`
TraceID string `gorm:"size:100;index" json:"trace_id"`
Raw string `gorm:"type:text" json:"raw"`
CreatedAt time.Time `json:"created_at"`
}
func (LogEntry) TableName() string { return "sys_log_entries" }