monitors

package
v6.0.0-beta2+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultIPSettings = IPSettings{
	IPv4: true,
	IPv6: true,
	Mode: PingAny,
}

DefaultIPSettings provides an instance of default IPSettings to be copied when unpacking settings from a common.Config object.

View Source
var Registry = newRegistrar()

Functions

func ActivePlugin

func ActivePlugin(name string, b ActiveBuilder) map[string][]interface{}

func MakePingAllIPFactory

func MakePingAllIPFactory(
	f func(*net.IPAddr) []func() (common.MapStr, error),
) func(*net.IPAddr) TaskRunner

MakePingAllIPFactory wraps a function for building a recursive Task Runner from function callbacks.

func MakePingAllIPPortFactory

func MakePingAllIPPortFactory(
	ports []uint16,
	f func(*net.IPAddr, uint16) (common.MapStr, error),
) func(*net.IPAddr) TaskRunner

MakePingAllIPPortFactory builds a set of TaskRunner supporting a set of IP/port-pairs.

func MakePingIPFactory

func MakePingIPFactory(
	f func(*net.IPAddr) (common.MapStr, error),
) func(*net.IPAddr) TaskRunner

MakePingIPFactory creates a factory for building a Task from a new IP address.

func RegisterActive

func RegisterActive(name string, builder ActiveBuilder)

Types

type ActiveBuilder

type ActiveBuilder func(Info, *common.Config) ([]Job, error)

type Factory

type Factory func(*common.Config) ([]Job, error)

type HostJobSettings

type HostJobSettings struct {
	Name   string
	Host   string
	IP     IPSettings
	Fields common.MapStr
}

HostJobSettings configures a Job including Host lookups and global fields to be added to every event.

func MakeHostJobSettings

func MakeHostJobSettings(name, host string, ip IPSettings) HostJobSettings

MakeHostJobSettings creates a new HostJobSettings structure without any global event fields.

func (*HostJobSettings) AddFields

func (s *HostJobSettings) AddFields(m common.MapStr)

AddFields adds new event fields to a Job. Existing fields will be overwritten.

func (HostJobSettings) WithFields

func (s HostJobSettings) WithFields(m common.MapStr) HostJobSettings

WithFields adds new event fields to a Job. Existing fields will be overwritten. The fields map will be updated (no copy).

type IPSettings

type IPSettings struct {
	IPv4 bool     `config:"ipv4"`
	IPv6 bool     `config:"ipv6"`
	Mode PingMode `config:"mode"`
}

IPSettings provides common configuration settings for IP resolution and ping mode.

func (IPSettings) Network

func (s IPSettings) Network() string

Network determines the Network type used for IP name resolution, based on the provided settings.

type Info

type Info struct {
	Name string
	Type Type
}

type Job

type Job interface {
	Name() string
	Run() (beat.Event, []JobRunner, error)
}

func MakeByHostJob

func MakeByHostJob(
	settings HostJobSettings,
	pingFactory func(ip *net.IPAddr) TaskRunner,
) (Job, error)

MakeByHostJob creates a new Job including host lookup. The pingFactory will be used to build one or multiple Tasks after name lookup according to settings.

A pingFactory instance is normally build with MakePingIPFactory, MakePingAllIPFactory or MakePingAllIPPortFactory.

func MakeByIPJob

func MakeByIPJob(
	settings JobSettings,
	ip net.IP,
	pingFactory func(ip *net.IPAddr) TaskRunner,
) (Job, error)

MakeByIPJob builds a new Job based on already known IP. Similar to MakeByHostJob, the pingFactory will be used to build the tasks run by the job.

A pingFactory instance is normally build with MakePingIPFactory, MakePingAllIPFactory or MakePingAllIPPortFactory.

func MakeJob

func MakeJob(settings JobSettings, f func() (common.MapStr, []TaskRunner, error)) Job

MakeJob create a new Job from a callback function. The callback can optionally return an event to be published and a set of derived sub-tasks to be scheduled. The sub-tasks will be run only once and removed from the scheduler after completion.

func MakeSimpleJob

func MakeSimpleJob(settings JobSettings, f func() (common.MapStr, error)) Job

MakeSimpleJob creates a new Job from a callback function. The callback should return an valid event and can not create any sub-tasks to be executed after completion.

type JobRunner

type JobRunner func() (beat.Event, []JobRunner, error)

type JobSettings

type JobSettings struct {
	Name   string
	Fields common.MapStr
}

JobSettings configures a Job name and global fields to be added to every event.

func MakeJobSetting

func MakeJobSetting(name string) JobSettings

MakeJobSetting creates a new JobSettings structure without any global event fields.

func (*JobSettings) AddFields

func (s *JobSettings) AddFields(m common.MapStr)

AddFields adds new event fields to a Job. Existing fields will be overwritten.

func (JobSettings) WithFields

func (s JobSettings) WithFields(m common.MapStr) JobSettings

WithFields adds new event fields to a Job. Existing fields will be overwritten. The fields map will be updated (no copy).

type PingMode

type PingMode uint8

PingMode enumeration for configuring `any` or `all` IPs pinging.

const (
	PingModeUndefined PingMode = iota
	PingAny
	PingAll
)

func (*PingMode) Unpack

func (p *PingMode) Unpack(s string) error

Unpack sets PingMode from a constant string. Unpack will be called by common.Unpack when unpacking into an IPSettings type.

type Registrar

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

func (*Registrar) AddActive

func (r *Registrar) AddActive(name string, builder ActiveBuilder) error

func (*Registrar) GetFactory

func (r *Registrar) GetFactory(name string) Factory

func (*Registrar) Query

func (r *Registrar) Query(name string) (Info, bool)

func (*Registrar) Register

func (r *Registrar) Register(name string, t Type, builder ActiveBuilder) error

func (*Registrar) String

func (r *Registrar) String() string

type TaskRunner

type TaskRunner interface {
	Run() (common.MapStr, []TaskRunner, error)
}

func MakeCont

func MakeCont(f func() (common.MapStr, []TaskRunner, error)) TaskRunner

MakeCont wraps a function into an executable TaskRunner. The task being generated can optionally return an event and/or sub-tasks.

func MakeSimpleCont

func MakeSimpleCont(f func() (common.MapStr, error)) TaskRunner

MakeSimpleCont wraps a function into an executable TaskRunner. The task bein generated should return an event to be reported.

func WithDuration

func WithDuration(field string, r TaskRunner) TaskRunner

WithDuration wraps a TaskRunner, measuring the duration between creation and finish of the actual task and sub-tasks.

func WithFields

func WithFields(fields common.MapStr, r TaskRunner) TaskRunner

WithFields wraps a TaskRunner, updating all events returned with the set of fields configured.

type Type

type Type uint8
const (
	ActiveMonitor Type = iota + 1
	PassiveMonitor
)

func (Type) String

func (t Type) String() string

Directories

Path Synopsis
active
tcp

Jump to

Keyboard shortcuts

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