agentutils

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2019 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func ActionDeleteAgent added in v0.1.6

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

func AddTabbar

func AddTabbar(actionWrapper actions.ActionWrapper)

func CheckHostConnectivity added in v0.1.2

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

检查主机设置

func FindAgentRuntime

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

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

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

查找通知相关的Link

func FindSharedAgents added in v0.1.2

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 added in v0.1.2

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

分析主机规则

func PostAgentEvent

func PostAgentEvent(agentId string, event *Event)

发送Agent事件

func RemoveAgentQueue

func RemoveAgentQueue(agentId string, c chan *Event)

删除Agent

func SyncAddChart added in v0.1.2

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

添加Chart

func SyncApp added in v0.1.2

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

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

func SyncAppEvent added in v0.1.2

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

仅同步Event

func SyncRemoveChart added in v0.1.2

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

仅同步Chart

func WaitAgentQueue

func WaitAgentQueue(agentId string, agentVersion string, osName string, speed float64, ip string, c chan *Event)

等待Agent事件

Types

type Event

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

func NewAgentEvent

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

新Agent事件

type Installer added in v0.1.2

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 added in v0.1.2

func NewInstaller() *Installer

获取新对象

func (*Installer) Start added in v0.1.2

func (this *Installer) Start() error

安装Agent

type ProcessLog

type ProcessLog struct {
	Id         primitive.ObjectID `var:"id" bson:"_id" json:"id"` // 数据库存储的ID
	AgentId    string             `bson:"agentId" json:"agentId"`
	TaskId     string             `bson:"taskId" json:"taskId"`
	ProcessId  string             `bson:"processId" json:"processId"`
	ProcessPid int                `bson:"processPid" json:"processPid"`
	EventType  string             `bson:"eventType" json:"eventType"` // start, log, stop
	Data       string             `bson:"data" json:"data"`
	Timestamp  int64              `bson:"timestamp" json:"timestamp"` // unix时间戳,单位为秒
	TimeFormat struct {
		Year   string `bson:"year" json:"year"`
		Month  string `bson:"month" json:"month"`
		Day    string `bson:"day" json:"day"`
		Hour   string `bson:"hour" json:"hour"`
		Minute string `bson:"minute" json:"minute"`
		Second string `bson:"second" json:"second"`
	} `bson:"timeFormat" json:"timeFormat"`
}

进程日志

type SSHAuthType added in v0.1.2

type SSHAuthType = string

安装器

type State added in v0.1.2

type State struct {
	Version string  // 版本号
	OsName  string  // 操作系统
	Speed   float64 // 连接速度,ms
	IP      string  // IP地址
}

Agent状态

func CheckAgentIsWaiting

func CheckAgentIsWaiting(agentId string) (state *State, isWaiting bool)

检查Agent是否正在运行

Jump to

Keyboard shortcuts

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