data

package
v0.0.0-...-f25ceec Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2016 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ESInsertDoc

func ESInsertDoc(esURL, esIndex, esType string, doc map[string]interface{})

ESInsertDoc will insert a doc to elasticsearch

Types

type Cluster

type Cluster struct {
	ID              string            `bson:"id,omitempty"`
	Name            string            `bson:"name,omitempty"`
	ConsensusPlugin string            `bson:"consensus_plugin,omitempty"`
	ConsensusMode   string            `bson:"consensus_mode,omitempty"`
	HostID          string            `bson:"host_id,omitempty"`
	UserID          string            `bson:"user_id,omitempty"`
	Containers      map[string]string `bson:"containers,omitempty"`
	APIURL          string            `bson:"api_url,omitempty"`
	DaemonURL       string            `bson:"daemon_url,omitempty"`
	Size            uint64            `bson:"size,omitempty"`
	CreateTS        time.Time         `bson:"create_ts,omitempty"`
	ReleaseTS       time.Time         `bson:"release_ts,omitempty"`
	Duration        time.Time         `bson:"duration,omitempty"`
	// contains filtered or unexported fields
}

Cluster is a document in the host collection

type ClusterStat

type ClusterStat struct {
	ClusterID        string    `bson:"cluster_id,omitempty"`
	ClusterName      string    `bson:"cluster_name,omitempty"`
	CPUPercentage    float64   `bson:"cpu_percentage,omitempty"`
	Memory           float64   `bson:"memory_usage,omitempty"`
	MemoryLimit      float64   `bson:"memory_limit,omitempty"`
	MemoryPercentage float64   `bson:"memory_percentage,omitempty"`
	NetworkRx        float64   `bson:"network_rx,omitempty"`
	NetworkTx        float64   `bson:"network_tx,omitempty"`
	BlockRead        float64   `bson:"block_read,omitempty"`
	BlockWrite       float64   `bson:"block_write,omitempty"`
	PidsCurrent      uint64    `bson:"pid_current,omitempty"`
	Size             uint64    `bson:"size,omitempty"`
	MaxLatency       float64   `bson:"max_latency,omitempty"`
	MinLatency       float64   `bson:"min_latency,omitempty"`
	AvgLatency       float64   `bson:"avg_latency,omitempty"`
	Latencies        []float64 `bson:"latencies,omitempty"`
	TimeStamp        time.Time `bson:"timestamp,omitempty"`
	// contains filtered or unexported fields
}

ClusterStat is a document of stat info for a cluster

func (*ClusterStat) CalculateStat

func (s *ClusterStat) CalculateStat(csList []*ContainerStat)

CalculateStat will get the stat result for a cluster

type ContainerStat

type ContainerStat struct {
	ContainerID      string    `bson:"container_id,omitempty"`
	ContainerName    string    `bson:"container_name,omitempty"`
	CPUPercentage    float64   `bson:"cpu_percentage,omitempty"`
	Memory           float64   `bson:"memory_usage,omitempty"`
	MemoryLimit      float64   `bson:"memory_limit,omitempty"`
	MemoryPercentage float64   `bson:"memory_percentage,omitempty"`
	NetworkRx        float64   `bson:"network_rx,omitempty"`
	NetworkTx        float64   `bson:"network_tx,omitempty"`
	BlockRead        float64   `bson:"block_read,omitempty"`
	BlockWrite       float64   `bson:"block_write,omitempty"`
	PidsCurrent      uint64    `bson:"pid_current,omitempty"`
	TimeStamp        time.Time `bson:"timestamp,omitempty"`
	// contains filtered or unexported fields
}

ContainerStat is a document of stat info for a container

type DB

type DB struct {
	URL  string // mongo api url
	Name string // name of the db
	// contains filtered or unexported fields
}

DB is a table in mongo

func (*DB) Close

func (db *DB) Close()

Close a db session

func (*DB) GetClusters

func (db *DB) GetClusters(filter map[string]interface{}) (*[]Cluster, error)

GetClusters retrieve the hosts info from db

func (*DB) GetCol

func (db *DB) GetCol(colName string) (*[]interface{}, error)

GetCol retrieve the collection from db depreacted

func (*DB) GetHosts

func (db *DB) GetHosts() (*[]Host, error)

GetHosts retrieve the hosts info from db

func (*DB) Init

func (db *DB) Init(dbURL string, dbName string) error

Init a db, open session and make collection handler

func (*DB) ReDial

func (db *DB) ReDial() error

ReDial will try reconnecting to the db

func (*DB) SaveData

func (db *DB) SaveData(s interface{}, colName string) error

SaveData save a record into db's collection

func (*DB) SetCol

func (db *DB) SetCol(colKey, colName string)

SetCol will set the cols points to collections

func (*DB) SetIndex

func (db *DB) SetIndex(colKey, indexKey string, expireDays int) error

SetIndex will set index property

type Host

type Host struct {
	ID        string   `bson:"id,omitempty"`
	Name      string   `bson:"name,omitempty"`
	DaemonURL string   `bson:"daemon_url,omitempty"`
	Clusters  []string `bson:"clusters,omitempty"`
	Status    string   `bson:"status,omitempty"`
	Capacity  uint64   `bson:"capacity,omitempty"`
	Type      string   `bson:"type,omitempty"`
	LogType   string   `bson:"log_type,omitempty"`
	LogServer string   `bson:"log_server,omitempty"`
	CreateTS  string   `bson:"create_ts,omitempty"`
	// contains filtered or unexported fields
}

Host is a document in the host collection

type HostStat

type HostStat struct {
	HostID           string    `bson:"host_id,omitempty"`
	HostName         string    `bson:"host_name,omitempty"`
	CPUPercentage    float64   `bson:"cpu_percentage,omitempty"`
	Memory           float64   `bson:"memory_usage,omitempty"`
	MemoryLimit      float64   `bson:"memory_limit,omitempty"`
	MemoryPercentage float64   `bson:"memory_percentage,omitempty"`
	NetworkRx        float64   `bson:"network_rx,omitempty"`
	NetworkTx        float64   `bson:"network_tx,omitempty"`
	BlockRead        float64   `bson:"block_read,omitempty"`
	BlockWrite       float64   `bson:"block_write,omitempty"`
	PidsCurrent      uint64    `bson:"pid_current,omitempty"`
	AvgLatency       float64   `bson:"avg_latency,omitempty"`
	MaxLatency       float64   `bson:"max_latency,omitempty"`
	MinLatency       float64   `bson:"min_latency,omitempty"`
	TimeStamp        time.Time `bson:"timestamp,omitempty"`
	// contains filtered or unexported fields
}

HostStat is a document of stat info for a cluster

func (*HostStat) CalculateStat

func (s *HostStat) CalculateStat(csList []*ClusterStat)

CalculateStat will get the stat result for a cluster

Jump to

Keyboard shortcuts

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