models

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2022 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDB

func CloseDB() error

CloseDB will close the database, only use when app closes.

func DeleteBwTestItemsBefore

func DeleteBwTestItemsBefore(before string) (int64, error)

DeleteBwTestItemsBefore operates on the DB to remote all bwtests rows which are more older than the 'before' epoch in ms.

func DeleteEchoItemsBefore

func DeleteEchoItemsBefore(before string) (int64, error)

DeleteEchoItemsBefore operates on the DB to remote all echo rows which are more older than the 'before' epoch in ms.

func DeleteTrHopItemsBefore

func DeleteTrHopItemsBefore(before string) (int64, error)

DeleteTrHopItemsBefore operates on the DB to remote all trhops rows which are more older than the 'before' epoch in ms.

func DeleteTracerouteItemsBefore

func DeleteTracerouteItemsBefore(before string) (int64, error)

DeleteTracerouteItemsBefore operates on the DB to remote all traceroute rows which are more older than the 'before' epoch in ms.

func InitDB

func InitDB(filepath string) error

InitDB controls the opening connection to the database.

func LoadDB

func LoadDB() error

LoadDB operates on the DB to load and/or migrate the database.

func MaintainDatabase

func MaintainDatabase()

MaintainDatabase is a goroutine that runs independanly to cleanup the database according to the defined schedule.

func StoreBwTestItem

func StoreBwTestItem(bwtest *BwTestItem) error

StoreBwTestItem operates on the DB to insert a BwTestItem.

func StoreEchoItem

func StoreEchoItem(echo *EchoItem) error

StoreEchoItem operates on the DB to insert a EchoItem.

func StoreTrHopItem

func StoreTrHopItem(hop *TrHopItem) error

StoreTrHopItem operates on the DB to insert a TrHopItem.

func StoreTracerouteItem

func StoreTracerouteItem(tr *TracerouteItem) error

StoreTracerouteItem operates on the DB to insert a TracerouteItem.

Types

type BwTestGraph

type BwTestGraph struct {
	Inserted       int64
	ActualDuration int
	CSBandwidth    int
	CSThroughput   int
	SCBandwidth    int
	SCThroughput   int
	Error          string
	Path           string
	Log            string
}

BwTestGraph reflects one row in the bwtests table with only the necessary items to display in a graph.

func ReadBwTestItemsSince

func ReadBwTestItemsSince(since string) ([]BwTestGraph, error)

ReadBwTestItemsSince operates on the DB to return all bwtests rows which are more recent than the 'since' epoch in ms.

type BwTestItem

type BwTestItem struct {
	Inserted       int64  // v0, ms
	ActualDuration int    // v0, ms
	CIa            string // v0
	CAddr          string // v0
	CPort          int    // v0
	SIa            string // v0
	SAddr          string // v0
	SPort          int    // v0
	CSDuration     int    // v0, ms
	CSPackets      int    // v0, packets
	CSPktSize      int    // v0, bytes
	CSBandwidth    int    // v0, bps
	CSThroughput   int    // v0, bps
	CSArrVar       int    // v0, ms
	CSArrAvg       int    // v0, ms
	CSArrMin       int    // v0, ms
	CSArrMax       int    // v0, ms
	SCDuration     int    // v0, ms
	SCPackets      int    // v0, packets
	SCPktSize      int    // v0, bytes
	SCBandwidth    int    // v0, bps
	SCThroughput   int    // v0, bps
	SCArrVar       int    // v0, ms
	SCArrAvg       int    // v0, ms
	SCArrMin       int    // v0, ms
	SCArrMax       int    // v0, ms
	Error          string // v0
	Path           string // v1
	Log            string // v2
}

BwTestItem reflects one row in the bwtests table with all columns.

func ReadBwTestItemsAll

func ReadBwTestItemsAll() ([]BwTestItem, error)

ReadBwTestItemsAll operates on the DB to return all bwtests rows.

func (BwTestItem) GetHeaders

func (bwtest BwTestItem) GetHeaders() []string

GetHeaders iterates the BwTestItem and returns struct variable names.

func (BwTestItem) ToSlice

func (bwtest BwTestItem) ToSlice() []string

ToSlice iterates the BwTestItem and returns struct values.

type CmdItem

type CmdItem interface {
	GetHeaders() []string
	ToSlice() []string
}

CmdItem could be either EchoItem or BwTestItem

type EchoGraph

