hoststat

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package hoststat offers host connection quality statistics and predefined sorts.

Index

Constants

View Source
const EwmaSlide int = 10

EwmaSlide is the EWMA window size.

Variables

This section is empty.

Functions

This section is empty.

Types

type HostStat

type HostStat struct {
	Value float64   `json:"v"`
	Count int       `json:"n"`
	Time  time.Time `json:"t"`
	// contains filtered or unexported fields
}

HostStat is a single HostStat.

type HostStats

type HostStats struct {
	sync.RWMutex
	Stats          map[string]*HostStat
	Validity       time.Duration
	BackupInterval time.Duration
	LastRecount    time.Time
}

HostStats holds all HostStats.

func MapStatsFile

func MapStatsFile(file string, validity time.Duration) (hs *HostStats)

MapStatsFile loads HostStats from a file, and save back the new results periodically.

func (*HostStats) Cleanup

func (hs *HostStats) Cleanup()

Cleanup cleans expired stats up, and reset the stat periodically.

func (*HostStats) GetStat added in v0.1.3

func (hs *HostStats) GetStat(h string) (stat HostStat)

GetStat gets the HostStat.

func (*HostStats) Load

func (hs *HostStats) Load(file string)

Load HostStats from a file.

func (*HostStats) Save

func (hs *HostStats) Save(file string)

Save HostStats to a file.

func (*HostStats) Update

func (hs *HostStats) Update(h string, v float64)

Update a host's stat by new value.

Jump to

Keyboard shortcuts

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