metrix

package
v0.0.0-...-b52e348 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2017 License: Apache-2.0 Imports: 19 Imported by: 4

Documentation

Overview

** Copyright [2013-2017] [Megam Systems] ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License.

Index

Constants

View Source
const (
	BACKUPS        = "backups"
	BACKUPS_SENSOR = "instance.backups.exists"
)
View Source
const (
	OPENNEBULA = "one"
	QUOTA      = "quota"
	ONDEMAND   = "ondemand"
	INSTANCE   = "instance"
	DOCKER     = "docker"
)
View Source
const (
	CPU_UNIT          = "cpu_unit"
	MEMORY_UNIT       = "memory_unit"
	DISK_UNIT         = "disk_unit"
	CPU_COST          = "cpu_cost"
	MEMORY_COST       = "memory_cost"
	CPU_COST_PER_HOUR = "cpu_cost_per_hour"
	RAM_COST_PER_HOUR = "ram_cost_per_hour"
	DISK_COST         = "disk_cost"

	STORAGE_COST_PER_HOUR = "storage_cost_per_hour"
	STORAGE_COST          = "storage_cost"
	STORAGE_UNIT          = "storage_unit"

	SKEWS_ACTIONS = "skews_actions"
	SKEWS_ACTION  = "action"
	GRACEPERIOD   = "grace_period"
	CREDIT_LIMIT  = "credit_limit"
)
View Source
const (
	SENSORSBUCKET           = "sensors"
	CEPH_STORAGE_SENSOR     = "storage.ceph.buckets"
	ONE_VM_SENSOR           = "compute.vm.exists"
	DOCKER_CONTAINER_SENSOR = "compute.container.exists"
)
View Source
const (
	SNAPSHOTS       = "snapshots"
	SNAPSHOT_SENSOR = "instance.snapshots.exists"
)
View Source
const (
	CEPHRGW = "ceph_rgw"
)

Variables

View Source
var MetricsInterval time.Duration

Functions

func AbortWith

func AbortWith(message string)

func FetchURL

func FetchURL(url string) (b []byte, e error)

func SendMetricsToScylla

func SendMetricsToScylla(metrics Sensors, hostname string) (err error)

func SendMetricsToStdout

func SendMetricsToStdout(metrics Sensors, hostname string)

Types

type Backups

type Backups struct {
	DefaultUnits map[string]string
	RawStatus    []byte
}

func (*Backups) Collect

func (s *Backups) Collect(c *MetricsCollection) (e error)

func (*Backups) CollectMetricsFromStats

func (c *Backups) CollectMetricsFromStats(mc *MetricsCollection, bks []carton.Backups)

actually the NewSensor can create trypes based on the event type.

func (*Backups) DeductBill

func (r *Backups) DeductBill(c *MetricsCollection) (e error)

func (*Backups) Prefix

func (r *Backups) Prefix() string

func (*Backups) ReadUsers

func (c *Backups) ReadUsers() ([]*carton.Account, error)

type CPUStats

type CPUStats struct {
	PercpuUsage       []uint64
	UsageInUsermode   uint64
	TotalUsage        uint64
	UsageInKernelmode uint64
	SystemCPUUsage    uint64
}

type CephRGWStats

type CephRGWStats struct {
	Url          string
	AdminUser    string
	MasterKey    string
	AccessKey    string
	SecretKey    string
	UserId       string
	UserPrefix   string
	DefaultUnits map[string]string
	RawStatus    []byte
}

func (*CephRGWStats) Collect

func (rgw *CephRGWStats) Collect(c *MetricsCollection) (e error)

func (*CephRGWStats) CollectMetricsFromStats

func (c *CephRGWStats) CollectMetricsFromStats(mc *MetricsCollection, acts []*carton.Account)

actually the NewSensor can create trypes based on the event type.

func (*CephRGWStats) DeductBill

func (rgw *CephRGWStats) DeductBill(c *MetricsCollection) (e error)

func (*CephRGWStats) Prefix

func (rgw *CephRGWStats) Prefix() string

func (*CephRGWStats) ReadUsers

func (c *CephRGWStats) ReadUsers() ([]*carton.Account, error)

type CephStorage

type CephStorage struct {
}

type Handler

type Handler interface {
}

type InstanceHandler

type InstanceHandler struct {
	Deployd        bool
	Dockerd        bool
	ContainerUnits map[string]string
	Flavors        map[string]*carton.Flavor
	VMUnits        map[string]string
	SkewsActions   map[string]string
}

func (*InstanceHandler) Collect

func (i *InstanceHandler) Collect(mc *MetricsCollection) (e error)

func (*InstanceHandler) CollectMetricsFromStats

func (i *InstanceHandler) CollectMetricsFromStats(mc *MetricsCollection, amies []carton.Assemblies, sensorType string)

actually the NewSensor can create trypes based on the event type.

func (*InstanceHandler) DeductBill

func (i *InstanceHandler) DeductBill(c *MetricsCollection) (e error)

func (*InstanceHandler) ParseAssemblies

func (i *InstanceHandler) ParseAssemblies(orgs []carton.Organization, users map[string]*carton.Account) (map[string][]carton.Assemblies, error)