type EchoGraph struct {
	Inserted       int64
	ActualDuration int
	ResponseTime   float32
	RunTime        float32
	PktLoss        int
	CmdOutput      string
	Error          string
	Path           string
}

EchoGraph reflects one row in the echo table with only the necessary items to display in a graph

func ReadEchoItemsSince

func ReadEchoItemsSince(since string) ([]EchoGraph, error)

ReadEchoItemsSince operates on the DB to return all echo rows which are more recent than the 'since' epoch in ms.

type EchoItem

type EchoItem struct {
	Inserted       int64 // ms Inserted time
	ActualDuration int   // ms
	CIa            string
	CAddr          string
	SIa            string
	SAddr          string
	Count          int     // Default 1
	Timeout        float32 // s Default 2
	Interval       float32 // s Default 1
	ResponseTime   float32 // ms
	RunTime        float32
	PktLoss        int    // percent Indicating pkt loss rate
	CmdOutput      string // command output
	Error          string
	Path           string
}

EchoItem reflects one row in the echo table with all columns

func ReadEchoItemsAll

func ReadEchoItemsAll() ([]EchoItem, error)

ReadEchoItemsAll operates on the DB to return all echo rows.

func (EchoItem) GetHeaders

func (echo EchoItem) GetHeaders() []string

GetHeaders iterates the EchoItem and returns struct variable names.

func (EchoItem) ToSlice

func (echo EchoItem) ToSlice() []string

ToSlice iterates the EchoItem and returns struct values.

type ReducedTrHopItem

type ReducedTrHopItem struct {
	HopIa     string
	HopAddr   string
	IntfID    int
	RespTime1 float32 // ms
	RespTime2 float32 // ms
	RespTime3 float32 // ms
}

Store only part of the TrHopItem information used for display in the graph

type TrHopItem

type TrHopItem struct {
	Inserted   int64 // ms Inserted time as primary key
	RunTimeKey int64 // ms, represent the inserted key in the corresponding entry in traceroute table
	Ord        int
	HopIa      string
	HopAddr    string
	IntfID     int
	RespTime1  float32 // ms
	RespTime2  float32 // ms
	RespTime3  float32 // ms
}

TrHopItem reflects one row in the Hop table with all columns.

func (TrHopItem) GetHeaders

func (hop TrHopItem) GetHeaders() []string

GetHeaders iterates the TrHopItem and returns struct variable names.

func (TrHopItem) ToSlice

func (hop TrHopItem) ToSlice() []string

ToSlice iterates the TrHopItem and returns struct values.

type TracerouteGraph

type TracerouteGraph struct {
	Inserted       int64
	ActualDuration int
	TrHops         []ReducedTrHopItem
	CmdOutput      string // command output
	Error          string
	Path           string
}

parse the result SQL query first in TracerouteHelper structs and then convert them into TracerouteGraph in order to avoid redundancy

func ReadTracerouteItemsSince

func ReadTracerouteItemsSince(since string) ([]TracerouteGraph, error)

ReadTracerouteItemsSince operates on the DB to return all rows in traceroute join trhops which are more recent than the 'since' epoch in ms.

type TracerouteHelper

type TracerouteHelper struct {
	Inserted       int64 // ms Inserted time of the TracerouteItem
	ActualDuration int   // ms
	Ord            int
	HopIa          string
	HopAddr        string
	IntfID         int
	RespTime1      float32 // ms
	RespTime2      float32 // ms
	RespTime3      float32 // ms
	CmdOutput      string  // command output
	Error          string
	Path           string
}

TracerouteHelper reflects one row in the Traceroute table joint with Hop table with only the necessary items to display in a graph.

type TracerouteItem

type TracerouteItem struct {
	Inserted       int64 // ms Inserted time as primary key
	ActualDuration int   // ms
	CIa            string
	CAddr          string
	SIa            string
	SAddr          string
	Timeout        float32 // s Default 2
	CmdOutput      string  // command output
	Error          string
	Path           string
}

TracerouteItem reflects one row in the Traceroute table with all columns.

func ReadTracerouteItemsAll

func ReadTracerouteItemsAll() ([]TracerouteItem, error)

ReadTracerouteItemsAll operates on the DB to return all traceroute rows.

func (TracerouteItem) GetHeaders

func (tr TracerouteItem) GetHeaders() []string

GetHeaders iterates the TracerouteItem and returns struct variable names.

func (TracerouteItem) ToSlice

func (tr TracerouteItem) ToSlice() []string

ToSlice iterates the TracerouteItem and returns struct values.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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