ag

package
v0.0.0-...-a2c9e3c Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func After

func After(s string, pos int) string

func Before

func Before(s string, pos int) string

Types

type App

type App struct {
	ListenAddr  string               // 监听端口,为空表示不启动监听。例如:9900
	AdServers   []string             // 服务端地址列表,例如[]string{"192.168.0.1:9901", "192.168.0.2:9901"}
	StartupTime now.Now              // 启动时间
	Gin         *gin.Engine          // Gin引擎
	Processors  map[string]Processor // 处理器
}

App 表示Agent应用

func CreateAgApp

func CreateAgApp(listenAddr, adServers string) *App

CreateAgApp 创建AgApp应用。 listenPort为监听端口,传0表示不启用监听。 adServers 为admin服务器地址列表,例如192.168.0.1:9901,192.168.0.2:9901。不传递时表示本Agent不主动连接任何AdminServer

func (*App) Exec

func (a *App) Exec(c *gin.Context)

func (*App) ExistsProcessor

func (a *App) ExistsProcessor(key string) bool

Processor 获得处理器

func (*App) GoStart

func (a *App) GoStart()

GoStart 异步启动应用

func (*App) Processor

func (a *App) Processor(key string) Processor

Processor 获得处理器

func (*App) Query

func (a *App) Query(c *gin.Context)

func (*App) RegisterProcessor

func (a *App) RegisterProcessor(key string, processor Processor) error

RegisterProcess 注册处理器

type BashProcessor

type BashProcessor struct{}

BashProcessor bash执行处理器

func (BashProcessor) Exec

func (s BashProcessor) Exec(query string, body string) (ok string, err error)

func (BashProcessor) Query

func (s BashProcessor) Query(body string) (ok string, err error)

type NotFoundProcessor

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

NotFoundProcessor 没有发现处理器

func (NotFoundProcessor) Exec

func (n NotFoundProcessor) Exec(query string, body string) (ok string, err error)

func (NotFoundProcessor) Query

func (n NotFoundProcessor) Query(_ string) (ok string, err error)

type PingPongProcessor

type PingPongProcessor struct{}

PingPongProcessor 乒乓处理器

func (PingPongProcessor) Exec

func (p PingPongProcessor) Exec(query string, body string) (ok string, err error)

func (PingPongProcessor) Query

func (p PingPongProcessor) Query(_ string) (ok string, err error)

type Processor

type Processor interface {
	// Query 处理请求体body,成功返回ok, 失败返回err
	Query(query string) (ok string, err error)
	Exec(query string, body string) (ok string, err error)
}

Processor 表示抽象的处理器接口

type SysinfoProcessor

type SysinfoProcessor struct{}

SysinfoProcessor 系统信息处理器

func (SysinfoProcessor) Exec

func (s SysinfoProcessor) Exec(query string, body string) (ok string, err error)

func (SysinfoProcessor) Query

func (s SysinfoProcessor) Query(query string) (ok string, err error)

Jump to

Keyboard shortcuts

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