func (*InstanceHandler) Prefix

func (on *InstanceHandler) Prefix() string

func (*InstanceHandler) ReadOrgs

func (i *InstanceHandler) ReadOrgs() ([]carton.Organization, error)

func (*InstanceHandler) ReadUsers

func (i *InstanceHandler) ReadUsers() (map[string]*carton.Account, error)

type Metric

type Metric struct {
	MetricName  string `json:"metric_name"`
	MetricValue string `json:"metric_value"`
	MetricUnits string `json:"metric_units"`
	MetricType  string `json:"metric_type"`
}

func (*Metric) String

func (m *Metric) String() string

type MetricCollector

type MetricCollector interface {
	Prefix() string
	Collect(*MetricsCollection) error
}

type MetricHandler

type MetricHandler struct {
}

func (*MetricHandler) Collect

func (h *MetricHandler) Collect(c MetricCollector) (Sensors, error)

type Metrics

type Metrics []*Metric

func (Metrics) Len

func (list Metrics) Len() int

func (Metrics) Swap

func (list Metrics) Swap(a, b int)

func (*Metrics) ToString

func (p *Metrics) ToString() []string

func (*Metrics) Totalcost

func (m *Metrics) Totalcost(units map[string]string) string

type MetricsCollection

type MetricsCollection struct {
	Prefix  string
	Sensors Sensors
}

func (*MetricsCollection) Add

func (m *MetricsCollection) Add(s *Sensor)

func (*MetricsCollection) String

func (m *MetricsCollection) String() string

type MetricsMap

type MetricsMap map[string]int64

type Metrix

type Metrix struct {
	Collectors map[string]*MetricCollector
}

func (*Metrix) AddCollector

func (self *Metrix) AddCollector(key string, col *MetricCollector)

func (*Metrix) ProcRoot

func (m *Metrix) ProcRoot() (s string)

func (*Metrix) ReadProcFile

func (m *Metrix) ReadProcFile(path string) (r string)

type OutputHandler

type OutputHandler struct {
	ScyllaAddress string
	Hostname      string
}

func (*OutputHandler) WriteMetrics

func (o *OutputHandler) WriteMetrics(all Sensors) (e error)

type Sensor

type Sensor struct {
	Id                   string    `json:"id" cql:"id"`
	AccountId            string    `json:"account_id" cql:"account_id"`
	SensorType           string    `json:"sensor_type" cql:"sensor_type"`
	AssemblyId           string    `json:"assembly_id" cql:"assembly_id"`
	AssemblyName         string    `json:"assembly_name" cql:"assembly_name"`
	AssembliesId         string    `json:"assemblies_id" cql:"assemblies_id"`
	Node                 string    `json:"node" cql:"node"`
	System               string    `json:"system" cql:"system"`
	Status               string    `json:"status" cql:"status"`
	Source               string    `json:"source" cql:"source"`
	Message              string    `json:"message" cql:"message"`
	AuditPeriodBeginning string    `json:"audit_period_beginning" cql:"audit_period_beginning"`
	AuditPeriodEnding    string    `json:"audit_period_ending" cql:"audit_period_ending"`
	AuditPeriodDelta     string    `json:"audit_period_delta" cql:"audit_period_delta"`
	Metrics              Metrics   `json:"metrics" cql:"metrics"`
	CreatedAt            time.Time `json:"created_at" cql:"created_at"`
	QuotaId              string    `json:"-"`
	Resources            string    `json:"-"`
}

func NewSensor

func NewSensor(senstype string) *Sensor

func (*Sensor) String

func (s *Sensor) String() string

func (*Sensor) WriteIt

func (s *Sensor) WriteIt()

type Sensors

type Sensors []*Sensor

type Snapshots

type Snapshots struct {
	DefaultUnits map[string]string
	RawStatus    []byte
}

func (*Snapshots) Collect

func (s *Snapshots) Collect(c *MetricsCollection) (e error)

func (*Snapshots) CollectMetricsFromStats

func (c *Snapshots) CollectMetricsFromStats(mc *MetricsCollection, snps []carton.Snaps)

actually the NewSensor can create trypes based on the event type.

func (*Snapshots) DeductBill

func (r *Snapshots) DeductBill(c *MetricsCollection) (e error)

func (*Snapshots) Prefix

func (r *Snapshots) Prefix() string

func (*Snapshots) ReadUsers

func (c *Snapshots) ReadUsers() ([]*carton.Account, error)

type Stats

type Stats struct {
	ContainerId     string
	Image           string
	MemoryUsage     uint64 //in bytes
	CPUUnitCost     string
	MemoryUnitCost  string
	AllocatedMemory int64
	AllocatedCpu    int64
	CPUStats        CPUStats //in percentage of total cpu used
	PreCPUStats     CPUStats
	NetworkIn       uint64
	NetworkOut      uint64
	AccountId       string
	AssemblyId      string
	QuotaId         string
	AssemblyName    string
	AssembliesId    string
	Status          string
	AuditPeriod     time.Time
}

Jump to

Keyboard shortcuts

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