Documentation ¶
Index ¶
- func Kill(pid int) error
- type DayLimits
- type Downtime
- type ProcessGroupDayBalance
- type ProcessGroupDayLimit
- type ProcessHunter
- func (ph *ProcessHunter) GetBalance() dayTimeBalance
- func (ph *ProcessHunter) GetLatestPGroupsBalance() []ProcessGroupDayBalance
- func (ph *ProcessHunter) GetLatestProcessesBalance() TimeBalance
- func (ph *ProcessHunter) GetLimits() ([]ProcessGroupDayLimit, 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
- func (ph *ProcessHunter) SetConfig(b []byte) error
- type TimeBalance
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DayLimits ¶ added in v0.10.1
DayLimits maps days to time limit The key (days) can be - "*" (meaing 'any day of the week') - space separated string of three-letter abbreviations of the days of week, i.e. Mon Tue Wed Thu Fri Sat Sun - a concreate date in the format YYYY-MM-DD - space separated list of dates - a combination of all of the above
func (DayLimits) MarshalJSON ¶ added in v0.10.1
MarshalJSON marshals dtl using 12h35m46s duration format
func (*DayLimits) UnmarshalJSON ¶ added in v0.10.1
UnmarshalJSON unmarshals dtl, lowercasing the key and using 12h35m46s duration format
type Downtime ¶ added in v0.10.1
Downtime maps days to a list of downtime periods See DayLimits for the meaning of the key of this map The values (downtime periods) are strings like this: "12:00..12:30" - for a 30 minutes downtime "..10:00" - downtime up until 10:00 in the morning "18:00.." - downtime after 6:00PM
type ProcessGroupDayBalance ¶ added in v0.10.1
type ProcessGroupDayBalance struct { PG []string `json:"processes"` Limit prettyDuration `json:"limit"` LimitDefined bool `json:"limit_defined"` Balance prettyDuration `json:"balance"` Downtime []string `json:"downtime"` Blocked bool `json:"blocked"` TimeStamp string `json:"timestamp"` }
ProcessGroupDayBalance describes day limits and monitored properties of a process group PG
type ProcessGroupDayLimit ¶ added in v0.10.1
type ProcessGroupDayLimit struct { PG []string `json:"processes"` DL DayLimits `json:"limits"` DT Downtime `json:"downtime"` }
ProcessGroupDayLimit specifies day time limit DL and downtime periods DT for one or more processes in PG
type ProcessHunter ¶
type ProcessHunter struct {
// contains filtered or unexported fields
}
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) GetBalance ¶ added in v0.10.4
func (ph *ProcessHunter) GetBalance() dayTimeBalance
GetBalance returns balance
func (*ProcessHunter) GetLatestPGroupsBalance ¶ added in v0.6.0
func (ph *ProcessHunter) GetLatestPGroupsBalance() []ProcessGroupDayBalance
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() ([]ProcessGroupDayLimit, uint32)
GetLimits returns current day 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 in a thread-safe way
func (*ProcessHunter) SetConfig ¶ added in v0.9.1
func (ph *ProcessHunter) SetConfig(b []byte) error
SetConfig sets configuration b (represented as json) and saves it to the ph.cfgPath if ph.cfgPath is "", then the call succeeds without saving config file if ph.cfgPath cannot be written, the call fails and new config is not set.
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