host

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CPUInfo added in v0.0.8

type CPUInfo struct {
	Percent  float64   `json:"percent"`
	System   float64   `json:"system"`
	User     float64   `json:"user"`
	IOWait   float64   `json:"iowait"`
	Steal    float64   `json:"steal"`
	Idle     float64   `json:"idle"`
	Children []CPUInfo `json:"children"`
	Uptime   int64     `json:"uptime"`
	Load     string    `json:"load"`
}

type Controller

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

func NewController

func NewController() *Controller

func (*Controller) RegisterRoute

func (c *Controller) RegisterRoute(engine *gin.RouterGroup)

type DiskInfo added in v0.0.8

type DiskInfo []DiskItem

type DiskItem added in v0.0.8

type DiskItem struct {
	Partition       string `json:"partition"`
	SizeBytes       int    `json:"size_bytes"`
	UsedSizeBytes   int    `json:"used_size_bytes"`
	MountPoint      string `json:"mount_point"`
	FsType          string `json:"fs_type"`
	ReadSpeedBps    int    `json:"read_speed_Bps"`
	WriteSpeedBps   int    `json:"write_speed_Bps"`
	ReadIops        int    `json:"read_iops"`
	WriteIops       int    `json:"write_iops"`
	ReadLatencyMs   int    `json:"read_latency_ms"`
	WriteLatencyMs  int    `json:"write_latency_ms"`
	TotalReadBytes  int    `json:"total_read_bytes"`
	TotalWriteBytes int    `json:"total_write_bytes"`
}

type Group

type Group struct {
	ID    uuid.UUID `json:"id" gorm:"type:uuid;primaryKey" swaggerignore:"true" example:"00000000-0000-0000-0000-000000000000"`
	Title string    `json:"title" gorm:"unique;not null" validate:"required"`
	Hosts []*Host   `json:"hosts" gorm:"foreignkey:GroupId" swaggerignore:"true"`

	CreatedAt time.Time `json:"createdAt" swaggerignore:"true"`
	UpdatedAt time.Time `json:"updatedAt" swaggerignore:"true"`
}

func (*Group) BeforeCreate

func (g *Group) BeforeCreate(tx *gorm.DB) error

func (*Group) TableName

func (g *Group) TableName() string

type Host

type Host struct {
	ID       uuid.UUID        `json:"id" gorm:"type:uuid;primaryKey" swaggerignore:"true" example:"00000000-0000-0000-0000-000000000000"`
	Title    string           `json:"title" gorm:"not null" validate:"required"`
	Desc     string           `json:"desc"`
	HostInfo sshutil.HostInfo `json:"hostInfo" gorm:"not null"`
	MetaInfo MetaInfo         `json:"metaInfo" swaggerignore:"true"`
	Group    Group            `json:"group" swaggerignore:"true" validate:"omitempty"`
	GroupId  uuid.UUID        `json:"groupId"`

	database.BaseModel
}

func (*Host) BeforeCreate

func (m *Host) BeforeCreate(tx *gorm.DB) error

func (*Host) TableName

func (m *Host) TableName() string

type MemInfo added in v0.0.8

type MemInfo struct {
	Total     int64 `json:"total"`
	Used      int64 `json:"used"`
	Free      int64 `json:"free"`
	Shared    int   `json:"shared"`
	BuffCache int64 `json:"buffcache"`
	Available int64 `json:"available"`
}

type MetaInfo

type MetaInfo struct {
	OS         string `json:"os"`
	Kernel     string `json:"kernel"`
	Hostname   string `json:"hostname"`
	Arch       string `json:"arch"`
	Cpu        string `json:"cpu"`
	Mem        string `json:"mem"`
	Containerd string `json:"containerd"`
	Docker     string `json:"docker"`
}

func (*MetaInfo) Scan

func (m *MetaInfo) Scan(val interface{}) error

func (MetaInfo) Value

func (m MetaInfo) Value() (driver.Value, error)

type NetworkInfo added in v0.0.8

type NetworkInfo []NetworkItem

type NetworkItem added in v0.0.8

type NetworkItem struct {
	Name      string `json:"name"`
	Type      string `json:"type"`
	BytesRec  int    `json:"bytes_rec"`
	BytesSent int    `json:"bytes_sent"`
	SpeedRec  int64  `json:"speed_rec"`
	SpeedSent int    `json:"speed_sent"`
}

type ProcessInfo added in v0.0.8

type ProcessInfo []ProcessItem

type ProcessItem added in v0.0.8

type ProcessItem struct {
	CPU     float64 `json:"cpu"`
	Mem     float64 `json:"mem"`
	Command string  `json:"command"`
}

type RTT added in v0.0.8

type RTT int64

type Service

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

func GetService

func GetService() *Service

func (*Service) AddGroup

func (s *Service) AddGroup(group *Group) error

AddGroup add host group

func (*Service) AddHost

func (s *Service) AddHost(host *Host) error

AddHost add host

func (*Service) DeleteGroup

func (s *Service) DeleteGroup(id uuid.UUID) error

DeleteGroup delete host group

func (*Service) DeleteHost

func (s *Service) DeleteHost(id uuid.UUID) error

DeleteHost delete host

func (*Service) DetailHost

func (s *Service) DetailHost(id uuid.UUID) (*Host, error)

DetailHost detail host

func (*Service) ExecContainer added in v0.0.8

func (s *Service) ExecContainer(ctx *gin.Context, id uuid.UUID, containerId, driver, user, cmd string) error

func (*Service) GetContainerLogs added in v0.0.8

func (s *Service) GetContainerLogs(ctx context.Context, id uuid.UUID, containerId string, driver string) (io.ReadCloser, error)

func (*Service) GetHostStats added in v0.0.8

func (s *Service) GetHostStats(id uuid.UUID) (*Stats, error)

func (*Service) Initialize

func (s *Service) Initialize() error

func (*Service) ListContainer added in v0.0.8

func (s *Service) ListContainer(id uuid.UUID, driver string) ([]*container.Container, error)

func (*Service) ListContainerImage added in v0.0.8

func (s *Service) ListContainerImage(id uuid.UUID, driver string) ([]*container.Image, error)

func (*Service) ListContainerNetwork added in v0.0.8

func (s *Service) ListContainerNetwork(id uuid.UUID, driver string) ([]*container.Network, error)

func (*Service) ListGroup

func (s *Service) ListGroup(group *Group) ([]*Group, error)

ListGroup list host group

func (*Service) ListHost

func (s *Service) ListHost(host *Host) ([]*Host, error)

ListHost list host

func (*Service) UpdateGroup

func (s *Service) UpdateGroup(group *Group) error

UpdateGroup update host group

func (*Service) UpdateHost

func (s *Service) UpdateHost(host *Host) error

UpdateHost update host

type Stats added in v0.0.8

type Stats struct {
	CpuInfo     *CPUInfo     `json:"cpuInfo"`
	MemInfo     *MemInfo     `json:"memInfo"`
	DiskInfo    *DiskInfo    `json:"diskInfo"`
	NetworkInfo *NetworkInfo `json:"networkInfo"`
	ProcessInfo *ProcessInfo `json:"processInfo"`
	Rtt         RTT          `json:"rtt"`
	// contains filtered or unexported fields
}

func (*Stats) Default added in v0.0.8

func (s *Stats) Default() *Stats

type StatsCache added in v0.0.8

type StatsCache map[string]*Stats

func (*StatsCache) Get added in v0.0.8

func (sc *StatsCache) Get(key string) *Stats

func (*StatsCache) Set added in v0.0.8

func (sc *StatsCache) Set(key string, value any)

Jump to

Keyboard shortcuts

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