Documentation ¶
Index ¶
- Constants
- Variables
- type Derivation
- type Set
- func (set *Set) Add(metricType Type, value float64)
- func (set *Set) AddAll(other *Set)
- func (set *Set) Clear(metricType Type)
- func (set *Set) ClearAll(clearInherited, clearNonInherited bool)
- func (set *Set) Get(metricType Type) float64
- func (set *Set) Set(metricType Type, value float64)
- func (set *Set) SetAll(other *Set)
- func (set *Set) Size() int
- func (set *Set) Types() []Type
- func (set *Set) Update()
- type Template
- type TemplateSet
- type Type
Constants ¶
const ( // Byte is the unit of bytes Byte = 1.0 // KiB is the unit Kibibytes KiB = 1024.0 * Byte // MiB is the unit Mebibytes MiB = 1024.0 * KiB // GiB is the unit Gibibytes GiB = 1024.0 * MiB // TiB is the unit Tebibytes TiB = 1024.0 * GiB // Bit is the unit bits Bit = 1.0 // KiBit is the unit Kibibits KiBit = 1024.0 * Bit // MiBit is the unit Mebibits MiBit = 1024.0 * KiBit // GiBit is the unit Gibibits GiBit = 1024.0 * MiBit )
Variables ¶
var ( // CPUTotal represents the total cpu for a group, each cpu adds 100 %, so a 24 core machine will have 2400 % cpu. CPUTotal = Type{ Name: "cpu_total", Unit: "%", Inherited: false, } // CPUUsed represents the used cpu usage for a group or an entity. CPUUsed = Type{ Name: "cpu_used", Unit: "%", Inherited: true, } // CPUFree represents the free cpu usage for a group. CPUFree = Type{ Name: "cpu_free", Unit: "%", Inherited: false, // contains filtered or unexported fields } // MemoryTotal represents the total memory. MemoryTotal = Type{ Name: "memory_total", Unit: "bytes", Inherited: false, } // MemoryUsed represents the used memory for a group or an entity. MemoryUsed = Type{ Name: "memory_used", Unit: "bytes", Inherited: true, } // MemoryFree represents the free memory for a group. MemoryFree = Type{ Name: "memory_free", Unit: "bytes", Inherited: false, // contains filtered or unexported fields } // DiskTotal represents the total disk for a group DiskTotal = Type{ Name: "disk_total", Unit: "bytes", Inherited: false, } // DiskUsed represents the used disk for a group or an entity. DiskUsed = Type{ Name: "disk_used", Unit: "bytes", Inherited: true, } // DiskFree represents the free disk for a group. DiskFree = Type{ Name: "disk_free", Unit: "bytes", Inherited: false, // contains filtered or unexported fields } // NetworkTotal represents the total network for a group NetworkTotal = Type{ Name: "network_total", Unit: "bits", Inherited: false, } // NetworkUsed represents the used network for a group or an entity. NetworkUsed = Type{ Name: "network_used", Unit: "bits", Inherited: true, } // NetworkFree represents the free network for a group. NetworkFree = Type{ Name: "network_free", Unit: "bits", Inherited: false, // contains filtered or unexported fields } // GPUTotal represents the total gpu for a group, each gpu adds 100 %, so a 24 core gpu will have 2400 % gpu. GPUTotal = Type{ Name: "gpu_total", Unit: "%", Inherited: false, } // GPUUsed represents the used gpu usage for a group or an entity. GPUUsed = Type{ Name: "gpu_used", Unit: "%", Inherited: true, } // GPUFree represents the free gpu usage for a group. GPUFree = Type{ Name: "gpu_free", Unit: "%", Inherited: false, // contains filtered or unexported fields } // FileDescriptorsTotal represents the total number of file descriptors available for a group. FileDescriptorsTotal = Type{ Name: "file_descriptors_total", Unit: "#", Inherited: false, } // FileDescriptorsUsed represents the number of used file descriptors available for a group or entity. FileDescriptorsUsed = Type{ Name: "file_descriptors_used", Unit: "#", Inherited: true, } // FileDescriptorsFree represents the number of free file descriptors available for a group. FileDescriptorsFree = Type{ Name: "file_descriptors_free", Unit: "#", Inherited: false, // contains filtered or unexported fields } // PortsTotal represents the total number of ports available for a group. PortsTotal = Type{ Name: "ports_total", Unit: "#", Inherited: false, } // PortsUsed represents the used number of ports for a group. PortsUsed = Type{ Name: "ports_used", Unit: "#", Inherited: true, } // PortsFree represents the free number of ports for a group. PortsFree = Type{ Name: "ports_free", Unit: "#", Inherited: false, // contains filtered or unexported fields } )
Functions ¶
This section is empty.
Types ¶
type Derivation ¶
type Derivation interface { // Dependencies returns the set of dependencies that this metric needs to derive its value. Dependencies() []Type // Calculate computes the derived value of the metric type and updates the metric set. Calculate(metricType Type, metricSet *Set) }
Derivation describes which other metric types that a given metric type is derived from and is able to calculate the current value of the metric from the other other metrics in a given metric set.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set represents some metric on a group which represents a host or zone or entity which represents a process, container or task that is running on a group. This can be, but is not limited to, cpu load, memory size, disk size, network bandwidth, estimated disk usage per day, etc.
func (*Set) AddAll ¶
AddAll combines the values from another metric set into this set, common metric types are combined.
type Template ¶
type Template interface { // Bind will bind the template with to the given value. Bind(value float64) Template // Mapping will return a the metric type and its current value. Mapping() (Type, float64) // Instantiate will create a new metric type with a given distribution. Instantiate() (Type, generation.Distribution) }
Template represents a metric template which can be instantiated with different values. A template can create a metric type and a value for it. The value of the metric type can bound later.
func NewTemplate ¶
NewTemplate will create a new template for a given metric type, the value of the metric can be bound later.
type TemplateSet ¶
type TemplateSet interface { // Bind will bind the template with the given metric type to the given value if a template exists for that metric // type, else nothing will happen. Bind(metricType Type, value float64) TemplateSet // Add will add a metric template whose value will be set by this bindings of this set. If a template already exists // for the metric type of the template then the old template will be overridden. Add(template Template) TemplateSet // AddAll adds all metric templates from the given template set to this template set. If a template already exists // for a metric type in the new set then the old template will be overridden. AddAll(set TemplateSet) TemplateSet // Templates returns all templates of the template set. Templates() map[Type]Template // Mappings will return a map of all the current metric types and their values. Mappings() map[Type]float64 }
TemplateSet represents a set of metric templates where the values of all templates can be bound later for all metric templates.
func NewTemplateSet ¶
func NewTemplateSet() TemplateSet
NewTemplateSet will create a new template set where templates can be added and metric types can be bound for all the templates.
type Type ¶
type Type struct { Name string Unit string Inherited bool // Inherited represents if the metric is inherited from entities or not. // contains filtered or unexported fields }
Type represents a type of information, it can be cpu usage, memory usage, disk usage, etc.
func TopSort ¶
TopSort takes a list of metric types and returns a order to visit the metric types in where any metric type is before its dependent metric types. If the metric types dependencies form a cycle it will be detected and an error will be returned.
func (Type) Derivation ¶
func (metricType Type) Derivation() Derivation
Derivation returns the derivation of this type.
func (*Type) SetDerivation ¶
func (metricType *Type) SetDerivation(value Derivation) error
SetDerivation sets the derivation of this type and gives an error if the derivation introduces a cycle in the derivation rules.