core

package
v0.0.0-...-3edb9e0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2015 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ContainerList map[string]*dguard.Container
	DockerDriver  string
)

List of probe's containers

Functions

func ContainerResetTime

func ContainerResetTime(id string) bool

Set the memory used size of a container in the ContainerList

func CriticalExit

func CriticalExit(s string)

Exit the program when critical error

func GetStats

func GetStats(container *dapi.ContainerShort, oldS *OldStats, wg *sync.WaitGroup)

Get container's stats

func HTTPHandlerDockerinfos

func HTTPHandlerDockerinfos(w http.ResponseWriter, r *http.Request)

Handle GET /dockerinfos

func HTTPHandlerList

func HTTPHandlerList(w http.ResponseWriter, r *http.Request)

Handle GET /list

func HTTPHandlerProbeinfos

func HTTPHandlerProbeinfos(w http.ResponseWriter, r *http.Request)

Handle GET /probeinfos

func HTTPReq

func HTTPReq(path string) (int, string)

Do HTTP request on API

func HTTPSecureAPI

func HTTPSecureAPI(r *http.Request, rm *mux.RouteMatch) bool

Secure API access

func HTTPURILogger

func HTTPURILogger(r *http.Request, rm *mux.RouteMatch) bool

Log HTTP requests' URI

func Init

func Init()

Initialize Core

func InitAPIClient

func InitAPIClient()

Initialize API Client

func InitConfig

func InitConfig(path string)

Load program config from file

func InitLogger

func InitLogger(l1, l2, l3 bool) *logo.Logger

Initialize logger

func RefreshContainerList

func RefreshContainerList() error

Refresh core.ContainerList

func RunHTTPServer

func RunHTTPServer()

Run HTTP Server

func SetContainerCPUUsage

func SetContainerCPUUsage(id string, size float64) bool

Set the cpu usage of a container in the ContainerList

func SetContainerMemoryUsed

func SetContainerMemoryUsed(id string, size float64) bool

Set the memory used size of a container in the ContainerList

func SetContainerNetBandwithRX

func SetContainerNetBandwithRX(id string, size float64) bool

Set the net bandwith RX of a container in the ContainerList

func SetContainerNetBandwithTX

func SetContainerNetBandwithTX(id string, size float64) bool

Set the net bandwith TX of a container in the ContainerList

func SetContainerSizeRootFs

func SetContainerSizeRootFs(id string, size float64) bool

Set the RootFs size of a container in the ContainerList

func SetContainerSizeRw

func SetContainerSizeRw(id string, size float64) bool

Set the Rw size of a container in the ContainerList

func StatsController

func StatsController()

Loop to get containers' stats

func StorageController

func StorageController()

Get containers' disk usage

func TestDockerAPI

func TestDockerAPI()

Test Docker API connectivity

Types

type Config

type Config struct {
	Docker struct {
		UnixSocketPath string `yaml:"unix-socket-path"`
	} `yaml:"docker"`

	DockerGuard struct {
		ListenInterface              string `yaml:"listen-interface"`
		ListenPort                   string `yaml:"listen-port"`
		APIPassword                  string `yaml:"api-password"`
		RefreshContainerListInterval int    `yaml:"refresh-container-list-interval"`
		StorageControllerInterval    int    `yaml:"storage-controller-interval"`
		StorageControllerPause       int    `yaml:"storage-controller-pause"`
	} `yaml:"docker-guard"`
}

Program config struct

var (
	// Program config
	DGConfig Config
)

type OldStats

type OldStats struct {
	Filled         bool
	NetRX          float64
	NetTX          float64
	CPUUsage       float64
	SystemCPUUsage float64
	Time           time.Time
}

Previous stats

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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