stats

package
v0.0.0-...-5e75ab2 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PortStatsTxPrefix = "ptp.sptp.portstats.tx."
	PortStatsRxPrefix = "ptp.sptp.portstats.rx."
)

port stats prefixes

Variables

This section is empty.

Functions

func FetchPortStats

func FetchPortStats(url string) (tx map[string]uint64, rx map[string]uint64, err error)

FetchPortStats fetches all counters and then returns two maps: packet type to counter, TX and RX

func FetchSysStats

func FetchSysStats(url string) (map[string]int64, error)

FetchSysStats fetches all counters and return sys stats from them

Types

type Counters

type Counters map[string]int64

Counters is various counters exported by SPTP client

func FetchCounters

func FetchCounters(url string) (Counters, error)

FetchCounters returns counters map fetched from the url

func (Counters) PortStats

func (c Counters) PortStats() (tx map[string]uint64, rx map[string]uint64)

PortStats returns two maps: packet type to counter, TX and RX

func (Counters) SysStats

func (c Counters) SysStats() map[string]int64

SysStats return sys stats from counters

type PrometheusExporter

type PrometheusExporter struct {
	// contains filtered or unexported fields
}

PrometheusExporter holds the exporter details

func NewPrometheusExporter

func NewPrometheusExporter(listenPort int, sptpPort int, scrapeInterval time.Duration) *PrometheusExporter

NewPrometheusExporter creates a new instance of PrometheusExporter

func (*PrometheusExporter) Start

func (e *PrometheusExporter) Start()

Start starts the exporter

type Stat

type Stat struct {
	GMAddress         string           `json:"gm_address"`
	ClockQuality      ptp.ClockQuality `json:"clock_quality"`
	Error             string           `json:"error"`
	GMPresent         int              `json:"gm_present"`
	IngressTime       int64            `json:"ingress_time"`
	MeanPathDelay     float64          `json:"mean_path_delay"`
	Offset            float64          `json:"offset"`
	PortIdentity      string           `json:"port_identity"`
	Priority1         uint8            `json:"priority1"`
	Priority2         uint8            `json:"priority2"`
	Priority3         uint8            `json:"priority3"`
	Selected          bool             `json:"selected"`
	StepsRemoved      int              `json:"steps_removed"`
	CorrectionFieldRX int64            `json:"cf_rx"`
	CorrectionFieldTX int64            `json:"cf_tx"`
	C2SDelay          int64            `json:"client_server_delay"`
	S2CDelay          int64            `json:"server_client_delay"`
}

Stat is a representation of a monitoring struct for sptp client

type Stats

type Stats []*Stat

Stats is a list of Stat

func FetchStats

func FetchStats(url string) (Stats, error)

FetchStats returns populated Stats structure fetched from the url

func (Stats) Index

func (s Stats) Index(e *Stat) int

Index returns the index of the e if it's already in s. Otherwise -1

func (Stats) Len

func (s Stats) Len() int

func (Stats) Less

func (s Stats) Less(i, j int) bool

func (Stats) Swap

func (s Stats) Swap(i, j int)

Jump to

Keyboard shortcuts

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