stat

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultHeartBeatLoggingInterval     uint = 15 * 60 // 15 minutes
	DefaultSystemMetricsLoggingInterval uint = 30 * 60 // 30 minutes
	MinimumHeartBeatLoggingInterval     uint = 10      // 10 seconds
	MinimumSystemMetricsLoggingInterval uint = 10      // 10 seconds
)

ExampleConfig:

"stat": {
    "verbose": false,
    "logging_interval":{
      "heartbeat":60,
      "system_metrics":20
    },
    "trigger":[{
      "measurement":"LoadAverage",
      "field":"LoadAvg1",
      "value":0.2,
      "sign":">="
    },
    {
      "measurement":"MemoryUsage",
      "field":"UsedPercent",
      "value":20,
      "sign":">="
    }
  ]
  }
  1. Stat service does not run if "stat" key-value pair is not mentioned in config
  2. Stat service runs with default config if "stat" key is present but value is empty i.e. "stat":{}
  3. If fields Verbose, LoggingInterval, Trigger is not specified in config, then default value for those configs are used
  4. For fields: heartbeat and system_metrics of logging_interval, following holds true for each If unspecified, use default config value If specified and set to 0, disable logging If specified and >0 && < minimum, enable logging and set interval to minimum Else , enable logging and set interval to that provided in config

CHECK ensureConfig() for detail

Functions

This section is empty.

Types

type DiskUsage

type DiskUsage struct {
	DiskUsagePerMount []*DiskUsagePerMount `json:"DiskUsagePerMount"`
}

type DiskUsagePerMount

type DiskUsagePerMount struct {
	FileSystem  string  `json:"FileSystem"`
	MountedOn   string  `json:"MountedOn"`
	Used        string  `json:"Used"`
	Available   string  `json:"Available"`
	UsedPercent float64 `json:"UsedPercent"`
}

type LoadAverage

type LoadAverage struct {
	LoadAvg1       float64 `json:"LoadAvg1"`
	LoadAvg5       float64 `json:"LoadAvg5"`
	LoadAvg15      float64 `json:"LoadAvg15"`
	RunningThreads float64 `json:"RunningThreads"`
	TotalThreads   float64 `json:"TotalThreads"`
}

type LoggingInterval

type LoggingInterval struct {
	HeartBeat     *uint `json:"heartbeat,omitempty"`
	SystemMetrics *uint `json:"system_metrics,omitempty"`
}

type MeasurementType

type MeasurementType string
const (
	LOADAVERAGE MeasurementType = "LoadAverage"
	MEMORYUSAGE MeasurementType = "MemoryUsage"
	DISKUSAGE   MeasurementType = "DiskUsage"
)

type MemoryUsage

type MemoryUsage struct {
	MemFree      float64 `json:"MemFree"`
	MemTotal     float64 `json:"MemTotal"`
	MemAvailable float64 `json:"MemAvailable"`
	UsedPercent  float64 `json:"UsedPercent"`
	SwapFree     float64 `json:"SwapFree"`
	SwapTotal    float64 `json:"SwapTotal"`
	SwapCached   float64 `json:"SwapCached"`
}

type StatCollector

type StatCollector interface {
	Start(ctx context.Context) error
	Stop()
}

func NewService

func NewService(cfg *StatConfig, l log.Logger) (StatCollector, error)

type StatConfig

type StatConfig struct {
	Verbose         bool             `json:"verbose,omitempy"`           // whether to display all fields or just the one used in trigger criteria
	LoggingInterval *LoggingInterval `json:"logging_interval,omitempty"` // check every X seconds
	Trigger         []*Trigger       `json:"trigger,omitempty"`          // defines threshold for alert to trigger
}

type SystemMetrics

type SystemMetrics struct {
	LoadAverage *LoadAverage `json:"LoadAverage"`
	MemoryUsage *MemoryUsage `json:"MemoryUsage"`
	DiskUsage   *DiskUsage   `json:"DiskUsage"`
}

type Trigger

type Trigger struct {
	Measurement MeasurementType `json:"measurement"` // Measurement: eg Meemory
	Field       string          `json:"field"`       // A field of measurement eg UsedPercent
	Value       float64         `json:"value"`       // Threshold Value: eg 90
	Sign        string          `json:"sign"`        // Relational Operator: eg >
}

Jump to

Keyboard shortcuts

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