tmcheck

package
v7.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 10 Imported by: 0

Documentation

Overview

package tmcheck contains utility functions for validating a Traffic Monitor is acting correctly.

Index

Constants

View Source
const PeerPollMax = time.Duration(10) * time.Second
View Source
const QueryIntervalMax = time.Duration(10) * time.Second
View Source
const RequestTimeout = time.Second * time.Duration(30)
View Source
const TrafficMonitorCRStatesPath = "/publish/CrStates"
View Source
const TrafficMonitorConfigDocPath = "/publish/ConfigDoc"
View Source
const TrafficMonitorDSStatsPath = "/publish/DsStats"
View Source
const TrafficMonitorStatsPath = "/publish/Stats"

Variables

This section is empty.

Functions

func AllMonitorsCRStatesOfflineValidator

func AllMonitorsCRStatesOfflineValidator(
	toClient *to.Session,
	interval time.Duration,
	includeOffline bool,
	grace time.Duration,
	onErr func(tc.TrafficMonitorName, error),
	onResumeSuccess func(tc.TrafficMonitorName),
	onCheck func(tc.TrafficMonitorName, error),
)

AllMonitorsCRStatesOfflineValidator is designed to be run as a goroutine, and does not return. It continously validates every `interval`, and calls `onErr` on failure, `onResumeSuccess` when a failure ceases, and `onCheck` on every poll. Note the error passed to `onErr` may be a general validation error not associated with any monitor, in which case the passed `tc.TrafficMonitorName` will be empty.

func AllMonitorsDSStatsValidator

func AllMonitorsDSStatsValidator(
	toClient *to.Session,
	interval time.Duration,
	includeOffline bool,
	grace time.Duration,
	onErr func(tc.TrafficMonitorName, error),
	onResumeSuccess func(tc.TrafficMonitorName),
	onCheck func(tc.TrafficMonitorName, error),
)

AllMonitorsDSStatsValidator is designed to be run as a goroutine, and does not return. It continously validates every `interval`, and calls `onErr` on failure, `onResumeSuccess` when a failure ceases, and `onCheck` on every poll. Note the error passed to `onErr` may be a general validation error not associated with any monitor, in which case the passed `tc.TrafficMonitorName` will be empty.

func AllMonitorsQueryIntervalValidator

func AllMonitorsQueryIntervalValidator(
	toClient *to.Session,
	interval time.Duration,
	includeOffline bool,
	grace time.Duration,
	onErr func(tc.TrafficMonitorName, error),
	onResumeSuccess func(tc.TrafficMonitorName),
	onCheck func(tc.TrafficMonitorName, error),
)

AllMonitorsQueryIntervalValidator is designed to be run as a goroutine, and does not return. It continously validates every `interval`, and calls `onErr` on failure, `onResumeSuccess` when a failure ceases, and `onCheck` on every poll. Note the error passed to `onErr` may be a general validation error not associated with any monitor, in which case the passed `tc.TrafficMonitorName` will be empty.

func AllValidator

func AllValidator(
	toClient *to.Session,
	interval time.Duration,
	includeOffline bool,
	grace time.Duration,
	onErr func(tc.TrafficMonitorName, error),
	onResumeSuccess func(tc.TrafficMonitorName),
	onCheck func(tc.TrafficMonitorName, error),
	validator func(toClient *to.Session, includeOffline bool) (map[tc.TrafficMonitorName]error, error),
)

func CRStatesOfflineValidator

func CRStatesOfflineValidator(
	tmURI string,
	toClient *to.Session,
	interval time.Duration,
	grace time.Duration,
	onErr func(error),
	onResumeSuccess func(),
	onCheck func(error),
)

CRStatesOfflineValidator is designed to be run as a goroutine, and does not return. It continously validates every `interval`, and calls `onErr` on failure, `onResumeSuccess` when a failure ceases, and `onCheck` on every poll.

func DSStatsValidator

