agentutils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: MIT, MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SSHAuthTypePassword = "password"
	SSHAuthTypeKey      = "key"
)

Variables

This section is empty.

Functions

func ActionDeleteAgent

func ActionDeleteAgent(agentId string, onFail func(message string)) (goNext bool)

func AddItemState

func AddItemState(itemId string, itemState *ItemState)

添加监控项状态

func AddTabbar

func AddTabbar(actionWrapper actions.ActionWrapper)

func CheckHostConnectivity

func CheckHostConnectivity(host string, port int, timeout time.Duration) (cost time.Duration, b bool)

检查主机设置

func ConvertReceiversToMaps

func ConvertReceiversToMaps(receivers []*notices.NoticeReceiver) (result []maps.Map)

将Receiver转换为Map

func FindAgentRuntime

func FindAgentRuntime(agentConfig *agents.AgentConfig) *agents.AgentConfig

查找正在运行中的Agent,用来维护Agent的状态

func FindNoticeLinks(notice *notices.Notice) (links []maps.Map)

查找通知相关的Link

func FindSharedAgents

func FindSharedAgents(currentAgentId string, groupIds []string, app *agents.AppConfig) []*agents.AgentConfig

查找共享的Agent

func FormatTask

func FormatTask(task *agents.TaskConfig, agentId string) maps.Map

格式化任务信息

func InitAppData

func InitAppData(actionWrapper actions.ActionWrapper, agentId string, appId string, tabbar string) *agents.AppConfig

App菜单

func ParseHostRules

func ParseHostRules(rules string, max int) (result []string)

分析主机规则

func PostAgentEvent

func PostAgentEvent(agentId string, event *AgentEvent)

通知事件

func RemoveItemState

func RemoveItemState(itemId string)

删除监控项状态

func SyncAddChart

func SyncAddChart(currentAgentId string, groupIds []string, app *agents.AppConfig, itemId string, chartId string) error

添加Chart

func SyncApp

func SyncApp(currentAgentId string, groupIds []string, app *agents.AppConfig, event *AgentEvent, op func(agent *agents.AgentConfig) error) error

同步App到其他Agents op是附加操作

func SyncAppEvent

func SyncAppEvent(currentAgentId string, groupIds []string, app *agents.AppConfig, event *AgentEvent) error

仅同步Event

func SyncRemoveChart

func SyncRemoveChart(currentAgentId string, groupIds []string, app *agents.AppConfig, chartId string) error

仅同步Chart

Types

type AgentEvent

type AgentEvent struct {
	Name string      `json:"name"`
	Data interface{} `json:"data"`
}

Agent事件

func NewAgentEvent

func NewAgentEvent(name string, data interface{}) *AgentEvent

获取新对象

func Wait

func Wait(agentId string) *AgentEvent

等待事件

type AgentQueue

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

func NewAgentQueue

func NewAgentQueue() *AgentQueue

type AgentState

type AgentState struct {
	Version  string  // 版本号
	OsName   string  // 操作系统
	Speed    float64 // 连接速度,ms
	IP       string  // IP地址
	IsActive bool    // 是否在线
}

Agent状态

func FindAgentState

func FindAgentState(agentId string) *AgentState

查找Agent状态

type Installer

type Installer struct {
	Master       string
	Dir          string
	Host         string
	Port         int
	AuthUsername string
	AuthType     SSHAuthType
	AuthPassword string
	AuthKey      []byte
	Timeout      time.Duration
	GroupId      string

	HostName string
	HostIP   string
	OS       string
	Arch     string

	Logs        []string
	IsInstalled bool
}

func NewInstaller

func NewInstaller() *Installer

获取新对象

func (*Installer) Start

func (this *Installer) Start() error

安装Agent

type ItemState

type ItemState struct {
	IsFailed bool // 是否已失败
}

监控项状态

func FindItemState

func FindItemState(itemId string) (state *ItemState, ok bool)

查找监控项状态

type SSHAuthType

type SSHAuthType = string

安装器

Jump to

Keyboard shortcuts

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