v1.5.0 Latest Latest

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

Go to latest
Published: Sep 21, 2023 License: AGPL-3.0 Imports: 9 Imported by: 4




View Source
const (
	GLOBAL_SITE          = "global"
	GLOBAL_DOMAIN        = "global"


This section is empty.


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

func SaveJSONL added in v1.2.1

func SaveJSONL(input []interface{}, outputFile string)

Save a slice of json objects as line-encoded JSON (JSONL) to a path.


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
	ClientsOWE    uint32
	ClientsOWE24  uint32
	ClientsOWE5   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
	SourceHostname string
	SourceAddress  string
	TargetID       string
	TargetAddress  string
	TargetHostname 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:"-"`
	CustomFields map[string]interface{} `json:"custom_fields"`

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

	// 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