func DSStatsValidator(
	tmURI string,
	toClient *to.Session,
	interval time.Duration,
	grace time.Duration,
	onErr func(error),
	onResumeSuccess func(),
	onCheck func(error),
)

DSStatsValidator is designed to be run as a goroutine, and does not return. It continously validates every `interval`, and calls `onErr` on failure, `onResumeSuccess` when a failure ceases, and `onCheck` on every poll.

func FilterOfflines

func FilterOfflines(servers []tc.Server) []tc.Server

FilterOfflines returns only servers which are REPORTED or ONLINE

func GetCDN

func GetCDN(uri string) (string, error)

GetCDN gets the CDN of the given Traffic Monitor.

func GetCDNs

func GetCDNs(servers []tc.Server) map[tc.CDNName]struct{}

func GetCRConfigs

func GetCRConfigs(cdns map[tc.CDNName]struct{}, toClient *to.Session) map[tc.CDNName]CRConfigOrError

func GetCRStates

func GetCRStates(uri string) (*tc.CRStates, error)

GetCRStates gets the CRStates from the given Traffic Monitor.

func GetDSStats

func GetDSStats(uri string) (*dsdata.StatsOld, error)

GetDSStats gets the DSStats from the given Traffic Monitor.

func GetMonitors

func GetMonitors(toClient *to.Session, includeOffline bool) ([]tc.Server, error)

func GetOldestPolledPeerTime

func GetOldestPolledPeerTime(uri string) (time.Duration, error)

func GetStats

func GetStats(uri string) (*datareq.Stats, error)

GetStats gets the stats from the given Traffic Monitor.

func PeerPollersAllValidator

func PeerPollersAllValidator(
	toClient *to.Session,
	interval time.Duration,
	includeOffline bool,
	grace time.Duration,
	onErr func(tc.TrafficMonitorName, error),
	onResumeSuccess func(tc.TrafficMonitorName),
	onCheck func(tc.TrafficMonitorName, error),
)

func PeerPollersValidator

func PeerPollersValidator(
	tmURI string,
	toClient *to.Session,
	interval time.Duration,
	grace time.Duration,
	onErr func(error),
	onResumeSuccess func(),
	onCheck func(error),
)

func QueryIntervalValidator

func QueryIntervalValidator(
	tmURI string,
	toClient *to.Session,
	interval time.Duration,
	grace time.Duration,
	onErr func(error),
	onResumeSuccess func(),
	onCheck func(error),
)

QueryIntervalValidator is designed to be run as a goroutine, and does not return. It continously validates every `interval`, and calls `onErr` on failure, `onResumeSuccess` when a failure ceases, and `onCheck` on every poll.

func ValidateAllMonitorsDSStats

func ValidateAllMonitorsDSStats(toClient *to.Session, includeOffline bool) (map[tc.TrafficMonitorName]error, error)

ValidateAllMonitorDSStats validates, for all monitors in the given Traffic Ops, DSStats contains all Delivery Services in the CRConfig.

func ValidateAllMonitorsOfflineStates

func ValidateAllMonitorsOfflineStates(toClient *to.Session, includeOffline bool) (map[tc.TrafficMonitorName]error, error)

ValidateOfflineStates validates that no OFFLINE or ADMIN_DOWN caches in the given Traffic Ops' CRConfig are marked Available in the given Traffic Monitor's CRStates.

func ValidateAllMonitorsQueryInterval

func ValidateAllMonitorsQueryInterval(toClient *to.Session, includeOffline bool) (map[tc.TrafficMonitorName]error, error)

ValidateAllMonitorsQueryInterval validates, for all monitors in the given Traffic Ops, an acceptable query interval 95th percentile.

func ValidateAllPeerPollers

func ValidateAllPeerPollers(toClient *to.Session, includeOffline bool) (map[tc.TrafficMonitorName]error, error)

func ValidateCRStates

func ValidateCRStates(crstates *tc.CRStates, crconfig *tc.CRConfig) error

