util

package
v2.0.0-...-2eb15ab Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IsCollector = map[string]struct{}{
	"ZapiPerf":    {},
	"Zapi":        {},
	"Rest":        {},
	"RestPerf":    {},
	"KeyPerf":     {},
	"Ems":         {},
	"StorageGrid": {},
	"Unix":        {},
	"Simple":      {},
}
View Source
var IsONTAPCollector = map[string]struct{}{
	"ZapiPerf": {},
	"Zapi":     {},
	"Rest":     {},
	"RestPerf": {},
	"KeyPerf":  {},
	"Ems":      {},
}

Functions

func AddIntString

func AddIntString(input string, value int) string

func AllSame

func AllSame(elements [][]string, k int) bool

func ArrayMetricToString

func ArrayMetricToString(value string) string

func Avg

func Avg(input []float64) float64

func CheckCert

func CheckCert(certPath string, name string, configPath string, logger *slog.Logger)

func CheckFreePorts

func CheckFreePorts(address string, ports []int) map[int]struct{}

func EncodeURL

func EncodeURL(href string) (string, error)

func FindLocalIP

func FindLocalIP() (string, error)

func GetCollectorSlice

func GetCollectorSlice() []string

func GetQueryParam

func GetQueryParam(href string, query string) (string, error)

func GetURLWithoutHost

func GetURLWithoutHost(r *http.Request) string

func HandleArrayFormat

func HandleArrayFormat(name string) string

func HasDuplicates

func HasDuplicates(slice []string) bool

func Intersection

func Intersection(a []string, b []string) ([]string, []string)

Intersection returns things from b that are common and missing with a

func IsPublicAPI

func IsPublicAPI(query string) bool

IsPublicAPI returns false if api endpoint has private keyword in it else true

func Max

func Max(input []float64) float64

Max returns 0 when passed an empty slice, slices.Max panics if input is empty, This function can be removed once all callers are checked for empty slices

func MaxLen

func MaxLen(elements [][]string) int

func Min

func Min(input []float64) float64

Min returns 0 when passed an empty slice, slices.Min panics if input is empty, This function can be removed once all callers are checked for empty slices

func MinLen

func MinLen(elements [][]string) int

func ParseMetric

func ParseMetric(rawName string) (string, string, string, string)

ParseMetric parses display name and type of field and metric type from the raw name of the metric as defined in (sub)template. Users can rename a metric with "=>" (e.g., some_long_metric_name => short). Trailing "^" characters are ignored/cleaned as they have special meaning in some collectors.

func ParseMetricType

func ParseMetricType(metricName string) (string, string)

func ParseZAPIDisplay

func ParseZAPIDisplay(obj string, path []string) string

func SafeConvertToInt32

func SafeConvertToInt32(in int) (int32, error)

func SaveConfig

func SaveConfig(fp string, token string) error

SaveConfig adds or updates the Grafana token in the harvest.yml config and saves it to fp. The Yaml marshaller is used so comments are preserved

func SumNumbers

func SumNumbers(s []float64) float64

func VersionAtLeast

func VersionAtLeast(currentVersion string, minVersion string) (bool, error)

VersionAtLeast checks if the provided currentVersion of the cluster is greater than or equal to the provided minimum version (minVersion).

Types

type Metadata

type Metadata struct {
	BytesRx         uint64
	NumCalls        uint64
	PluginInstances uint64
}

func (*Metadata) Reset

func (m *Metadata) Reset()

type PollerStatus

type PollerStatus struct {
	Name          string
	Status        Status
	Pid           int32
	ProfilingPort string
	PromPort      string
}

func GetPollerStatuses

func GetPollerStatuses() ([]PollerStatus, error)

type Status

type Status string
const (
	StatusStopped        Status = "stopped"
	StatusStoppingFailed Status = "stopping failed"
	StatusRunning        Status = "running"
	StatusNotRunning     Status = "not running"
	StatusKilled         Status = "killed"
	StatusAlreadyExited  Status = "already exited"
	StatusDisabled       Status = "disabled"
)

Jump to

Keyboard shortcuts

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