hook

package
v1.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: May 23, 2017 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DISK_EVENT = iota
	CPU_EVENT
	MEM_EVENT
	STATUS_EVENT
	LOAD_EVENT
)

钩子事件类型

Variables

View Source
var DefaultEventMaps = map[string]int{"disk": DISK_EVENT,
	"cpu":    CPU_EVENT,
	"mem":    MEM_EVENT,
	"status": STATUS_EVENT,
	"load":   LOAD_EVENT,
}

事件对象映射

View Source
var DefaultScriptSyntaxKeywords = []string{"eventtarget",
	"gt",
	"lt",
	"attr",
	"callback",
}

语法关键字

View Source
var GEventQueue = NewEventQueue()

event queue

View Source
var GScriptSyntax = NewDefaultSyntax()

syntax

View Source
var NotifyTemplate = `` /* 347-byte string literal not displayed */

通告模板

Functions

func DispatchEvent

func DispatchEvent()

dispatch event 设计事件分发机制

func ParseHookScript

func ParseHookScript(configfile string)

解析钩子脚本

func SendEmailTo

func SendEmailTo(user, password, host, to, subject, body, mailtype string) error

发送邮件

Types

type Event

type Event struct {
	EventType      int
	EventTarget    string
	EventAttr      string
	EventCondition map[string]string
	EventCallback  string
	EventHostIP    string
}

event

func NewEvent

func NewEvent() *Event

func (*Event) ExecCallback

func (self *Event) ExecCallback() (string, error)

callback run

type EventQueue

type EventQueue struct {
	EventCache cache.Cacher
	//email监控
	EmailOpen bool
	EmailUser string
	EmailPwd  string
	SmtpHost  string
	EmailTo   string
}

事件列表

func NewEventQueue

func NewEventQueue() *EventQueue

new memory event list

func (*EventQueue) GetEvent

func (self *EventQueue) GetEvent(k string) []*Event

get event

func (*EventQueue) GetEvents

func (self *EventQueue) GetEvents() map[string]interface{}

events

func (*EventQueue) PushEvent

func (self *EventQueue) PushEvent(k string, v interface{})

push event

type ExprData

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

表达式数据

type ScriptSyntax

type ScriptSyntax struct {
}

func (*ScriptSyntax) CheckFloadValue

func (self *ScriptSyntax) CheckFloadValue(expr *ExprData, value float64) bool

check fload

func (*ScriptSyntax) CheckSyntakKeyWords

func (self *ScriptSyntax) CheckSyntakKeyWords(keywords string) bool

检查关键字

func (*ScriptSyntax) GetExpt

func (self *ScriptSyntax) GetExpt(event *Event) *ExprData

func (*ScriptSyntax) IsExpr

func (self *ScriptSyntax) IsExpr(keywords string) bool

是否是表达式

func (*ScriptSyntax) ParseCondition

func (self *ScriptSyntax) ParseCondition(condition string) bool

解析condition

type Syntaxer

type Syntaxer interface {
	CheckSyntakKeyWords(keywords string) bool
	GetExpt(event *Event) *ExprData
	IsExpr(keywords string) bool
	CheckFloadValue(expr *ExprData, value float64) bool
}

func NewDefaultSyntax

func NewDefaultSyntax() Syntaxer

new syntax

Jump to

Keyboard shortcuts

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