Documentation
¶
Index ¶
- Constants
- Variables
- type Cache
- type Count
- func (n *Count) Bytes() ([]byte, error)
- func (n *Count) DeserializeFrom(d []byte) error
- func (n *Count) GetCount() int
- func (n *Count) GetTimestamp() time.Time
- func (n *Count) Key() []byte
- func (n *Count) SetCount(count int)
- func (n *Count) SetKey(k []byte)
- func (n *Count) SetTimestamp(timestamp time.Time)
- type CountMeshClients
- type CountMeshNodes
- type CountNodeClients
- type Counter
- type Gateway
- type GraphJSON
- type GraphJSONBatAdv
- type GraphJSONLink
- type GraphJSONNode
- type LogSample
- type NodeDB
- func (db *NodeDB) ExportNodeInfo(w io.Writer)
- func (db *NodeDB) ExportStatistics(w io.Writer)
- func (db *NodeDB) ExportVisData(w io.Writer)
- func (db *NodeDB) ForEachLogEntry(logitem Counter, handler func() (bool, error)) error
- func (db *NodeDB) GenerateGraphJSON(w io.Writer)
- func (db *NodeDB) GenerateLogJSON(w io.Writer, logitem Counter) error
- func (db *NodeDB) GenerateLogList(w io.Writer) error
- func (db *NodeDB) GenerateLogitemSamplesJSON(w io.Writer, logitem Counter, start time.Time, over time.Duration, samples int) error
- func (db *NodeDB) GenerateNodesJSON(w io.Writer, offlineDuration time.Duration)
- func (db *NodeDB) GenerateNodesOldJSON(w io.Writer, offlineDuration time.Duration)
- func (db *NodeDB) GetLogSamples(logitem Counter, start time.Time, over time.Duration, samples int, ...) error
- func (db *NodeDB) ImportNodes(r io.Reader, persistent bool) error
- func (db *NodeDB) ImportNodesFile(filename string, persistent bool) error
- func (db *NodeDB) LogCounts(offlineAfter time.Duration)
- func (db *NodeDB) NewNodeID(tx *bolt.Tx, nodeid string, alias []byte) error
- func (db *NodeDB) ResolveNodeID(tx *bolt.Tx, mac alfred.HardwareAddr) (string, bool)
- func (db *NodeDB) StartLogger(offlineAfter time.Duration)
- func (db *NodeDB) StartPurger(gluonpurgeint, vispurgeint time.Duration)
- func (db *NodeDB) StartUpdater(client *alfred.Client, updatewait, retrywait time.Duration)
- func (db *NodeDB) StopLogger()
- func (db *NodeDB) StopPurger()
- func (db *NodeDB) StopUpdater()
- func (db *NodeDB) UpdateNodeInfo(i *NodeInfo, persistent bool) error
- func (db *NodeDB) UpdateStatistics(s *Statistics) error
- func (db *NodeDB) UpdateVisData(v *VisData) error
- type NodeID
- type NodeInfo
- type NodesJSON
- type NodesJSONData
- type NodesJSONFlags
- type NodesJSONStatistics
- type NodesJSONTime
- type NodesOldJSON
- type NodesOldJSONData
- type NodesOldJSONFlags
- type NodesOldJSONLink
- type NodesOldJSONMeta
- type Statistics
- type VisData
Constants ¶
const ( // log this client count for offline nodes NODE_OFFLINE = -1 // log this if the client statistics data cannot be parsed NODE_DATAERROR = -2 )
const ( // time.Time format string for what we like the JSON Marshaled // variant to look like NodesJSONTimeStamp = `"2006-01-02T15:04:05"` )
Variables ¶
var DefaultValidityGluon = time.Hour * 24 * 30
var DefaultValidityVis = time.Minute * 20
var ErrInvalid = errors.New("invalid data")
var ErrUnknownVersion = errors.New("Unknown data format version")
Functions ¶
This section is empty.
Types ¶
type Count ¶
func (*Count) DeserializeFrom ¶
func (*Count) GetTimestamp ¶
func (*Count) SetTimestamp ¶
type CountMeshClients ¶
type CountMeshClients struct{ Count }
func (*CountMeshClients) StoreID ¶
func (c *CountMeshClients) StoreID() []byte
type CountMeshNodes ¶
type CountMeshNodes struct{ Count }
func (*CountMeshNodes) StoreID ¶
func (c *CountMeshNodes) StoreID() []byte
type CountNodeClients ¶
func NewCountNodeClients ¶
func NewCountNodeClients(node string, timestamp time.Time, count int) *CountNodeClients
func (*CountNodeClients) StoreID ¶
func (c *CountNodeClients) StoreID() []byte
type GraphJSON ¶
type GraphJSON struct {
Version int `json:"version,omitempty"`
BatAdv GraphJSONBatAdv `json:"batadv"`
}
Type corresponding to a full graph.json document
type GraphJSONBatAdv ¶
type GraphJSONBatAdv struct {
Directed bool `json:"directed"`
Graph []struct{} `json:"graph"`
Nodes []GraphJSONNode `json:"nodes"`
Links []GraphJSONLink `json:"links"`
}
batadv subelement in graph.json document
type GraphJSONLink ¶
type GraphJSONLink struct {
Source int `json:"source"`
Vpn bool `json:"vpn"`
Bidirect bool `json:"bidirect"`
Target int `json:"target"`
Tq float64 `json:"tq"`
}
Information about a link. Especially stupid design is the numerical indexing based on the list index of the corresponding node information.
type GraphJSONNode ¶
type GraphJSONNode struct {
NodeID string `json:"node_id,omitempty"`
ID alfred.HardwareAddr `json:"id"`
Number int `json:"number"`
}
Information about the existence of a mesh node
func NewGraphJSONNode ¶
func NewGraphJSONNode(id alfred.HardwareAddr, nodeid string, number int) GraphJSONNode
func NewGraphJSONNodeIDonly ¶
func NewGraphJSONNodeIDonly(id alfred.HardwareAddr, number int) GraphJSONNode
type LogSample ¶
type LogSample struct {
// the start of the sample is the point in time from where we are going
// backwards, i.e. into the past
Start time.Time
// part of the sample that the logged instance is considered offline
Offline float64
// part of the sample that the logged instance gave us invalid data
Errorneous float64
// a weighted (by the duration of it being valid) average of the log count
WeightedAverage float64
// minimum count within sample time
Min float64
// maximum count within sample time
Max float64
}
a sample of log data
type NodeDB ¶
type NodeDB struct {
Main *store.DB
Logs *store.DB
NotifyPurgeVis *topic.Topic
NotifyUpdateNodeInfo *topic.Topic
NotifyUpdateStatistics *topic.Topic
NotifyUpdateVis *topic.Topic
NotifyQuitUpdater *topic.Topic
NotifyQuitPurger *topic.Topic
NotifyQuitLogger *topic.Topic
// contains filtered or unexported fields
}
func (*NodeDB) ExportNodeInfo ¶
func (*NodeDB) ExportStatistics ¶
func (*NodeDB) ExportVisData ¶
func (*NodeDB) ForEachLogEntry ¶
fetch raw log data
handler function might return "true" to abort reading further
func (*NodeDB) GenerateGraphJSON ¶
Write a full graph.json document based on the contents of the database.
func (*NodeDB) GenerateLogJSON ¶
Wrapper to generate JSON output for raw log data
func (*NodeDB) GenerateLogList ¶
generate a JSON list of nodes for which there is log data available
func (*NodeDB) GenerateLogitemSamplesJSON ¶
func (db *NodeDB) GenerateLogitemSamplesJSON(w io.Writer, logitem Counter, start time.Time, over time.Duration, samples int) error
generate a JSON list of samples
func (*NodeDB) GenerateNodesJSON ¶
Write a full nodes.json style document based on the current database contents.
func (*NodeDB) GenerateNodesOldJSON ¶
Write a full nodes.json style document based on the current database contents.
func (*NodeDB) GetLogSamples ¶
func (db *NodeDB) GetLogSamples(logitem Counter, start time.Time, over time.Duration, samples int, handler func(sample LogSample)) error
sample log data into a certain amount of samples, starting at a fixed point in time and going backwards from there, covering a given overall duration to take samples of
For the reader of the following code: take your time, and read the documentation within the code carefully.
func (*NodeDB) ImportNodes ¶
read nodes.json compatible data into database
func (*NodeDB) ImportNodesFile ¶
read nodes.json file into database
func (*NodeDB) LogCounts ¶
Will wait for update notifications and upon receiving them, run a count of the data items to be logged. Only one count will be run at any time. When notifications arrive during a count is running, another count will be run as soon the current one is done.
func (*NodeDB) ResolveNodeID ¶
func (*NodeDB) StartLogger ¶
func (*NodeDB) StartPurger ¶
func (*NodeDB) StartUpdater ¶
func (*NodeDB) StopLogger ¶
func (db *NodeDB) StopLogger()
func (*NodeDB) StopPurger ¶
func (db *NodeDB) StopPurger()
func (*NodeDB) StopUpdater ¶
func (db *NodeDB) StopUpdater()
func (*NodeDB) UpdateNodeInfo ¶
func (*NodeDB) UpdateStatistics ¶
func (db *NodeDB) UpdateStatistics(s *Statistics) error
func (*NodeDB) UpdateVisData ¶
type NodeInfo ¶
type NodeInfo struct {
store.ContainedKey
gluon.NodeInfo
}
func (*NodeInfo) DeserializeFrom ¶
type NodesJSON ¶
type NodesJSON struct {
Timestamp NodesJSONTime `json:"timestamp"`
Nodes map[string]*NodesJSONData `json:"nodes"`
Version int `json:"version,omitempty"`
}
Base type for the nodes.json document
type NodesJSONData ¶
type NodesJSONData struct {
// wrap gluon.NodeInfoData
NodeInfo gluon.NodeInfoData `json:"nodeinfo,omitempty"`
Flags NodesJSONFlags `json:"flags,omitempty"`
FirstSeen NodesJSONTime `json:"firstseen,omitempty"`
LastSeen NodesJSONTime `json:"lastseen,omitempty"`
Statistics NodesJSONStatistics `json:"statistics,omitempty"`
}
Type for the data of a single Mesh node
type NodesJSONFlags ¶
type NodesJSONStatistics ¶
type NodesJSONTime ¶
Wrapped time.Time type to provide JSON Marshaling as we like it to be
func (NodesJSONTime) MarshalJSON ¶
func (t NodesJSONTime) MarshalJSON() ([]byte, error)
provide interface for JSON serialization
func (*NodesJSONTime) UnmarshalJSON ¶
func (t *NodesJSONTime) UnmarshalJSON(tval []byte) error
provide interface for JSON serialization
type NodesOldJSON ¶
type NodesOldJSON struct {
Meta NodesOldJSONMeta `json:"meta"`
Nodes []*NodesOldJSONData `json:"nodes"`
Links []*NodesOldJSONLink `json:"links"`
}
Base type for the nodes.json document
type NodesOldJSONData ¶
type NodesOldJSONData struct {
Id string `json:"id"`
Name *string `json:"name"`
LastSeen int64 `json:"lastseen"`
Uptime float64 `json:"uptime"`
Geo []float64 `json:"geo,omitempty"`
ClientCount int `json:"clientcount"`
BatmanVersion *string `json:"batman_version"`
BatmanGWMode *string `json:"batman_gwmode"`
Group *string `json:"group"`
Flags NodesOldJSONFlags `json:"flags"`
AutoUpdaterState bool `json:"autoupdater_state"`
AutoUpdaterBranch string `json:"autoupdater_branch"`
Hardware string `json:"hardware,omitempty"`
Firmware *string `json:"firmware"`
GluonBase string `json:"gluon_base,omitempty"`
Gateway *alfred.HardwareAddr `json:"gateway,omitempty"`
Addresses []net.IP `json:"addresses,omitempty"`
}
Type for the data of a single Mesh node
type NodesOldJSONFlags ¶
type NodesOldJSONLink ¶
type NodesOldJSONMeta ¶
type NodesOldJSONMeta struct {
Timestamp NodesJSONTime `json:"timestamp"`
GluonRelease string `json:"gluon_release,omitempty"`
}
type Statistics ¶
type Statistics struct {
store.ContainedKey
gluon.Statistics
}
func (*Statistics) Bytes ¶
func (s *Statistics) Bytes() ([]byte, error)
func (*Statistics) DeserializeFrom ¶
func (s *Statistics) DeserializeFrom(b []byte) error
func (*Statistics) Key ¶
func (s *Statistics) Key() []byte
func (*Statistics) StoreID ¶
func (n *Statistics) StoreID() []byte
type VisData ¶
type VisData struct {
store.ContainedKey
batadvvis.VisV1
}