nexserver

package
v0.2.1-0...-6d22bef Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2019 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName          = "NexServer"
	AppDescription   = "NexServer for NexClipper Monitoring System"
	NexServerVersion = "0.3.0"
	ConfigFilename   = "nexserver.yaml"
)

Variables

This section is empty.

Functions

func Migrate

func Migrate(host string, port int, user string, password string, dbname string, sslmode string) error

Types

type Agent

type Agent struct {
	gorm.Model

	Online     bool
	Version    string `gorm:"size:32"`
	Ipv4       string `gorm:"size:16"`
	Ipv6       string `gorm:"size:40"`
	PublicIpv4 string `gorm:"size:16"`
	PublicIpv6 string `gorm:"size:40"`

	LastContact time.Time
	Disabled    bool
	Uuid        string `gorm:"size:36;unique_index"`
	MachineID   string `gorm:"size:70;unique_index"`
	Description string

	ClusterID uint `gorm:"index"`
	Node      Node
}

type BasicRuleConfig

type BasicRuleConfig struct {
	NodeCpuLoad1   float64
	NodeMemoryFree float64
	NodeDiskFree   float64
}

type Cluster

type Cluster struct {
	gorm.Model

	Name        string `gorm:"size:128"`
	Description string
	Disabled    bool

	Agents []Agent
	Nodes  []Node
}

type Config

type Config struct {
	Server    ServerConfig
	Database  DatabaseConfig
	TLS       TLSConfig
	BasicRule BasicRuleConfig
}

type Container

type Container struct {
	gorm.Model

	Type        string `gorm:"size:32"`
	ContainerID string `gorm:"size:128;index"`
	Name        string `gorm:"size:256"`
	Image       string `gorm:"size:128"`
	Info        postgres.Jsonb

	ClusterID uint `gorm:"index"`
	NodeID    uint `gorm:"index"`
	Processes []Process
}

type DatabaseConfig

type DatabaseConfig struct {
	Host     string
	Port     int
	User     string
	Password string
	DbName   string
	SslMode  string
}

type Event

type Event struct {
	Ts    time.Time
	Value string

	Acked   bool
	AckedTs time.Time

	EndpointID uint
	TypeID     uint
	NameID     uint
	LabelID    uint

	ClusterID   uint
	AgentID     uint
	NodeID      uint
	ProcessID   uint
	ContainerID uint
	PodID       uint
}

type Incident

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

type IncidentBasicRule

type IncidentBasicRule struct {
	gorm.Model

	Name        string
	Description string
	Query       string
}

type IncidentItem

type IncidentItem struct {
	ClusterId   uint
	NodeId      uint
	ProcessId   uint
	ContainerId uint
	PodId       uint
	TargetType  string
	Target      string
	Value       float64
	Condition   float64
	EventName   string
	ReportedTs  time.Time
	DetectedTs  time.Time
}

type K8sCluster

type K8sCluster struct {
	gorm.Model

	Name           string `gorm:"size:128:index"`
	AgentClusterID uint
}

type K8sConnector

type K8sConnector struct {
	gorm.Model

	Name        string `gorm:"size:128;index"`
	Status      string `gorm:"size:32"`
	Method      string `gorm:"size:32"`
	InCluster   bool
	BearerToken string
	KubeConfig  string
}

type K8sContainer

type K8sContainer struct {
	gorm.Model

	Name          string `gorm:"size:256"`
	Image         string `gorm:"size:256"`
	ContainerType string `gorm:"size64"`
	ContainerId   string `gorm:"size:256"`

	K8sClusterID   uint
	K8sNamespaceID uint
	K8sPodID       uint
}

type K8sDaemonSet

type K8sDaemonSet struct {
	gorm.Model

	Name string `gorm:"size:256"`

	K8sClusterID   uint
	K8sNamespaceID uint
	K8sObjectID    uint
}

type K8sDeployment

type K8sDeployment struct {
	gorm.Model

	Name string `gorm:"size:256"`

	K8sClusterID   uint
	K8sNamespaceID uint
	K8sObjectID    uint
}