ValidateCRStates validates that no OFFLINE or ADMIN_DOWN caches in the given CRConfig are marked Available in the given CRStates.

func ValidateDSStats

func ValidateDSStats(tmURI string, toClient *to.Session) error

ValidateDSStates validates that all Delivery Services in the CRConfig exist in given Traffic Monitor's DSStats. Existence in DSStats is useful to verify, because "Available: false" in CRStates

func ValidateDSStatsData

func ValidateDSStatsData(dsStats *dsdata.StatsOld, crconfig *tc.CRConfig) error

ValidateDSStatsData validates that all delivery services in the given CRConfig with caches assigned exist in the given DSStats.

func ValidateDSStatsWithCDN

func ValidateDSStatsWithCDN(tmURI string, tmCDN string, toClient *to.Session) error

ValidateOfflineStatesWithCDN validates per ValidateOfflineStates, but saves an additional query if the Traffic Monitor's CDN is known.

func ValidateDSStatsWithCRConfig

func ValidateDSStatsWithCRConfig(tmURI string, crConfig *tc.CRConfig, toClient *to.Session) error

ValidateOfflineStatesWithCRConfig validates per ValidateOfflineStates, but saves querying the CRconfig if it's already fetched.

func ValidateOfflineStates

func ValidateOfflineStates(tmURI string, toClient *to.Session) error

ValidateOfflineStates validates that no OFFLINE or ADMIN_DOWN caches in the given Traffic Ops' CRConfig are marked Available in the given Traffic Monitor's CRStates.

func ValidateOfflineStatesWithCDN

func ValidateOfflineStatesWithCDN(tmURI string, tmCDN string, toClient *to.Session) error

ValidateOfflineStatesWithCDN validates per ValidateOfflineStates, but saves an additional query if the Traffic Monitor's CDN is known.

func ValidateOfflineStatesWithCRConfig

func ValidateOfflineStatesWithCRConfig(tmURI string, crConfig *tc.CRConfig, toClient *to.Session) error

ValidateOfflineStatesWithCRConfig validates per ValidateOfflineStates, but saves querying the CRconfig if it's already fetched.

func ValidatePeerPoller

func ValidatePeerPoller(uri string) error

func ValidateQueryInterval

func ValidateQueryInterval(tmURI string, toClient *to.Session) error

ValidateQueryInterval validates the given monitor has an acceptable Query Interval 95th percentile.

func Validator

func Validator(
	tmURI string,
	toClient *to.Session,
	interval time.Duration,
	grace time.Duration,
	onErr func(error),
	onResumeSuccess func(),
	onCheck func(error),
	validator func(tmURI string, toClient *to.Session) error,
)

CRStatesOfflineValidator is designed to be run as a goroutine, and does not return. It continously validates every `interval`, and calls `onErr` on failure, `onResumeSuccess` when a failure ceases, and `onCheck` on every poll.

Types

type AllValidatorFunc

type AllValidatorFunc func(
	toClient *to.Session,
	interval time.Duration,
	includeOffline bool,
	grace time.Duration,
	onErr func(tc.TrafficMonitorName, error),
	onResumeSuccess func(tc.TrafficMonitorName),
	onCheck func(tc.TrafficMonitorName, error),
)

type CRConfigOrError

type CRConfigOrError struct {
	CRConfig *tc.CRConfig
	Err      error
}

CRConfigOrError contains a CRConfig or an error. Union types? Monads? What are those?

type TrafficMonitorConfigDoc

type TrafficMonitorConfigDoc struct {
	CDN string `json:"cdnName"`
}

TrafficMonitorConfigDoc represents the JSON returned by Traffic Monitor's ConfigDoc endpoint. This currently only contains the CDN member, as needed by this library.

type ValidatorFunc

type ValidatorFunc func(
	tmURI string,
	toClient *to.Session,
	interval time.Duration,
	grace time.Duration,
	onErr func(error),
	onResumeSuccess func(),
	onCheck func(error),
)

Jump to

Keyboard shortcuts

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