executors

package
v0.0.0-...-c12f8f0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package executors provides objects that gathers resource data from a host.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, constructor func() IExecutor)

Register makes any executor constructor available by name.

Types

type AgentLogPayload

type AgentLogPayload struct {
	Host struct {
		Name string
		Tags map[string]string
	}
	Data struct {
		Loglines []AgentLoglinePayload
		Filename string
	}
}

type AgentLoglinePayload

type AgentLoglinePayload struct {
	Created int64
	Content string
}

type Base

type Base struct {
	// Command: Shell command to execute.
	Command string

	// Path: ResourceD URL path. Example:
	// /uptime -> http://localhost:55555/x/uptime
	Path string

	Interval string

	// LowThreshold: minimum count of valid conditions
	LowThreshold int64

	// HighThreshold: maximum count of valid conditions
	HighThreshold int64

	// Conditions for when executor should run.
	Conditions string

	// Host data
	Host *host.Host

	ResourcedMasterURL         string
	ResourcedMasterAccessToken string

	ReadersDataBytes map[string][]byte
	// contains filtered or unexported fields
}

func (*Base) GetPath

func (b *Base) GetPath() string

func (*Base) HighThresholdExceeded

func (b *Base) HighThresholdExceeded() bool

func (*Base) IsConditionMet

func (b *Base) IsConditionMet() bool

func (*Base) LowThresholdExceeded

func (b *Base) LowThresholdExceeded() bool

func (*Base) NewHttpRequest

func (b *Base) NewHttpRequest(dataJson []byte) (*http.Request, error)

NewHttpRequest builds and returns http.Request struct.

func (*Base) SetCounterDB

func (b *Base) SetCounterDB(db *libmap.TSafeMapCounter)

func (*Base) SetHostData

func (b *Base) SetHostData(hostData *host.Host)

func (*Base) SetInterval

func (b *Base) SetInterval(interval string)

func (*Base) SetPath

func (b *Base) SetPath(path string)

func (*Base) SetQueryParser

func (b *Base) SetQueryParser(readersJsonBytes map[string][]byte)

func (*Base) SetReadersDataInBytes

func (b *Base) SetReadersDataInBytes(readersJsonBytes map[string][]byte)

SetReadersDataInBytes pulls readers data and store them on ReadersData field.

func (*Base) SetResourcedMasterAccessToken

func (b *Base) SetResourcedMasterAccessToken(resourcedMasterAccessToken string)

func (*Base) SetResourcedMasterURL

func (b *Base) SetResourcedMasterURL(resourcedMasterURL string)

func (*Base) SetTags

func (b *Base) SetTags(tags map[string]string)

SetTags assigns all host tags to qp (QueryParser).

type DiskCleaner

type DiskCleaner struct {
	Base
	Data  map[string]interface{}
	Globs []interface{}
}

func (*DiskCleaner) Run

func (dc *DiskCleaner) Run() error

Run shells out external program and store the output on c.Data.

func (*DiskCleaner) ToJson

func (dc *DiskCleaner) ToJson() ([]byte, error)

ToJson serialize Data field to JSON. If there are no meaningful results, ToJson returns nil.

type HipChat

type HipChat struct {
	Base
	Data      map[string]interface{}
	AuthToken string
	RoomName  string
	Message   string
}

func (*HipChat) Run

func (hc *HipChat) Run() error

Run shells out external program and store the output on c.Data.

func (*HipChat) ToJson

func (hc *HipChat) ToJson() ([]byte, error)

ToJson serialize Data field to JSON.

type IExecutor

type IExecutor interface {
	SetPath(string)
	GetPath() string
	SetInterval(string)
	SetResourcedMasterURL(string)
	SetResourcedMasterAccessToken(string)
	SetHostData(*host.Host)
	SetCounterDB(*libmap.TSafeMapCounter)
	Run() error
	ToJson() ([]byte, error)
	SetQueryParser(map[string][]byte)
	SetReadersDataInBytes(map[string][]byte)
	SetTags(map[string]string)
	IsConditionMet() bool
	LowThresholdExceeded() bool
	HighThresholdExceeded() bool
}

IExecutor is generic interface for all executors.

func NewDiskCleaner

func NewDiskCleaner() IExecutor

func NewGoStruct

func NewGoStruct(name string) (IExecutor, error)

NewGoStruct instantiates IExecutor

func NewGoStructByConfig

func NewGoStructByConfig(config resourced_config.Config) (IExecutor, error)

NewGoStructByConfig instantiates IExecutor given Config struct

func NewHipChat

func NewHipChat() IExecutor

func NewPagerDuty

func NewPagerDuty() IExecutor

func NewShell

func NewShell() IExecutor

type PagerDuty

type PagerDuty struct {
	Base
	Data        map[string]interface{}
	ServiceKey  string
	Description string
	IncidentKey string
}

func (*PagerDuty) Run

func (pd *PagerDuty) Run() error

Run shells out external program and store the output on c.Data.

func (*PagerDuty) ToJson

func (pd *PagerDuty) ToJson() ([]byte, error)

ToJson serialize Data field to JSON.

type Shell

type Shell struct {
	Base
	Data map[string]interface{}
}

func (*Shell) Run

func (s *Shell) Run() error

Run shells out external program and store the output on c.Data.

func (*Shell) ToJson

func (s *Shell) ToJson() ([]byte, error)

ToJson serialize Data field to JSON. If there are no meaningful results, ToJson returns nil.

Jump to

Keyboard shortcuts

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