type K8sEvent

type K8sEvent struct {
	Ts    time.Time
	Value string

	EndpointID uint
	TypeID     uint
	NameID     uint
	LabelID    uint

	ClusterID   uint
	NamespaceID uint
	NodeID      uint
	PodID       uint
	ContainerID uint
}

type K8sLabel

type K8sLabel struct {
	gorm.Model

	Label string `gorm:"size:256;index"`

	K8sObjectID uint
}

type K8sMetric

type K8sMetric struct {
	Ts    time.Time
	Value float64

	EndpointID uint
	TypeID     uint
	NameID     uint
	LabelID    uint

	K8sClusterID   uint
	K8sNodeID      uint
	K8sNamespaceID uint
	K8sPodID       uint
	K8sContainerID uint
}

type K8sNamespace

type K8sNamespace struct {
	gorm.Model

	Name string `gorm:"size:128"`

	K8sClusterID uint
	K8sObjectID  uint
}

type K8sNode

type K8sNode struct {
	gorm.Model

	Name string `gorm:"size:128"`

	K8sClusterID uint
	K8sObjectID  uint
}

type K8sObject

type K8sObject struct {
	gorm.Model

	K8sClusterID uint

	ApiVersion string `gorm:"size:128"`
	Kind       string `gorm:"size:128"`
	Name       string `gorm:"size:256"`

	Metadata postgres.Jsonb
	Spec     postgres.Jsonb
	Status   postgres.Jsonb
}

type K8sObjectTag

type K8sObjectTag struct {
	gorm.Model

	K8sObjectID uint
	K8sLabelID  uint
}

type K8sPod

type K8sPod struct {
	gorm.Model

	Name string `gorm:"size:256"`
	Qos  string `gorm:"size:32"`

	K8sClusterID   uint
	K8sNamespaceID uint
	K8sObjectID    uint
}

type K8sReplicaSet

type K8sReplicaSet struct {
	gorm.Model

	Name string `gorm:"size:256"`

	K8sClusterID    uint
	K8sNamespaceID  uint
	K8sDeploymentID uint
	K8sObjectID     uint
}

type K8sStatefulSet

type K8sStatefulSet struct {
	gorm.Model

	Name string `gorm:"size:256"`

	K8sClusterID   uint
	K8sNamespaceID uint
	K8sObjectID    uint
}

type Metric

type Metric struct {
	Ts    time.Time `gorm:"index"`
	Value float64

	EndpointID uint `gorm:"index"`
	TypeID     uint `gorm:"index"`
	NameID     uint `gorm:"index"`
	LabelID    uint `gorm:"index"`

	ClusterID   uint `gorm:"index"`
	NodeID      uint `gorm:"index"`
	ProcessID   uint `gorm:"index"`
	ContainerID uint `gorm:"index"`
}

type MetricEndpoint

type MetricEndpoint struct {
	gorm.Model

	Path string `gorm:"size:256;unique_index"`

	Metrics []Metric
	Events  []Event
}

type MetricLabel

type MetricLabel struct {
	gorm.Model

	Label string `gorm:"size:256;unique_index"`

	Metrics []Metric
	Events  []Event
}

type MetricName

type MetricName struct {
	gorm.Model

	Name string `gorm:"size:256;unique_index"`
	Help string

	TypeID uint `gorm:"index"`

	Metrics []Metric
	Events  []Event
}

type MetricType

type MetricType struct {
	gorm.Model

	Name string `gorm:"size:32;unique_index"`

	MetricNames []MetricName
}

type NexServer

type NexServer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewNexServer

func NewNexServer() *NexServer

func (*NexServer) AddIncident

func (s *NexServer) AddIncident(eventName string, item *IncidentItem) bool

func (*NexServer) ApiAgentList

func (s *NexServer) ApiAgentList(c *gin.Context)

func (*NexServer) ApiAgentListAll

func (s *NexServer) ApiAgentListAll(c *gin.Context)

func (*NexServer) ApiClusterList

func (s *NexServer) ApiClusterList(c *gin.Context)

func (*NexServer) ApiHealth

