stats

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2019 License: GPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PluginNfqueueHandler

func PluginNfqueueHandler(mess dispatch.NfqueueMessage, ctid uint32, newSession bool) dispatch.NfqueueResult

PluginNfqueueHandler is called to handle nfqueue packet data.

func PluginShutdown

func PluginShutdown()

PluginShutdown function called when the daemon is shutting down.

func PluginStartup

func PluginStartup()

PluginStartup function is called to allow plugin specific initialization.

func WriteStatsJSON

func WriteStatsJSON(p ParentJSON)

WriteStatsJSON writes the json object to /tmp/stats.json

Types

type Collector

type Collector struct {
	Latency1Min     ExponentialAverage
	Latency5Min     ExponentialAverage
	Latency15Min    ExponentialAverage
	LatencyVariance RunningVariance
}

Collector collects all the stats for a given interface

func CreateCollector

func CreateCollector() *Collector

CreateCollector creates a new collector

func (*Collector) AddDataPoint

func (c *Collector) AddDataPoint(value float64)

AddDataPoint adds a new datapoint to a collector if it falls within the std deviation limit

func (*Collector) AddDataPointLimited

func (c *Collector) AddDataPointLimited(value float64, deviationLimit float64)

AddDataPointLimited adds a new datapoint to a collector if it falls within the std deviation limit

func (*Collector) MakeCopy

func (c *Collector) MakeCopy() Collector

MakeCopy makes a copy of the collector

type ExponentialAverage

type ExponentialAverage struct {
	TimeframeMilliSeconds  float64
	Value                  float64
	LastDatapointTimestamp time.Time
	CreationTime           time.Time
}

ExponentialAverage tallies an running exponential average

func (*ExponentialAverage) AdjustExpAvg

func (ea *ExponentialAverage) AdjustExpAvg(value float64)

AdjustExpAvg adjust the exponential running average with the new datapoint

func (*ExponentialAverage) String

func (ea *ExponentialAverage) String() string

type InterfaceStatsJSON

type InterfaceStatsJSON struct {
	InterfaceID int             `json:"interfaceId"`
	Stats       []StatisticJSON `json:"stats"`
}

InterfaceStatsJSON stores all stats for an interface

func MakeInterfaceStatsJSON

func MakeInterfaceStatsJSON(interfaceID int, latency1 float64, latency5 float64, latency15 float64) InterfaceStatsJSON

MakeInterfaceStatsJSON makes an InterfaceStatsJSON

type MetricJSON

type MetricJSON struct {
	Name  string  `json:"name"`
	Value float64 `json:"value"`
}

MetricJSON stores an individual metric for a stat

type ParentJSON

type ParentJSON struct {
	Version    int                  `json:"version"`
	Interfaces []InterfaceStatsJSON `json:"interfaces"`
}

ParentJSON stores all stats written to file

func MakeStatsJSON

func MakeStatsJSON(interfaceStats []InterfaceStatsJSON) ParentJSON

MakeStatsJSON makes a ParentJSON object

type RunningVariance

type RunningVariance struct {
	Alpha        float64 // 0.0 -> 1.0
	Mean         float64
	Variance     float64
	StdDeviation float64
}

RunningVariance tallies an running variance

func (*RunningVariance) AdjustVariance

func (rv *RunningVariance) AdjustVariance(value float64)

AdjustVariance adjust the variance with a new datapoint Adjust the variance with a new datapoint http://people.ds.cam.ac.uk/fanf2/hermes/doc/antiforgery/stats.pdf

func (*RunningVariance) String

func (rv *RunningVariance) String() string

type StatisticJSON

type StatisticJSON struct {
	Name    string       `json:"name"`
	Unit    string       `json:"unit"`
	Metrics []MetricJSON `json:"metrics"`
}

StatisticJSON stores an individual stat

func MakeStatisticJSON

func MakeStatisticJSON(name string, unit string, metrics []MetricJSON) StatisticJSON

MakeStatisticJSON makes a StatisticJSON

Jump to

Keyboard shortcuts

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