Documentation ¶
Index ¶
- Constants
- Variables
- func BuildMetric(metricBuilder MetricBuilder) (*transit.TimeSeries, error)
- func BuildServiceForMetric(hostName string, metricBuilder MetricBuilder) (*transit.MonitoredService, error)
- func BuildServiceForMetricWithStatusText(hostName string, metricBuilder MetricBuilder, ...) (*transit.MonitoredService, error)
- func BuildServiceForMetrics(serviceName string, hostName string, metricBuilders []MetricBuilder) (*transit.MonitoredService, error)
- func BuildServiceForMultiMetric(hostName string, serviceName string, customName string, ...) (*transit.MonitoredService, error)
- func CreateCriticalThreshold(label string, value interface{}) (*transit.ThresholdValue, error)
- func CreateInventoryResource(name string, services []transit.InventoryService) transit.InventoryResource
- func CreateInventoryService(name string, owner string) transit.InventoryService
- func CreateMetric(name string, value interface{}, args ...interface{}) (*transit.TimeSeries, error)
- func CreateResource(name string, args ...interface{}) (*transit.MonitoredResource, error)
- func CreateResourceGroup(name string, description string, groupType transit.GroupType, ...) transit.ResourceGroup
- func CreateResourceRef(name string, owner string, resourceType transit.ResourceType) transit.ResourceRef
- func CreateService(name string, owner string, args ...interface{}) (*transit.MonitoredService, error)
- func CreateThreshold(thresholdType transit.MetricSampleType, label string, value interface{}) (*transit.ThresholdValue, error)
- func CreateWarningThreshold(label string, value interface{}) (*transit.ThresholdValue, error)
- func DivideToPercentage(values ...float64) float64
- func DoubleToInt(values ...float64) float64
- func EvaluateExpression(expression ExpressionToEvaluate, override bool) (float64, error)
- func EvaluateExpressionHandler(c *gin.Context)
- func EvaluateExpressions(services []transit.MonitoredService) []transit.MonitoredService
- func EvaluateGroundworkExpression(expression string, vars map[string]interface{}, argumentCounter int) (float64, []float64, error)
- func FillGroupWithResources(group transit.ResourceGroup, resources []transit.InventoryResource) transit.ResourceGroup
- func FormatTimeForStatusMessage(value time.Duration, minRound time.Duration) string
- func GB(values ...float64) float64
- func GB2(values ...float64) float64
- func IntToDouble(values ...float64) float64
- func KB(values ...float64) float64
- func KB2(values ...float64) float64
- func MB(values ...float64) float64
- func MB2(values ...float64) float64
- func MaxDuration(x time.Duration, rest ...time.Duration) time.Duration
- func MaxFloat(values ...float64) float64
- func MaxInt(values ...float64) float64
- func MinFloat(values ...float64) float64
- func MinInt(values ...float64) float64
- func Name(defaultName string, customName string) string
- func PercentageUnused(values ...float64) float64
- func PercentageUsed(values ...float64) float64
- func SanitizeString(str string) string
- func ScalePercentageUnused(values ...float64) float64
- func ScalePercentageUsed(values ...float64) float64
- func SendInventory(ctx context.Context, resources []transit.InventoryResource, ...) error
- func SendMetrics(ctx context.Context, resources []transit.MonitoredResource, ...) error
- func Start() error
- func StartPeriodic(ctx context.Context, t time.Duration, fn func())
- func TB(values ...float64) float64
- func TB2(values ...float64) float64
- func ToPercentage(values ...float64) float64
- func ToPercentageLimit(values ...float64) float64
- func UnmarshalConfig(data []byte, metricsProfile *transit.MetricsProfile, ...) error
- type ExpressionParameter
- type ExpressionToEvaluate
- type ExpressionToSuggest
- type MetricBuilder
Constants ¶
const ( Kb = "GW:KB" Mb = "GW:MB" Gb = "GW:GB" Tb = "GW:TB" Kb2 = "GW:KB2" Mb2 = "GW:MB2" Gb2 = "GW:GB2" Tb2 = "GW:TB2" IntMax = "GW:maxInt" IntMin = "GW:minInt" DoubleMax = "GW:maxDouble" DoubleMin = "GW:minDouble" IntDouble = "GW:toDouble" DoubleInt = "GW:toInt" ToPercent = "GW:toPercentage" PercentUsed = "GW:percentageUsed" PercentUnused = "GW:percentageUnused" ToPercentLimit = "GW:toPercentageLimit" DivideToPercent = "GW:divideToPercentage" ScalePercentUsed = "GW:scalePercentageUsed" ScalePercentUnused = "GW:scalePercentageUnused" )
const DefaultCheckInterval = time.Minute * 2
DefaultCheckInterval defines interval
const ExtKeyCheckInterval = "checkIntervalMinutes"
ExtKeyCheckInterval defines field name
Variables ¶
var CheckInterval = DefaultCheckInterval
CheckInterval comes from extensions field
var ErrUnsupportedType = errors.New("unsupported value type")
var Hashsum = config.Hashsum
Hashsum calculates FNV non-cryptographic hash suitable for checking the equality
var ProcessesCache = cache.New(5*time.Minute, 5*time.Minute)
ProcessesCache | TODO: move into Server Connector
Functions ¶
func BuildMetric ¶
func BuildMetric(metricBuilder MetricBuilder) (*transit.TimeSeries, error)
BuildMetric creates metric based on data provided with metricBuilder
func BuildServiceForMetric ¶
func BuildServiceForMetric(hostName string, metricBuilder MetricBuilder) (*transit.MonitoredService, error)
BuildServiceForMetric creates metric based on data provided in metric builder and if metric successfully created creates service with same name as metric which contains only this one metric returns the result of service creation
func BuildServiceForMetricWithStatusText ¶
func BuildServiceForMetricWithStatusText(hostName string, metricBuilder MetricBuilder, statusMessages map[transit.MonitorStatus]string) (*transit.MonitoredService, error)
func BuildServiceForMetrics ¶
func BuildServiceForMetrics(serviceName string, hostName string, metricBuilders []MetricBuilder) (*transit.MonitoredService, error)
func BuildServiceForMultiMetric ¶
func BuildServiceForMultiMetric(hostName string, serviceName string, customName string, metricBuilders []MetricBuilder) (*transit.MonitoredService, error)
func CreateCriticalThreshold ¶
func CreateCriticalThreshold(label string, value interface{}) (*transit.ThresholdValue, error)
func CreateInventoryResource ¶
func CreateInventoryResource(name string, services []transit.InventoryService) transit.InventoryResource
makes and modifies a copy, doesn't modify services
func CreateInventoryService ¶
func CreateInventoryService(name string, owner string) transit.InventoryService
Inventory Constructors
func CreateMetric ¶
func CreateMetric(name string, value interface{}, args ...interface{}) (*transit.TimeSeries, error)
CreateMetric
required parameters: name, value optional parameters: interval, UnitType
CreateMetric("cpu", 30) // integer value CreateMetric("percentFree", 30.59) // double value CreateMetric("cpu", 30.59, transit.PercentCPU) // with optional Unit CreateMetric("cpu", 30.59, interval) // with optional interval CreateMetric("cpu", 30.59, transit.PercentCPU, interval) // with optional Unit and optional interval with optional Unit and optional Interval and optional UnitType CreateMetric("cpu", 30.59, interval, transit.PercentCPU) Thresholds must be set separately
func CreateResource ¶
func CreateResource(name string, args ...interface{}) (*transit.MonitoredResource, error)
CreateResource makes node required params: name optional params: services
func CreateResourceGroup ¶
func CreateResourceGroup(name string, description string, groupType transit.GroupType, resources []transit.ResourceRef) transit.ResourceGroup
func CreateResourceRef ¶
func CreateResourceRef(name string, owner string, resourceType transit.ResourceType) transit.ResourceRef
func CreateService ¶
func CreateService(name string, owner string, args ...interface{}) (*transit.MonitoredService, error)
CreateService makes node required params: name, owner(resource) optional params: metrics
func CreateThreshold ¶
func CreateThreshold(thresholdType transit.MetricSampleType, label string, value interface{}) (*transit.ThresholdValue, error)
func CreateWarningThreshold ¶
func CreateWarningThreshold(label string, value interface{}) (*transit.ThresholdValue, error)
func DivideToPercentage ¶
Given two metrics, <code>dividend</code> and <code>divisor</code> divides them and returns a percentage ratio
Example:
GW:divideToPercentage(summary.quickStats.overallMemoryUsage,summary.hardware.memorySize)
@param - dividend typically a usage or free type metric @param - divisor typically a totality type metric, such as total disk space @return The percentage ratio as an integer
func DoubleToInt ¶
func EvaluateExpression ¶
func EvaluateExpression(expression ExpressionToEvaluate, override bool) (float64, error)
func EvaluateExpressions ¶
func EvaluateExpressions(services []transit.MonitoredService) []transit.MonitoredService
EvaluateExpressions calculates synthetic metrics
func FillGroupWithResources ¶
func FillGroupWithResources(group transit.ResourceGroup, resources []transit.InventoryResource) transit.ResourceGroup
func FormatTimeForStatusMessage ¶
Returns duration provided as a "human-readable" string, like: "N second(s)/minute(s)/hour(s)/day(s)"
Following formatting rules are being applied by default (not considering minRound): if the value is less than 3 minutes it will be formatted to seconds if the value is between 3 minutes and 3 hours it will be formatted to minutes if the value is between 3 hours and 3 days (<73 hours) it will be formatted to hours values higher than 72 hours (3 days) will be formatted to days minRound arg determines time unit "limit" lower than that formatting is not allowed i.e. if the value is for example 120 seconds which is gonna be returned as "120 second(s)" by default rules will be returned as "2 minute(s)" if minRound="minute" (i.e. formatting to lower than minute is not allowed) or "0 hour(s)" if minRound="hour" (i.e. formatting to lower than hour is not allowed)
func GB ¶
Converts byte value to Gigabyte value
@param bytes - value in bytes @return value in Gigabytes
func IntToDouble ¶
func KB ¶
Converts byte value to Kilobyte value
@param bytes - value in bytes @return value in Kilobytes
func MB ¶
Converts byte value to Megabyte value
@param bytes - value in bytes @return value in Megabytes
func MaxDuration ¶
MaxDuration returns maximum value
func PercentageUnused ¶
This Function provides percentage unused/free synthetic values. Calculates the unused(free) percentage for a given <code>unused</code> metric and a corresponding <code>available</code> metric. Both the unused metric and available metric can be scaled by corresponding scale factor parameters.
Example:
PercentageUnused(summary.freeSpace, summary.capacity)
@param unused - Represents a metric reference value of how much of this resource has not be used (free) @param available - Represents the totality of a resource, such as all disk space available @return The percentage not used (free) as an integer
func PercentageUsed ¶
This Function provides percentage usage synthetic values. Calculates the usage percentage for a given <code>used</code> metric and a corresponding <code>available</code> metric.
Example:
PercentageUsed(summary.quickStats.overallMemoryUsage, summary.hardware.memorySize)
@param - used Represents a 'used' metric value of how much of this resource has been used such as 'overallMemoryUsage' @param - available Represents the totality of a resource, such as all memory available @return The percentage usage as an integer
func SanitizeString ¶
SanitizeString replaces all special characters with '_'
func ScalePercentageUnused ¶
This Function provides percentage unused/free synthetic values. Calculates the unused(free) percentage for a given <code>unused</code> metric and a corresponding <code>available</code> metric. Both the unused metric and available metric can be scaled by corresponding scale factor parameters.
Example:
scalePercentageUnused(summary.freeSpace,summary.capacity, 1.0, null, true)
@param unused Represents a metric reference value of how much of this resource has not be used (free) @param available Represents the totality of a resource, such as all disk space available @param usageScaleFactor multiply usage parameter by this value, or pass in null to not scale. Passing in 1.0 will also not scale @param availableScaleFactor multiply available parameter by this value, or pass in null to not scale. Passing in 1.0 will also not scale @return The percentage not used (free) as an integer
func ScalePercentageUsed ¶
This Function provides percentage usage synthetic values. Calculates the usage percentage for a given <code>used</code> metric and a corresponding <code>available</code> metric. Both the used metric and available metric can be scaled by corresponding scale factor parameters.
Example:
scalePercentageUsed(summary.quickStats.overallMemoryUsage,summary.hardware.memorySize, 1.0, 1.0)
@param used Represents a 'used' metric value of how much of this resource has been used such as 'overallMemoryUsage' @param available Represents the totality of a resource, such as all memory available @param usedScaleFactor multiply usage parameter by this value, or pass in null to not scale. Passing in 1.0 will also not scale @param availableScaleFactor multiply available parameter by this value, or pass in null to not scale. Passing in 1.0 will also not scale @return The percentage usage as an integer
func SendInventory ¶
func SendInventory(ctx context.Context, resources []transit.InventoryResource, resourceGroups []transit.ResourceGroup, ownershipType transit.HostOwnershipType) error
SendInventory processes inventory payload
func SendMetrics ¶
func SendMetrics(ctx context.Context, resources []transit.MonitoredResource, groups *[]transit.ResourceGroup) error
SendMetrics processes metrics payload
func StartPeriodic ¶
StartPeriodic starts periodic event loop context can provide ctx.Done channel and "notOften" guard with 1 minute defaults
func TB ¶
Converts byte value to Terabyte value
@param bytes - value in bytes @return value in Terabytes
func ToPercentage ¶
Turns a number such as .87 into an integer percentage (87). Also handles rounding of percentages
@param value - the value to be rounded to a full integer percentage @return the percentage value as an integer
func ToPercentageLimit ¶
func UnmarshalConfig ¶
func UnmarshalConfig(data []byte, metricsProfile *transit.MetricsProfile, monitorConnection *transit.MonitorConnection) error
UnmarshalConfig updates args with data
Types ¶
type ExpressionParameter ¶
type ExpressionToEvaluate ¶
type ExpressionToEvaluate struct { Expression string `json:"expression"` Params []ExpressionParameter `json:"params"` }
type ExpressionToSuggest ¶
func ListExpressions ¶
func ListExpressions(name string) []ExpressionToSuggest