app

package
v0.0.0-...-7c73390 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Config struct {
	Interfaces   []string
	DatabaseDir  string
	SaveInterval time.Duration
	Listen       string
	AuthUser     string
	AuthPass     string
	SSLCert      string
	SSLKey       string
}

Config struct

View Source
var (
	// DB is the global database variable
	DB = make(map[string]DBStruct)
)

Functions

func AddStat

func AddStat(nwIf, date string, rx, tx int64)

AddStat will set a statistic to the database.

func BasicAuthFromFile

func BasicAuthFromFile(filePath string) error

BasicAuthFromFile opens a file and sets a global user/password if a line with two words is found

func IFStat

func IFStat(nwIf string) (int64, int64, error)

IFStat returns the current of rx & tx values from network interface

func InitInterfaces

func InitInterfaces(cmd *cobra.Command) error

InitInterfaces will set a slice of config interfaces from the cmd

func LoadStats

func LoadStats(nwIf string) error

LoadStats will load any existing CSV files for a matching network interface

func SaveStats

func SaveStats()

SaveStats will save the running stats to CSV files

func StartHTTP

func StartHTTP()

StartHTTP starts and HTTP server

func SyncNwInterfaces

func SyncNwInterfaces()

SyncNwInterfaces will log each interface to the global DB if either the RX or TX > 0

Types

type DBStruct

type DBStruct struct {
	Daily   []Stat
	Monthly []Stat
}

DBStruct represents the database layout for an interface

type InterfaceLog

type InterfaceLog struct {
	RX int64
	TX int64
}

InterfaceLog struct stores each interface's previous stats to calculate difference

type JSONReturn

type JSONReturn struct {
	If string
	Rx int64
	Tx int64
}

JSONReturn struct

type Stat

type Stat struct {
	Date string
	RX   int64
	TX   int64
}

Stat struct stores each statistic

type Statistic

type Statistic struct {
	Date string
	RX   int64
	TX   int64
}

Statistic struct

Jump to

Keyboard shortcuts

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