Documentation
¶
Index ¶
- func Kill(pid int) error
- type DailyLimits
- type ProcessGroupDailyBalance
- type ProcessGroupDailyLimit
- type ProcessHunter
- func (ph *ProcessHunter) GetLatestPGroupsBalance() []ProcessGroupDailyBalance
- func (ph *ProcessHunter) GetLatestProcessesBalance() TimeBalance
- func (ph *ProcessHunter) GetLimits() ([]ProcessGroupDailyLimit, uint32)
- func (ph *ProcessHunter) LoadBalance() error
- func (ph *ProcessHunter) LoadConfig() error
- func (ph *ProcessHunter) Run(ctx context.Context, wg *sync.WaitGroup)
- func (ph *ProcessHunter) SaveBalance() error
- type TimeBalance
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DailyLimits ¶
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
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