monitor

package
v0.27.3 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FullHealth means all nodes online, synced, validators making blocks
	FullHealth = Health(0)
	// ModerateHealth means we're making blocks
	ModerateHealth = Health(1)
	// Dead means we're not making blocks due to all validators freezing or crashing
	Dead = Health(2)
)

Variables

This section is empty.

Functions

func RecalculateNetworkUptimeEvery

func RecalculateNetworkUptimeEvery(d time.Duration) func(m *Monitor)

RecalculateNetworkUptimeEvery lets you change network uptime update interval.

func SetCheckIsValidatorInterval

func SetCheckIsValidatorInterval(d time.Duration) func(n *Node)

SetCheckIsValidatorInterval lets you change interval for checking whenever node is still a validator or not.

func SetNumValidatorsUpdateInterval

func SetNumValidatorsUpdateInterval(d time.Duration) func(m *Monitor)

SetNumValidatorsUpdateInterval lets you change num validators update interval.

func UnmarshalEvent

func UnmarshalEvent(b json.RawMessage) (string, events.EventData, error)

UnmarshalEvent unmarshals a json event

Types

type Health

type Health int

Health describes the health of the network. Note that this applies only to the observed nodes, and not to the entire cluster, which may consist of thousands of machines. It may change in the future.

type Monitor

type Monitor struct {
	Nodes []*Node

	Network *Network
	// contains filtered or unexported fields
}

Monitor keeps track of the nodes and updates common statistics upon receiving new events from nodes.

Common statistics is stored in Network struct.

func NewMonitor

func NewMonitor(options ...func(*Monitor)) *Monitor

NewMonitor creates new instance of a Monitor. You can provide options to change some default values.

Example:

NewMonitor(monitor.SetNumValidatorsUpdateInterval(1 * time.Second))

func (*Monitor) Monitor

func (m *Monitor) Monitor(n *Node) error

Monitor begins to monitor the node `n`. The node will be started and added to the monitor.

func (*Monitor) NodeByName

func (m *Monitor) NodeByName(name string) (index int, node *Node)

NodeByName returns the node and its index if such node exists within the monitor. Otherwise, -1 and nil are returned.

func (*Monitor) NodeIsOnline

func (m *Monitor) NodeIsOnline(name string)

NodeIsOnline is called when connection to the node is restored. Must be safe to call multiple times.

func (*Monitor) SetLogger

func (m *Monitor) SetLogger(l log.Logger)

SetLogger lets you set your own logger

func (*Monitor) Start

func (m *Monitor) Start() error

Start starts the monitor's routines: recalculating network uptime and updating number of validators.

func (*Monitor) Stop

func (m *Monitor) Stop()

Stop stops the monitor's routines.

func (*Monitor) Unmonitor

func (m *Monitor) Unmonitor(n *Node)

Unmonitor stops monitoring node `n`. The node will be stopped and removed from the monitor.

type Network

type Network struct {
	Height int64 `json:"height"`

	AvgBlockTime float64 `json:"avg_block_time" amino:"unsafe"` // ms (avg over last minute)

	AvgTxThroughput float64 `json:"avg_tx_throughput" amino:"unsafe"` // tx/s (avg over last minute)

	AvgBlockLatency float64 `json:"avg_block_latency" amino:"unsafe"` // ms (avg over last minute)

	NumValidators           int `json:"num_validators"`
	NumNodesMonitored       int `json:"num_nodes_monitored"`
	NumNodesMonitoredOnline int `json:"num_nodes_monitored_online"`

	Health Health `json:"health"`

	UptimeData *UptimeData `json:"uptime_data"`
	// contains filtered or unexported fields
}

Common statistics for network of nodes

func NewNetwork

func NewNetwork() *Network

func (*Network) GetHealthString

func (n *Network) GetHealthString() string

func (*Network) NewBlock

func (n *Network) NewBlock(b tmtypes.Header)

func (*Network) NewBlockLatency

func (n *Network) NewBlockLatency(l float64)

func (*Network) NewNode

func (n *Network) NewNode(name string)

NewNode is called when the new node is added to the monitor.

func (*Network) NodeDeleted

func (n *Network) NodeDeleted(name string)

NodeDeleted is called when the node is deleted from under the monitor.

func (*Network) NodeIsDown

func (n *Network) NodeIsDown(name string)

NodeIsDown is called when the node disconnects for whatever reason. Must be safe to call multiple times.

func (*Network) NodeIsOnline

func (n *Network) NodeIsOnline(name string)

NodeIsOnline is called when connection to the node is restored. Must be safe to call multiple times.

func (*Network) RecalculateUptime

func (n *Network) RecalculateUptime()

RecalculateUptime calculates uptime on demand.

func (*Network) StartTime

func (n *Network) StartTime() time.Time

StartTime returns time we started monitoring.

func (*Network) UpdateNumValidatorsForHeight

func (n *Network) UpdateNumValidatorsForHeight(num int, height int64)

func (*Network) Uptime

func (n *Network) Uptime() float64

Uptime returns network's uptime in percentages.

type Node

type Node struct {
	IsValidator bool `json:"is_validator"` // validator or non-validator?

	Name         string  `json:"name"`
	Online       bool    `json:"online"`
	Height       int64   `json:"height"`
	BlockLatency float64 `json:"block_latency" amino:"unsafe"` // ms, interval between block commits
	// contains filtered or unexported fields
}

func NewNode

func NewNode(rpcAddr string, options ...func(*Node)) *Node

func NewNodeWithEventMeterAndRpcClient

func NewNodeWithEventMeterAndRpcClient(rpcAddr string, em eventMeter, rpcClient rpc_client.HTTPClient, options ...func(*Node)) *Node

func (*Node) NotifyAboutDisconnects

func (n *Node) NotifyAboutDisconnects(ch chan<- bool)

func (*Node) NumValidators

func (n *Node) NumValidators() (height int64, num int, err error)

func (*Node) RestartEventMeterBackoff

func (n *Node) RestartEventMeterBackoff() error

func (*Node) SendBlockLatenciesTo

func (n *Node) SendBlockLatenciesTo(ch chan<- float64)

func (*Node) SendBlocksTo

func (n *Node) SendBlocksTo(ch chan<- tmtypes.Header)

func (*Node) SetLogger

func (n *Node) SetLogger(l log.Logger)

SetLogger lets you set your own logger

func (*Node) Start

func (n *Node) Start() error

func (*Node) Stop

func (n *Node) Stop()

type UptimeData

type UptimeData struct {
	StartTime time.Time `json:"start_time"`
	Uptime    float64   `json:"uptime" amino:"unsafe"` // percentage of time we've been healthy, ever
	// contains filtered or unexported fields
}

UptimeData stores data for how long network has been running.

Jump to

Keyboard shortcuts

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