metrics

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2014 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	/*
	  CPU time is stored in system clock ticks.  Most
	  modern linux systems use 100 clock ticks per second,
	  or 100 Hz.  Use "getconf CLK_TCK" to verify this.
	  Since our cycle time is 15 seconds, there's 1500
	  ticks to spend each cycle.  If a process uses 750
	  ticks on the CPU, that means it used 50% of the CPU
	  during that cycle.  Multithreaded processes running on
	  systems with multiple CPUs/cores can use more than 100% CPU.
	*/
	CLK_TCK = 100

	// all metric ring buffers will store one hour of metric history
	SLOTS = 3600 / 15
)

Variables

View Source
var (
	DisplayPercent = func(val float64) string {
		return strconv.FormatFloat(val, 'f', 1, 64) + "%"
	}
	DisplayInMB = func(val float64) string {
		return strconv.FormatFloat(val/(1024*1024), 'f', 2, 64) + "m"
	}
)

Functions

This section is empty.

Types

type DisplayFunc

type DisplayFunc func(float64) string

Convert the raw metric value into something displayable to the user.

type Loadable

type Loadable interface {
	Load(values ...interface{})
}

type Metric

type Metric interface {
	// Used for current value
	Put(val float64)
	Get() float64
	Display() string

	// Used for History ('show')
	At(int) *float64
	Displayable(float64) string
	Size() int
}

type Store

type Store interface {
	Get(family string, name string) float64
	Display(family string, name string) string
	Collect(pid int) error

	Families() []string
	MetricNames(family string) []string

	Save(family, name string, value float64)
	DeclareCounter(family, name string, xform TransformFunc, display DisplayFunc)
	DeclareGauge(family, name string, display DisplayFunc)
	Metric(family, name string) Metric
}

func NewHostStore

func NewHostStore(path string, cycleSeconds uint) Store

func NewMockStore

func NewMockStore() Store

func NewProcessStore

func NewProcessStore(path string, cycleSeconds uint) Store

type TransformFunc

type TransformFunc func(float64, float64) float64

transform the raw collected data into something we can compare. Used by cpu(*) to transform raw ticks into a percentage.

type Type

type Type uint8
const (
	Counter Type = iota
	Gauge
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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