func (s *NexServer) ApiHealth(c *gin.Context)

func (*NexServer) ApiIncidentBasic

func (s *NexServer) ApiIncidentBasic(c *gin.Context)

func (*NexServer) ApiMetricNameList

func (s *NexServer) ApiMetricNameList(c *gin.Context)

func (*NexServer) ApiMetricsClusterSummary

func (s *NexServer) ApiMetricsClusterSummary(c *gin.Context)

func (*NexServer) ApiMetricsContainers

func (s *NexServer) ApiMetricsContainers(c *gin.Context)

func (*NexServer) ApiMetricsNodes

func (s *NexServer) ApiMetricsNodes(c *gin.Context)

func (*NexServer) ApiMetricsPods

func (s *NexServer) ApiMetricsPods(c *gin.Context)

func (*NexServer) ApiMetricsProcesses

func (s *NexServer) ApiMetricsProcesses(c *gin.Context)

func (*NexServer) ApiNodeList

func (s *NexServer) ApiNodeList(c *gin.Context)

func (*NexServer) ApiNodeListAll

func (s *NexServer) ApiNodeListAll(c *gin.Context)

func (*NexServer) ApiResponseJson

func (s *NexServer) ApiResponseJson(c *gin.Context, code int, status, message string)

func (*NexServer) ApiSnapshotContainers

func (s *NexServer) ApiSnapshotContainers(c *gin.Context)

func (*NexServer) ApiSnapshotNodes

func (s *NexServer) ApiSnapshotNodes(c *gin.Context)

func (*NexServer) ApiSnapshotPods

func (s *NexServer) ApiSnapshotPods(c *gin.Context)

func (*NexServer) ApiSnapshotProcesses

func (s *NexServer) ApiSnapshotProcesses(c *gin.Context)

func (*NexServer) ApiStatus

func (s *NexServer) ApiStatus(c *gin.Context)

func (*NexServer) ApiSummaryClusters

func (s *NexServer) ApiSummaryClusters(c *gin.Context)

func (*NexServer) ApiSummaryNodes

func (s *NexServer) ApiSummaryNodes(c *gin.Context)

func (*NexServer) CheckNodeBasicIncident

func (s *NexServer) CheckNodeBasicIncident(nodeMetricChan chan Metric)

func (*NexServer) CheckRequiredParams

func (s *NexServer) CheckRequiredParams(c *gin.Context, params []string) (map[string]string, bool)

func (*NexServer) ClearAgentConnected

func (s *NexServer) ClearAgentConnected(clusterId, nodeId uint, hostName string)

func (*NexServer) ClearIncident

func (s *NexServer) ClearIncident(eventName string, item *IncidentItem) bool

func (*NexServer) ConnectDatabase

func (s *NexServer) ConnectDatabase() (*gorm.DB, error)

func (*NexServer) FireAgentDisconnected

func (s *NexServer) FireAgentDisconnected(clusterId, nodeId uint, hostName string)

func (*NexServer) InitBasicRuleChecker

func (s *NexServer) InitBasicRuleChecker()

func (*NexServer) IsExistIncident

func (s *NexServer) IsExistIncident(eventName string, item *IncidentItem) bool

func (*NexServer) IsSameIncident

func (s *NexServer) IsSameIncident(left, right *IncidentItem) bool

func (*NexServer) IsValidParams

func (s *NexServer) IsValidParams(clusterId string, query *Query, existDateRange bool, existMetricNames bool) bool

func (*NexServer) LoadConfig

func (s *NexServer) LoadConfig(configPath string) error

func (*NexServer) Param

func (s *NexServer) Param(c *gin.Context, key string) string

func (*NexServer) ParseQuery

func (s *NexServer) ParseQuery(c *gin.Context) *Query

func (*NexServer) Ping

func (s *NexServer) Ping(stream pb.Collector_PingServer) error

func (*NexServer) QueryRowsWithTime

func (s *NexServer) QueryRowsWithTime(q *gorm.DB) (*sql.Rows, error, time.Duration)

func (*NexServer) RemoveSpecialChar

