engine

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2019 License: BSD-3-Clause, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Kill

func Kill(pid int) error

Kill kills process pid

Types

type DailyLimits

type DailyLimits map[string]time.Duration

DailyLimits maps days of the week to time limit The key can be "*" (meaing 'any day of the week') or space separated string of three-letter abbreviations of the days of week, i.e. Mon Tue Wed Thu Fri Sat Sun

func (DailyLimits) MarshalJSON

func (dtl DailyLimits) MarshalJSON() ([]byte, error)

MarshalJSON marshals dtl using 12h35m46s duration format

func (*DailyLimits) UnmarshalJSON

func (dtl *DailyLimits) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals dtl, lowercasing the key and using 12h35m46s duration format

type ProcessGroupDailyBalance added in v0.6.2

type ProcessGroupDailyBalance struct {
	PG []string       `json:"processes"`
	L  prettyDuration `json:"limit"`
	B  prettyDuration `json:"balance"`
}

ProcessGroupDailyBalance describes daily limit L and balance B of process group PG

type ProcessGroupDailyLimit

type ProcessGroupDailyLimit struct {
	PG []string    `json:"processes"`
	DL DailyLimits `json:"limits"`
}

ProcessGroupDailyLimit specifies daily time limit DL for one or more processes in PG

type ProcessHunter

type ProcessHunter struct {
	// contains filtered or unexported fields
}

ProcessHunter is monitoring and killing processes that go overtime for particular day

func NewProcessHunter

func NewProcessHunter(
	checkPeriod time.Duration,
	balancePath string,
	savePeriod time.Duration,
	killer func(int) error,
	cfgPath string) *ProcessHunter

NewProcessHunter initializes and returns a new ProcessHunter

func (*ProcessHunter) GetLatestPGroupsBalance added in v0.6.0

func (ph *ProcessHunter) GetLatestPGroupsBalance() []ProcessGroupDailyBalance

GetLatestPGroupsBalance returns pgroups

func (*ProcessHunter) GetLatestProcessesBalance added in v0.6.0

func (ph *ProcessHunter) GetLatestProcessesBalance() TimeBalance

GetLatestProcessesBalance returns processes

func (*ProcessHunter) GetLimits

func (ph *ProcessHunter) GetLimits() ([]ProcessGroupDailyLimit, uint32)

GetLimits returns current daily limits (which are normally loaded from a config file) and its hash

func (*ProcessHunter) LoadBalance

func (ph *ProcessHunter) LoadBalance() error

LoadBalance loads the balance from provided path

func (*ProcessHunter) LoadConfig

func (ph *ProcessHunter) LoadConfig() error

LoadConfig loads ProcessHunder configuration from path

func (*ProcessHunter) Run

func (ph *ProcessHunter) Run(ctx context.Context, wg *sync.WaitGroup)

Run is a goroutine that periodically checks running processes

func (*ProcessHunter) SaveBalance

func (ph *ProcessHunter) SaveBalance() error

SaveBalance saves balance to provided path

type TimeBalance added in v0.6.0

type TimeBalance map[string]time.Duration

TimeBalance maps process name to running time

func (TimeBalance) MarshalJSON added in v0.6.0

func (tb TimeBalance) MarshalJSON() ([]byte, error)

MarshalJSON marshals tb using 12h35m46s duration format

func (*TimeBalance) UnmarshalJSON added in v0.6.0

func (tb *TimeBalance) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals dtl using 12h35m46s duration format

Jump to

Keyboard shortcuts

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