runtime

package
Version: v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2018 License: AGPL-3.0 Imports: 9 Imported by: 108

Documentation

Index

Constants

View Source
const (
	DISABLED_AUTOUPDATER = "disabled"
	GLOBAL_SITE          = "global"
	GLOBAL_DOMAIN        = "global"
)

Variables

This section is empty.

Functions

func NewGlobalStats

func NewGlobalStats(nodes *Nodes, sitesDomains map[string][]string) (result map[string]map[string]*GlobalStats)

NewGlobalStats returns global statistics for InfluxDB

func SaveJSON

func SaveJSON(input interface{}, outputFile string)

SaveJSON to path

Types

type CounterMap

type CounterMap map[string]uint32

CounterMap to manage multiple values

func (CounterMap) Increment

func (m CounterMap) Increment(key string)

Increment counter in the map by one if the value is not empty

type GlobalStats

type GlobalStats struct {
	Clients       uint32
	ClientsWifi   uint32
	ClientsWifi24 uint32
	ClientsWifi5  uint32
	Gateways      uint32
	Nodes         uint32

	Firmwares   CounterMap
	Models      CounterMap
	Autoupdater CounterMap
}

GlobalStats struct

func (*GlobalStats) Add

func (s *GlobalStats) Add(node *Node)

Add values to GlobalStats if node is online

type Link struct {
	SourceID      string
	SourceAddress string
	TargetID      string
	TargetAddress string
	TQ            float32
}

Link represents a link between two nodes

type Node

type Node struct {
	Address    *net.UDPAddr     `json:"-"` // the last known address
	Firstseen  jsontime.Time    `json:"firstseen"`
	Lastseen   jsontime.Time    `json:"lastseen"`
	Online     bool             `json:"online"`
	Statistics *data.Statistics `json:"statistics"`
	Nodeinfo   *data.NodeInfo   `json:"nodeinfo"`
	Neighbours *data.Neighbours `json:"-"`
}

Node struct

func (*Node) IsGateway

func (node *Node) IsGateway() bool

IsGateway returns whether the node is a gateway

type Nodes

type Nodes struct {
	List map[string]*Node `json:"nodes"` // the current nodemap, indexed by node ID

	sync.RWMutex
	// contains filtered or unexported fields
}

Nodes struct: cache DB of Node's structs

func NewNodes

func NewNodes(config *NodesConfig) *Nodes

NewNodes create Nodes structs

func (*Nodes) AddNode

func (nodes *Nodes) AddNode(node *Node)

func (*Nodes) GetNodeIDbyAddress

func (nodes *Nodes) GetNodeIDbyAddress(addr string) string
func (nodes *Nodes) NodeLinks(node *Node) (result []Link)

NodeLinks returns a list of links to known neighbours

func (*Nodes) Select

func (nodes *Nodes) Select(f func(*Node) bool) []*Node

Select selects a list of nodes to be returned

func (*Nodes) Start

func (nodes *Nodes) Start()

Start all services to manage Nodes

func (*Nodes) Update

func (nodes *Nodes) Update(nodeID string, res *data.ResponseData) *Node

Update a Node

type NodesConfig

type NodesConfig struct {
	StatePath    string            `toml:"state_path"`
	SaveInterval duration.Duration `toml:"save_interval"` // Save nodes periodically
	OfflineAfter duration.Duration `toml:"offline_after"` // Set node to offline if not seen within this period
	PruneAfter   duration.Duration `toml:"prune_after"`   // Remove nodes after n days of inactivity
	Output       map[string]interface{}
}

Jump to

Keyboard shortcuts

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