func (s *NexServer) RemoveSpecialChar(key string) string

func (*NexServer) ReportContainerMetrics

func (s *NexServer) ReportContainerMetrics(ctx context.Context, in *pb.ContainerMetrics) (*pb.Response, error)

func (*NexServer) ReportK8SMetrics

func (s *NexServer) ReportK8SMetrics(ctx context.Context, in *pb.K8SMetrics) (*pb.Response, error)

func (*NexServer) ReportMetrics

func (s *NexServer) ReportMetrics(ctx context.Context, in *pb.Metrics) (*pb.Response, error)

func (*NexServer) ReportNodeMetrics

func (s *NexServer) ReportNodeMetrics(ctx context.Context, in *pb.NodeMetrics) (*pb.Response, error)

func (*NexServer) ReportProcessMetrics

func (s *NexServer) ReportProcessMetrics(ctx context.Context, in *pb.ProcessMetrics) (*pb.Response, error)

func (*NexServer) SetBasicRule

func (s *NexServer) SetBasicRule(nodeCpuLoad1, nodeDiskFree, nodeMemoryFree float64)

func (*NexServer) SetDatabaseConfig

func (s *NexServer) SetDatabaseConfig(dbHost string, dbPort int, dbUser, dbPass, dbName, dbSslMode string)

func (*NexServer) SetServerConfig

func (s *NexServer) SetServerConfig(bindAddress string, agentPort, apiPort int)

func (*NexServer) SetupApiHandler

func (s *NexServer) SetupApiHandler()

func (*NexServer) Start

func (s *NexServer) Start() error

func (*NexServer) UpdateAgent

func (s *NexServer) UpdateAgent(ctx context.Context, in *pb.Agent) (*pb.Response, error)

func (*NexServer) UpdateContainer

func (s *NexServer) UpdateContainer(ctx context.Context, in *pb.ContainerAll) (*pb.Response, error)

func (*NexServer) UpdateK8SCluster

func (s *NexServer) UpdateK8SCluster(ctx context.Context, in *pb.K8SCluster) (*pb.Response, error)

func (*NexServer) UpdateNode

func (s *NexServer) UpdateNode(ctx context.Context, in *pb.Node) (*pb.Response, error)

func (*NexServer) UpdateProcess

func (s *NexServer) UpdateProcess(ctx context.Context, in *pb.ProcessAll) (*pb.Response, error)

type Node

type Node struct {
	gorm.Model

	Host            string `gorm:"size:128"`
	Ipv4            string `gorm:"size:16"`
	Ipv6            string `gorm:"size:40"`
	PublicIpv4      string `gorm:"size:16"`
	PublicIpv6      string `gorm:"size:40"`
	Os              string `gorm:"size:64"`
	Platform        string `gorm:"size:64"`
	PlatformFamily  string `gorm:"size:64"`
	PlatformVersion string `gorm:"size:64"`
	Info            postgres.Jsonb
	Uuid            string `gorm:"size:36;unique_index"`
	Description     string
	Disabled        bool

	AgentID   uint `gorm:"index"`
	ClusterID uint `gorm:"index"`

	Containers []Container
	Processes  []Process
}

type Process

type Process struct {
	gorm.Model

	Name string `gorm:"size:256"`
	PID  int32  `gorm:"index"`
	Cmd  string
	Info postgres.Jsonb

	ClusterID   uint `gorm:"index"`
	NodeID      uint `gorm:"index"`
	ContainerID uint `gorm:"index"`
}

type Query

type Query struct {
	Timezone    string   `json:"timezone"`
	MetricNames []string `json:"metricNames"`
	DateRange   []string `json:"dateRange"`
	Granularity string   `json:"granularity"`
}

type ServerConfig

type ServerConfig struct {
	BindAddress     string
	AgentListenPort int
	ApiPort         int
}

type Setting

type Setting struct {
	gorm.Model

	Name  string `gorm:"size:128;index"`
	Value string
}

type TLSConfig

type TLSConfig struct {
	Use      bool
	CertFile string
	KeyFile  string
}

Jump to

Keyboard shortcuts

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