Documentation
¶
Overview ¶
Package dashboard provides dashboard statistics for the STX system. dashboard 包提供 STX 系统的仪表盘统计功能。
Index ¶
- type ClusterSummary
- type DashboardDataResponse
- type HostSummary
- type OverviewData
- type OverviewHandler
- type OverviewService
- func (s *OverviewService) GetClusterSummaries(ctx context.Context, limit int) ([]*ClusterSummary, error)
- func (s *OverviewService) GetHostSummaries(ctx context.Context, limit int) ([]*HostSummary, error)
- func (s *OverviewService) GetOverviewData(ctx context.Context) (*OverviewData, error)
- func (s *OverviewService) GetOverviewStats(ctx context.Context) (*OverviewStats, error)
- func (s *OverviewService) GetRecentActivities(ctx context.Context, limit int) ([]*RecentActivity, error)
- type OverviewStats
- type RecentActivity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClusterSummary ¶
type ClusterSummary struct {
ID uint `json:"id"`
Name string `json:"name"`
Status string `json:"status"` // DB status; display as "unhealthy" when running but 0 online
DeploymentMode string `json:"deployment_mode"`
TotalNodes int `json:"total_nodes"`
MasterNodes int `json:"master_nodes"`
WorkerNodes int `json:"worker_nodes"`
RunningNodes int `json:"running_nodes"` // nodes with status running AND host online
OnlineNodes int `json:"online_nodes"` // number of nodes whose host is online
}
ClusterSummary represents a cluster summary for dashboard. ClusterSummary 表示仪表盘的集群摘要。
type DashboardDataResponse ¶
type DashboardDataResponse struct {
ErrorMsg string `json:"error_msg"`
Data interface{} `json:"data"`
}
DashboardDataResponse is the common API envelope used by dashboard handlers. DashboardDataResponse 是 dashboard handler 统一使用的响应结构。
type HostSummary ¶
type HostSummary struct {
ID uint `json:"id"`
Name string `json:"name"`
IPAddress string `json:"ip_address"`
IsOnline bool `json:"is_online"`
AgentStatus string `json:"agent_status"`
NodeCount int `json:"node_count"`
}
HostSummary represents a host summary for dashboard. HostSummary 表示仪表盘的主机摘要。
type OverviewData ¶
type OverviewData struct {
Stats *OverviewStats `json:"stats"`
ClusterSummaries []*ClusterSummary `json:"cluster_summaries"`
HostSummaries []*HostSummary `json:"host_summaries"`
RecentActivities []*RecentActivity `json:"recent_activities"`
}
OverviewData represents the complete dashboard overview data. OverviewData 表示完整的仪表盘概览数据。
type OverviewHandler ¶
type OverviewHandler struct {
// contains filtered or unexported fields
}
OverviewHandler handles dashboard overview HTTP requests. OverviewHandler 处理仪表盘概览 HTTP 请求。
func NewOverviewHandler ¶
func NewOverviewHandler(service *OverviewService) *OverviewHandler
NewOverviewHandler creates a new dashboard overview handler. NewOverviewHandler 创建新的仪表盘概览处理器。
func (*OverviewHandler) GetClusterSummaries ¶
func (h *OverviewHandler) GetClusterSummaries(c *gin.Context)
GetClusterSummaries godoc @Summary Get cluster summaries @Description Get cluster summaries for dashboard @Tags Dashboard @Accept json @Produce json @Param limit query int false "Limit" default(5) @Success 200 {object} DashboardDataResponse{data=[]ClusterSummary} @Failure 500 {object} DashboardDataResponse @Router /api/v1/dashboard/overview/clusters [get]
func (*OverviewHandler) GetHostSummaries ¶
func (h *OverviewHandler) GetHostSummaries(c *gin.Context)
GetHostSummaries godoc @Summary Get host summaries @Description Get host summaries for dashboard @Tags Dashboard @Accept json @Produce json @Param limit query int false "Limit" default(5) @Success 200 {object} DashboardDataResponse{data=[]HostSummary} @Failure 500 {object} DashboardDataResponse @Router /api/v1/dashboard/overview/hosts [get]
func (*OverviewHandler) GetOverviewData ¶
func (h *OverviewHandler) GetOverviewData(c *gin.Context)
GetOverviewData godoc @Summary Get complete dashboard overview data @Description Get complete dashboard overview data including stats, clusters, hosts, and activities @Tags Dashboard @Accept json @Produce json @Success 200 {object} DashboardDataResponse{data=OverviewData} @Failure 500 {object} DashboardDataResponse @Router /api/v1/dashboard/overview [get]
func (*OverviewHandler) GetOverviewStats ¶
func (h *OverviewHandler) GetOverviewStats(c *gin.Context)
GetOverviewStats godoc @Summary Get dashboard overview statistics @Description Get dashboard overview statistics including hosts, clusters, nodes, and agents @Tags Dashboard @Accept json @Produce json @Success 200 {object} DashboardDataResponse{data=OverviewStats} @Failure 500 {object} DashboardDataResponse @Router /api/v1/dashboard/overview/stats [get]
func (*OverviewHandler) GetRecentActivities ¶
func (h *OverviewHandler) GetRecentActivities(c *gin.Context)
GetRecentActivities godoc @Summary Get recent activities @Description Get recent audit log activities for dashboard @Tags Dashboard @Accept json @Produce json @Param limit query int false "Limit" default(10) @Success 200 {object} DashboardDataResponse{data=[]RecentActivity} @Failure 500 {object} DashboardDataResponse @Router /api/v1/dashboard/overview/activities [get]
type OverviewService ¶
type OverviewService struct {
// contains filtered or unexported fields
}
OverviewService provides dashboard overview statistics.
func NewOverviewService ¶
func NewOverviewService(hostRepo *host.Repository, clusterRepo *cluster.Repository, auditRepo *audit.Repository, heartbeatTimeout time.Duration, processStartedAt time.Time) *OverviewService
NewOverviewService creates a new dashboard overview service. processStartedAt is used so hosts are not shown online until at least one heartbeat is received after platform start.
func (*OverviewService) GetClusterSummaries ¶
func (s *OverviewService) GetClusterSummaries(ctx context.Context, limit int) ([]*ClusterSummary, error)
GetClusterSummaries returns cluster summaries for dashboard.
func (*OverviewService) GetHostSummaries ¶
func (s *OverviewService) GetHostSummaries(ctx context.Context, limit int) ([]*HostSummary, error)
GetHostSummaries returns host summaries for dashboard.
func (*OverviewService) GetOverviewData ¶
func (s *OverviewService) GetOverviewData(ctx context.Context) (*OverviewData, error)
GetOverviewData returns complete dashboard overview data.
func (*OverviewService) GetOverviewStats ¶
func (s *OverviewService) GetOverviewStats(ctx context.Context) (*OverviewStats, error)
GetOverviewStats returns dashboard overview statistics.
func (*OverviewService) GetRecentActivities ¶
func (s *OverviewService) GetRecentActivities(ctx context.Context, limit int) ([]*RecentActivity, error)
GetRecentActivities returns recent audit log activities.
type OverviewStats ¶
type OverviewStats struct {
// Host statistics / 主机统计
TotalHosts int `json:"total_hosts"`
OnlineHosts int `json:"online_hosts"`
// Cluster statistics / 集群统计
TotalClusters int `json:"total_clusters"`
RunningClusters int `json:"running_clusters"`
StoppedClusters int `json:"stopped_clusters"`
ErrorClusters int `json:"error_clusters"`
// Node statistics / 节点统计
TotalNodes int `json:"total_nodes"`
RunningNodes int `json:"running_nodes"`
StoppedNodes int `json:"stopped_nodes"`
ErrorNodes int `json:"error_nodes"`
// Agent statistics / Agent 统计
TotalAgents int `json:"total_agents"`
OnlineAgents int `json:"online_agents"`
}
OverviewStats represents the dashboard overview statistics. OverviewStats 表示仪表盘概览统计数据。
type RecentActivity ¶
type RecentActivity struct {
ID uint `json:"id"`
Type string `json:"type"` // success, warning, info, error
Operator string `json:"operator"`
Source string `json:"source"`
Action string `json:"action"`
// Message is kept for backward compatibility; prefer Operator/Source/Action.
// Message 保留兼容旧客户端;优先使用 Operator/Source/Action。
Message string `json:"message,omitempty"`
Timestamp string `json:"timestamp"`
}
RecentActivity represents a recent activity log entry. RecentActivity 表示最近活动日志条目。