monitor

package
v4.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 1, 2019 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewErrorRecordingListWatcher

func NewErrorRecordingListWatcher(recorder Recorder, lw cache.ListerWatcher) cache.ListerWatcher

Types

type Condition

type Condition struct {
	Level EventLevel

	Locator string
	Message string
}

type ConditionalSampler

type ConditionalSampler interface {
	ConditionWhenFailing(*Condition) SamplerFunc
}

func StartSampling

func StartSampling(ctx context.Context, recorder Recorder, interval time.Duration, sampleFn func(previous bool) (*Condition, bool)) ConditionalSampler

type Event

type Event struct {
	Condition

	At time.Time
}

func (*Event) String

func (e *Event) String() string

type EventInterval

type EventInterval struct {
	*Condition

	From time.Time
	To   time.Time
}

func (*EventInterval) String

func (i *EventInterval) String() string

type EventIntervals

type EventIntervals []*EventInterval

func (EventIntervals) Len

func (intervals EventIntervals) Len() int

func (EventIntervals) Less

func (intervals EventIntervals) Less(i, j int) bool

func (EventIntervals) Swap

func (intervals EventIntervals) Swap(i, j int)

type EventLevel

type EventLevel int
const (
	Info EventLevel = iota
	Warning
	Error
)

type Interface

type Interface interface {
	Events(from, to time.Time) EventIntervals
	Conditions(from, to time.Time) EventIntervals
}

type Monitor

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

Monitor records events that have occurred in memory and can also periodically sample results.

func NewMonitor

func NewMonitor() *Monitor

NewMonitor creates a monitor with the default sampling interval.

func Start

func Start(ctx context.Context) (*Monitor, error)

Start begins monitoring the cluster referenced by the default kube configuration until context is finished.

func (*Monitor) AddSampler

func (m *Monitor) AddSampler(fn SamplerFunc)

AddSampler adds a sampler function to the list of samplers to run every interval. Conditions discovered this way are recorded with a start and end time if they persist across multiple sampling intervals.

func (*Monitor) Conditions

func (m *Monitor) Conditions(from, to time.Time) EventIntervals

Conditions returns all conditions that were sampled in the interval between from and to. If that does not include a sample interval, no results will be returned. EventIntervals are returned in order of their first sampling. A condition that was only sampled once is returned with from == to. No duplicate conditions are returned unless a sampling interval did not report that value.

func (*Monitor) Events

func (m *Monitor) Events(from, to time.Time) EventIntervals

Events returns all events that occur between from and to, including any sampled conditions that were encountered during that period. EventIntervals are returned in order of their occurrence.

func (*Monitor) Record

func (m *Monitor) Record(conditions ...Condition)

Record captures one or more conditions at the current time. All conditions are recorded in monotonic order as Event objects.

func (*Monitor) StartSampling

func (m *Monitor) StartSampling(ctx context.Context)

StartSampling starts sampling every interval until the provided context is done. A sample is captured when the context is closed.

type Options

type Options struct {
	Out, ErrOut io.Writer
}

Options is used to run a monitoring process against the provided server as a command line interaction.

func (*Options) Run

func (opt *Options) Run() error

Run starts monitoring the cluster by invoking Start, periodically printing the events accumulated to Out. When the user hits CTRL+C or signals termination the condition intervals (all non-instantaneous events) are reported to Out.

type Recorder

type Recorder interface {
	Record(conditions ...Condition)
	AddSampler(fn SamplerFunc)
}

type SamplerFunc

type SamplerFunc func(time.Time) []*Condition

Jump to

Keyboard shortcuts

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