Documentation
¶
Overview ¶
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2024 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
build +linux
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- func ActivePreset[T Preset](s []T) (elem T)
- func ChanFirst[C chan T, T any](ch C, f func(T) bool) T
- func ChanMapFilter[C1 chan T1, C2 chan T2, T1, T2 any](in C1, out C2, f func(T1) (T2, bool))
- func Clone[S ~[]E, E any](s S) S
- func Diff[T BaseStruct](preset T, runtime T) (T, int)
- func Execute()
- func Filter[S ~[]E, E any](s S, f func(E) bool) S
- func GetCgroup(pid int) (cgroup string, err error)
- func GetOomScoreAdj(pid int) (score int, err error)
- func GetPreset[T Preset](m map[string][]T, key string, kind string) (T, error)
- func GetResource(pid int, rc string) ([]byte, error)
- func GetStat(path string) (stat unix.Stat_t, err error)
- func GetStringFromFlags(fallback string, names ...string) string
- func GetUid(pid int) int
- func GetUser(uid int) (*user.User, error)
- func HasPreset[T Preset](m map[string][]T, key string) bool
- func IOPrio_Get(pid int) (int, error)
- func IOPrio_Split(ioprio int, class, data *int)
- func IterCache[T Preset](m map[string][]T) chan T
- func List[T Preset](m map[string][]T) (result []string)
- func ListFrom[T Preset](m map[string][]T, required string) (result []string)
- func LoadConfig[T Preset](m map[string][]T, f func() chan T)
- func LookAll(file string) chan string
- func LookPath(file string) string
- func Map[S1 ~[]E1, E1, E2 any](s S1, f func(E1) E2) []E2
- func Properties[T BaseStruct](st T) (result []string)
- func Reduce[S ~[]E, E, T any](s S, init T, f func(T, E) T) T
- func ResetMatching[T1, T2 Struct](st1 *T1, st2 *T2)
- func Reverse[S ~[]E, E any](s S) S
- func Sched_GetParam(pid int) (int, error)
- func Sched_GetScheduler(pid int) (int, error)
- func ShellJoin(words ...string) string
- func ShellQuote(words []string) (result []string)
- func ShellSplit(input string) (words []string, err error)
- func ToInterface[T Struct](st T) map[string]any
- func ToJson[T Struct](st T) string
- func UpdateRule[T BaseStruct](st T, rule *Rule)
- func ValidShell(shell string) (string, error)
- type AppGroup
- type AppRule
- type BaseCgroup
- type BaseProfile
- type BaseRequest
- type BaseRule
- type BaseStruct
- type Cgroup
- type Command
- func (c Command) Copy() Tokener
- func (c *Command) Exec(tag string) error
- func (c *Command) Output() (output []string, err error)
- func (c *Command) RequireSysCapability() bool
- func (c *Command) Run(tag string, std *Streams) error
- func (c *Command) RunJob(shell string) (job *ProcJob, args []string, err error)
- func (c *Command) Runtime(pid, uid int) Command
- func (c *Command) Scan(std *Streams) Command
- func (c *Command) Split() (path string, args []string, err error)
- func (c *Command) Start(tag string, std *Streams) (cmd *exec.Cmd, err error)
- func (c *Command) StartWait(tag string, std *Streams) (err error)
- type Config
- type FilterAny
- type FilterProc
- type Filterer
- type Formatter
- type Group
- type Preset
- type PresetCache
- func (pc *PresetCache) Cgroup(key string) (Cgroup, error)
- func (pc *PresetCache) CgroupCandidate(base BaseCgroup) (string, bool)
- func (pc *PresetCache) DiffReview(job *ProcGroupJob) (count int, err error)
- func (pc *PresetCache) Expand(rule *Rule) error
- func (pc *PresetCache) FilteredProcs(inputs <-chan []*Proc, outputs chan<- []*Proc, wg *sync.WaitGroup)
- func (pc *PresetCache) GenerateGroupJobs(inputs <-chan []*Proc, output chan<- *ProcGroupJob, wgmain *sync.WaitGroup) (err error)
- func (pc *PresetCache) GenerateJobs(inputs <-chan *Request, outputs chan<- *ProcJob, wgmain *sync.WaitGroup) (err error)
- func (pc *PresetCache) GetContent() ([]byte, error)
- func (pc *PresetCache) GetFilterer(scope string) ProcFilterer
- func (pc *PresetCache) HasPreset(category string, key string) bool
- func (pc *PresetCache) List(category string) (result []string, err error)
- func (pc *PresetCache) ListFrom(category, origin string) (result []string, err error)
- func (pc *PresetCache) LoadFromCache(cacheFile string) error
- func (pc *PresetCache) LoadFromConfig() (err error)
- func (pc *PresetCache) Profile(key string) (Profile, error)
- func (pc *PresetCache) RawGroupJobs(inputs <-chan []*Proc, output chan<- *ProcGroupJob, wg *sync.WaitGroup)
- func (pc *PresetCache) RawRule(input *Request) (Rule, error)
- func (pc *PresetCache) RequestJob(input *Request) *ProcJob
- func (pc *PresetCache) RequestRule(input *Request) Rule
- func (pc *PresetCache) Rule(key string) (Rule, error)
- func (pc *PresetCache) SliceProperties(rule Rule) (result []string)
- func (pc *PresetCache) WriteCache(cacheFile string) error
- type Proc
- func (p *Proc) CPUSchedInfo() string
- func (p *Proc) GetStringMap() (result map[string]interface{})
- func (p *Proc) GoString() string
- func (p *Proc) IOClass() string
- func (p *Proc) IOSchedInfo() string
- func (p *Proc) InSystemSlice() bool
- func (p *Proc) InUserSlice() bool
- func (p Proc) Json() (result string)
- func (p Proc) Raw() string
- func (p *Proc) Runtime() BaseProfile
- func (p *Proc) Sched() string
- func (p *Proc) String() string
- func (p *Proc) Username() string
- func (p *Proc) Values() string
- type ProcByPgrp
- type ProcByPid
- type ProcFilter
- type ProcFilterer
- type ProcGroupJob
- type ProcJob
- func (job *ProcJob) AddCommand(c Command)
- func (job *ProcJob) AddExecCmd() error
- func (job *ProcJob) AddProfileCommand(property string, c Command)
- func (job *ProcJob) AdjustIOClassIONice(pid int) error
- func (job *ProcJob) AdjustNice(pid int) error
- func (job *ProcJob) AdjustOomScoreAdj(pid int) error
- func (job *ProcJob) AdjustSchedRTPrio(pid int) error
- func (job ProcJob) IsPrivilegeRequired(command string) bool
- func (job ProcJob) IsSudoSet() bool
- func (job *ProcJob) NicyExec() string
- func (job *ProcJob) PrepareCommands() error
- func (job *ProcJob) Run(tag string, args []string, std *Streams) (err error)
- func (job *ProcJob) Script(shell string) (result []string, err error)
- func (job *ProcJob) SetPrivilege(command string)
- func (job *ProcJob) SetSudoIfRequired()
- func (job *ProcJob) Show() (result []string, err error)
- type ProcStat
- type Profile
- type Request
- type Rule
- func (r *Rule) CgroupEntries() (BaseCgroup, bool)
- func (r *Rule) CgroupOnly()
- func (r *Rule) Copy() Rule
- func (r *Rule) GetCredentials() (result []string)
- func (r *Rule) GetDiff(runtime Rule) (Rule, int)
- func (r *Rule) HasCPUQuota() bool
- func (r *Rule) HasCgroupKey() bool
- func (r *Rule) HasIOWeight() bool
- func (r *Rule) HasIoclass() bool
- func (r *Rule) HasIonice() bool
- func (r *Rule) HasMemoryHigh() bool
- func (r *Rule) HasMemoryMax() bool
- func (r *Rule) HasNice() bool
- func (r *Rule) HasOomScoreAdj() bool
- func (r *Rule) HasProfileKey() bool
- func (r *Rule) HasRtprio() bool
- func (r *Rule) HasSched() bool
- func (r Rule) Keys() (string, string)
- func (r *Rule) NeedScope() bool
- func (r Rule) Path() string
- func (r *Rule) SetCgroup(cgroup string)
- func (r *Rule) SetCredentials()
- func (r *Rule) SetSliceProperties(properties []string)
- func (r Rule) String() string
- type Sched_Param
- type SchedulingPolicy
- type Script
- type Streams
- type Struct
- type Tokener
- type Tokens
- func (t Tokens) Append(s ...string) Tokener
- func (t Tokens) Content() []string
- func (t Tokens) Copy() Tokener
- func (t Tokens) Index(pos int) (result string)
- func (t Tokens) IsEmpty() bool
- func (t Tokens) Len() int
- func (t Tokens) Prepend(s ...string) Tokener
- func (t Tokens) ShellCmd() string
- func (t Tokens) String() string
- func (t Tokens) WriteTo(dest io.Writer) (n int, err error)
Constants ¶
const ( SUCCESS = 0 FAILURE = 1 EPARSE = 2 ENOTCONF = 3 ENOTDIR = 4 EACCESS = 5 EINVAL = 6 EALREADY = 16 // EUSAGE = 66 // ECOMPILE = 67 EPERM = 126 ENOTFOUND = 127 )
Error codes
const ( IOPRIO_CLASS_NONE = iota IOPRIO_CLASS_RT IOPRIO_CLASS_BE IOPRIO_CLASS_IDLE )
const ( IOPRIO_WHO_PROCESS IOPRIO_WHO_PGRP IOPRIO_WHO_USER )
const ( NONE = iota REALTIME BEST_EFFORT IDLE )
const ( SCHED_OTHER = iota SCHED_FIFO SCHED_RR SCHED_BATCH SCHED_ISO SCHED_IDLE SCHED_DEADLINE )
const IOPRIO_CLASS_SHIFT = 13
Variables ¶
var ( ErrFailure = customError{"fail", FAILURE} ErrParse = customError{"cannot parse options", EPARSE} ErrNotConfDir = customError{"unknown directory", ENOTCONF} ErrNotDir = customError{"not a directory", ENOTDIR} ErrNotWritableDir = customError{"not writable directory", EACCESS} ErrInvalid = customError{"invalid argument", EINVAL} ErrAlready = customError{"already running", EALREADY} ErrPermission = customError{"permission denied", EPERM} ErrNotFound = customError{"not found", ENOTFOUND} )
var CPUSched map[int]string
var GetScopeOnlyFilterer = GetFilterer
Functions ¶
func ActivePreset ¶ added in v0.2.0
func ActivePreset[T Preset](s []T) (elem T)
func ChanMapFilter ¶ added in v0.2.1
func Diff ¶ added in v0.2.0
func Diff[T BaseStruct](preset T, runtime T) (T, int)
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func GetOomScoreAdj ¶ added in v0.2.2
func GetStringFromFlags ¶ added in v0.2.0
func IOPrio_Get ¶ added in v0.2.2
func IOPrio_Split ¶ added in v0.2.2
func LoadConfig ¶ added in v0.2.0
func LookAll ¶ added in v0.2.1
LookAll searches for all executable named files in the directories named by the PATH environment variable. If file contains a slash, it is tried directly and the PATH is not consulted.
func LookPath ¶ added in v0.2.1
LookPath looks for a valid executable file outside scripts location.
func Properties ¶ added in v0.2.0
func Properties[T BaseStruct](st T) (result []string)
func ResetMatching ¶ added in v0.2.0
func ResetMatching[T1, T2 Struct](st1 *T1, st2 *T2)
ResetMatching iterate through st1 fields and, if set, resets matching fields in st2.
func Sched_GetParam ¶ added in v0.2.2
func Sched_GetScheduler ¶ added in v0.2.2
func ShellQuote ¶ added in v0.2.0
func ShellSplit ¶ added in v0.2.0
func ToInterface ¶ added in v0.2.0
func UpdateRule ¶ added in v0.2.0
func UpdateRule[T BaseStruct](st T, rule *Rule)
UpdateRule iterates through st fields and, if set, updates matching fields in rule, if not set yet.
func ValidShell ¶ added in v0.2.1
Types ¶
type AppRule ¶ added in v0.2.0
type AppRule struct { ProfileKey string `yaml:"profile,omitempty" json:"profile,omitempty"` Nice int `yaml:"nice,omitempty" json:"nice,omitempty"` Sched string `yaml:"sched,omitempty" json:"sched,omitempty"` RTPrio int `yaml:"rtprio,omitempty" json:"rtprio,omitempty"` IOClass string `yaml:"ioclass,omitempty" json:"ioclass,omitempty"` IONice int `yaml:"ionice,omitempty" json:"ionice,omitempty"` OomScoreAdj int `yaml:"oom_score_adj,omitempty" json:"oom_score_adj,omitempty"` CgroupKey string `yaml:"cgroup,omitempty" json:"cgroup,omitempty"` CPUQuota string `yaml:"CPUQuota,omitempty" json:"CPUQuota,omitempty"` IOWeight string `yaml:"IOWeight,omitempty" json:"IOWeight,omitempty"` MemoryHigh string `yaml:"MemoryHigh,omitempty" json:"MemoryHigh,omitempty"` MemoryMax string `yaml:"MemoryMax,omitempty" json:"MemoryMax,omitempty"` CmdArgs []string `yaml:"cmdargs,omitempty,flow" json:"cmdargs,omitempty"` Env map[string]string `yaml:"env,omitempty,flow" json:"env,omitempty"` }
type BaseCgroup ¶ added in v0.2.0
type BaseCgroup struct { CPUQuota string `yaml:"CPUQuota,omitempty" json:"CPUQuota,omitempty"` IOWeight string `yaml:"IOWeight,omitempty" json:"IOWeight,omitempty"` MemoryHigh string `yaml:"MemoryHigh,omitempty" json:"MemoryHigh,omitempty"` MemoryMax string `yaml:"MemoryMax,omitempty" json:"MemoryMax,omitempty"` }
func (*BaseCgroup) HasScopeProperties ¶ added in v0.2.0
func (c *BaseCgroup) HasScopeProperties() bool
func (*BaseCgroup) ScopeProperties ¶ added in v0.2.0
func (c *BaseCgroup) ScopeProperties() (result []string)
type BaseProfile ¶ added in v0.2.0
type BaseProfile struct { Nice int `yaml:"nice,omitempty" json:"nice,omitempty"` Sched string `yaml:"sched,omitempty" json:"sched,omitempty"` RTPrio int `yaml:"rtprio,omitempty" json:"rtprio,omitempty"` IOClass string `yaml:"ioclass,omitempty" json:"ioclass,omitempty"` IONice int `yaml:"ionice,omitempty" json:"ionice,omitempty"` OomScoreAdj int `yaml:"oom_score_adj,omitempty" json:"oom_score_adj,omitempty"` }
type BaseRequest ¶ added in v0.2.1
type BaseRequest struct { Name string `json:"name"` Path string `json:"cmd"` Preset string `json:"preset"` Shell string `json:"shell"` NumCPU int `json:"nproc"` MaxNice int `json:"max_nice"` }
func NewBaseRequest ¶ added in v0.2.1
func NewBaseRequest(name, path, shell string) *BaseRequest
type BaseRule ¶ added in v0.2.0
type BaseRule struct { // Profile: assign to profile with `ProfileKey` // and eventually adjust process properties in Rule // Cgroup: assign to cgroup slice with `CgroupKey` // and eventually adjust scope properties in Rule ProfileKey string `yaml:"profile,omitempty" json:"profile,omitempty"` CgroupKey string `yaml:"cgroup,omitempty" json:"cgroup,omitempty"` CmdArgs []string `yaml:"cmdargs,omitempty,flow" json:"cmdargs,omitempty"` Env map[string]string `yaml:"env,omitempty,flow" json:"env,omitempty"` SliceProperties []string `yaml:"slice_properties,omitempty,flow" json:"slice_properties,omitempty"` Credentials []string `yaml:"cred,omitempty,flow" json:"cred,omitempty"` }
type BaseStruct ¶ added in v0.2.2
type BaseStruct interface { BaseCgroup | BaseProfile | BaseRule }
type Cgroup ¶ added in v0.2.0
type Cgroup struct { BaseCgroup `yaml:"basecgroup,omitempty,flow"` CgroupKey string `yaml:"cgroup,omitempty" json:"cgroup,omitempty"` Origin string `yaml:"origin,omitempty" json:"origin,omitempty"` }
type Command ¶ added in v0.2.0
type Command struct { Tokener // contains filtered or unexported fields }
func ManagerCommand ¶ added in v0.2.0
func NewCommand ¶ added in v0.2.0
func SudoCommand ¶ added in v0.2.0
func UserTernaryCommand ¶ added in v0.2.2
func (*Command) RequireSysCapability ¶ added in v0.2.0
type Config ¶ added in v0.2.0
type Config struct { Path string Origin string Cgroups map[string]BaseCgroup `yaml:"cgroups,flow" json:"cgroups"` AppGroups map[string]AppGroup `yaml:"appgroups,flow" json:"appgroups"` Rules map[string]AppRule `yaml:"rules,flow" json:"rules"` }
func (*Config) IterCgroups ¶ added in v0.2.0
func (*Config) IterProfiles ¶ added in v0.2.0
type FilterProc ¶ added in v0.2.0
type Filterer ¶ added in v0.2.2
func GetFilterer ¶ added in v0.2.0
func NewProcScopeFilter ¶ added in v0.2.0
type Formatter ¶ added in v0.2.2
func GetFormatter ¶ added in v0.2.0
type Group ¶ added in v0.2.0
type Group struct { CgroupKey string `yaml:"cgroup,omitempty" json:"cgroup,omitempty"` CPUQuota string `yaml:"CPUQuota,omitempty" json:"CPUQuota,omitempty"` IOWeight string `yaml:"IOWeight,omitempty" json:"IOWeight,omitempty"` MemoryHigh string `yaml:"MemoryHigh,omitempty" json:"MemoryHigh,omitempty"` MemoryMax string `yaml:"MemoryMax,omitempty" json:"MemoryMax,omitempty"` Nice int `yaml:"nice,omitempty" json:"nice,omitempty"` Sched string `yaml:"sched,omitempty" json:"sched,omitempty"` Rtprio int `yaml:"rtprio,omitempty" json:"rtprio,omitempty"` Ioclass string `yaml:"ioclass,omitempty" json:"ioclass,omitempty"` Ionice int `yaml:"ionice,omitempty" json:"ionice,omitempty"` OomScoreAdj int `yaml:"oom_score_adj,omitempty" json:"oom_score_adj,omitempty"` }
type PresetCache ¶ added in v0.2.0
type PresetCache struct { Date string `yaml:"date" json:"date"` Cgroups map[string][]Cgroup `yaml:"cgroups,flow" json:"cgroups"` Profiles map[string][]Profile `yaml:"profiles,flow" json:"profiles"` Rules map[string][]Rule `yaml:"rules,flow" json:"rules"` Origin string `yaml:"-" json:"-"` RuleFilter FilterProc `yaml:"-" json:"-"` }
func GetPresetCache ¶ added in v0.2.0
func GetPresetCache() PresetCache
func NewPresetCache ¶ added in v0.2.0
func NewPresetCache() PresetCache
func (*PresetCache) Cgroup ¶ added in v0.2.0
func (pc *PresetCache) Cgroup(key string) (Cgroup, error)
func (*PresetCache) CgroupCandidate ¶ added in v0.2.1
func (pc *PresetCache) CgroupCandidate(base BaseCgroup) (string, bool)
func (*PresetCache) DiffReview ¶ added in v0.2.1
func (pc *PresetCache) DiffReview(job *ProcGroupJob) (count int, err error)
func (*PresetCache) Expand ¶ added in v0.2.1
func (pc *PresetCache) Expand(rule *Rule) error
func (*PresetCache) FilteredProcs ¶ added in v0.2.2
func (pc *PresetCache) FilteredProcs(inputs <-chan []*Proc, outputs chan<- []*Proc, wg *sync.WaitGroup)
func (*PresetCache) GenerateGroupJobs ¶ added in v0.2.1
func (pc *PresetCache) GenerateGroupJobs(inputs <-chan []*Proc, output chan<- *ProcGroupJob, wgmain *sync.WaitGroup) (err error)
func (*PresetCache) GenerateJobs ¶ added in v0.2.1
func (*PresetCache) GetContent ¶ added in v0.2.0
func (pc *PresetCache) GetContent() ([]byte, error)
func (*PresetCache) GetFilterer ¶ added in v0.2.1
func (pc *PresetCache) GetFilterer(scope string) ProcFilterer
func (*PresetCache) HasPreset ¶ added in v0.2.0
func (pc *PresetCache) HasPreset(category string, key string) bool
func (*PresetCache) List ¶ added in v0.2.0
func (pc *PresetCache) List(category string) (result []string, err error)
func (*PresetCache) ListFrom ¶ added in v0.2.0
func (pc *PresetCache) ListFrom(category, origin string) (result []string, err error)
func (*PresetCache) LoadFromCache ¶ added in v0.2.0
func (pc *PresetCache) LoadFromCache(cacheFile string) error
func (*PresetCache) LoadFromConfig ¶ added in v0.2.0
func (pc *PresetCache) LoadFromConfig() (err error)
func (*PresetCache) Profile ¶ added in v0.2.0
func (pc *PresetCache) Profile(key string) (Profile, error)
func (*PresetCache) RawGroupJobs ¶ added in v0.2.1
func (pc *PresetCache) RawGroupJobs(inputs <-chan []*Proc, output chan<- *ProcGroupJob, wg *sync.WaitGroup)
func (*PresetCache) RawRule ¶ added in v0.2.1
func (pc *PresetCache) RawRule(input *Request) (Rule, error)
func (*PresetCache) RequestJob ¶ added in v0.2.1
func (pc *PresetCache) RequestJob(input *Request) *ProcJob
func (*PresetCache) RequestRule ¶ added in v0.2.1
func (pc *PresetCache) RequestRule(input *Request) Rule
func (*PresetCache) SliceProperties ¶ added in v0.2.1
func (pc *PresetCache) SliceProperties(rule Rule) (result []string)
func (*PresetCache) WriteCache ¶ added in v0.2.0
func (pc *PresetCache) WriteCache(cacheFile string) error
type Proc ¶ added in v0.2.0
type Proc struct { ProcStat Uid int `json:"uid"` Cgroup string `json:"cgroup"` Slice string `json:"slice"` Unit string `json:"unit"` OomScoreAdj int `json:"oom_score_adj"` IOPrioClass int `json:"ioprio_class"` IOPrioData int `json:"ionice"` // contains filtered or unexported fields }
func AllProcs ¶ added in v0.2.2
func AllProcs() (result []*Proc)
AllProcs returns a slice of Proc for all processes.
func FilteredProcs ¶ added in v0.2.0
FilteredProcs returns a slice of Proc for filtered processes.
func GetCalling ¶ added in v0.2.0
func GetCalling() *Proc
func NewProcFromStat ¶ added in v0.2.0
func (*Proc) CPUSchedInfo ¶ added in v0.2.2
func (*Proc) GetStringMap ¶ added in v0.2.2
func (*Proc) IOSchedInfo ¶ added in v0.2.2
func (*Proc) InSystemSlice ¶ added in v0.2.2
func (*Proc) InUserSlice ¶ added in v0.2.2
func (*Proc) Runtime ¶ added in v0.2.2
func (p *Proc) Runtime() BaseProfile
type ProcByPgrp ¶ added in v0.2.2
type ProcByPgrp []*Proc
ProcByPgrp implements sort.Interface for []*Proc based on Pgrp field
func (ProcByPgrp) ByPgrp ¶ added in v0.2.2
func (s ProcByPgrp) ByPgrp() chan []*Proc
func (ProcByPgrp) Len ¶ added in v0.2.2
func (s ProcByPgrp) Len() int
func (ProcByPgrp) Less ¶ added in v0.2.2
func (s ProcByPgrp) Less(i, j int) bool
func (ProcByPgrp) Swap ¶ added in v0.2.2
func (s ProcByPgrp) Swap(i, j int)
type ProcByPid ¶ added in v0.2.2
type ProcByPid []*Proc
ProcByPid implements sort.Interface for []*Proc based on Pid field
type ProcFilter ¶ added in v0.2.0
type ProcFilter struct { FilterProc Scope string }
func (ProcFilter) String ¶ added in v0.2.2
func (pf ProcFilter) String() string
type ProcFilterer ¶ added in v0.2.0
type ProcGroupJob ¶ added in v0.2.0
type ProcGroupJob struct { Pgrp int `json:"pgrp"` Pids []int `json:"pids"` Diff Rule `json:"diff"` Commands []Command `json:"commands"` Jobs []*ProcJob `json:"jobs"` // contains filtered or unexported fields }
func (*ProcGroupJob) Add ¶ added in v0.2.0
func (job *ProcGroupJob) Add(p *ProcJob) (err error)
func (*ProcGroupJob) LeaderInfo ¶ added in v0.2.0
func (job *ProcGroupJob) LeaderInfo() (result string)
func (*ProcGroupJob) PrepareAdjust ¶ added in v0.2.0
func (job *ProcGroupJob) PrepareAdjust() error
type ProcJob ¶ added in v0.2.0
type ProcJob struct { *Proc *Request `json:"request"` Rule `json:"rule"` Commands []Command `json:"commands"` }
func NewProcJob ¶ added in v0.2.2
func ProcToProcJob ¶ added in v0.2.2
func (*ProcJob) AddCommand ¶ added in v0.2.0
func (*ProcJob) AddExecCmd ¶ added in v0.2.0
func (*ProcJob) AddProfileCommand ¶ added in v0.2.0
func (*ProcJob) AdjustIOClassIONice ¶ added in v0.2.0
func (*ProcJob) AdjustNice ¶ added in v0.2.0
func (*ProcJob) AdjustOomScoreAdj ¶ added in v0.2.0
func (*ProcJob) AdjustSchedRTPrio ¶ added in v0.2.0
func (ProcJob) IsPrivilegeRequired ¶ added in v0.2.0
func (*ProcJob) PrepareCommands ¶ added in v0.2.0
func (*ProcJob) SetPrivilege ¶ added in v0.2.0
func (*ProcJob) SetSudoIfRequired ¶ added in v0.2.0
func (job *ProcJob) SetSudoIfRequired()
type ProcStat ¶ added in v0.2.2
type ProcStat struct { Pid int `json:"pid"` // (1) %d * Comm string `json:"comm"` // (2) %s * State string `json:"state"` // (3) %c * Ppid int `json:"ppid"` // (4) %d * Pgrp int `json:"pgrp"` // (5) %d * Session int `json:"session"` // (6) %d TtyNr int `json:"tty_nr"` // (7) %d TPGid int `json:"tpgid"` // (8) %d Flags uint `json:"flags"` // (9) %u MinFlt uint `json:"minflt"` // (10) %lu CMinFlt uint `json:"cminflt"` // (11) %lu MajFlt uint `json:"majflt"` // (12) %lu CMajFlt uint `json:"cmajflt"` // (13) %lu UTime uint `json:"utime"` // (14) %lu STime uint `json:"stime"` // (15) %lu CUTime int `json:"cutime"` // (16) %ld CSTime int `json:"cstime"` // (17) %ld Priority int `json:"priority"` // (18) %ld * Nice int `json:"nice"` // (19) %ld * NumThreads int `json:"num_threads"` // (20) %ld * ITRealValue int `json:"itrealvalue"` // (21) %ld StartTime uint64 `json:"starttime"` // (22) %llu VSize uint `json:"vsize"` // (23) %lu Rss int `json:"rss"` // (24) %ld RssLim uint `json:"rsslim"` // (25) %lu StartCode uint `json:"startcode"` // (26) %lu EndCode uint `json:"endcode"` // (27) %lu StartStack uint `json:"startstack"` // (28) %lu KStkESP uint `json:"kstkesp"` // (29) %lu KStkEIP uint `json:"kstkeip"` // (30) %lu Signal uint `json:"signal"` // (31) %lu Blocked uint `json:"blocked"` // (32) %lu SigIgnore uint `json:"sigignore"` // (33) %lu SigCatch uint `json:"sigcatch"` // (34) %lu WChan uint `json:"wchan"` // (35) %lu NSwap uint `json:"nswap"` // (36) %lu - CNSwap uint `json:"cnswap"` // (37) %lu - ExitSignal int `json:"exit_signal"` // (38) %d Processor int `json:"processor"` // (39) %d RTPrio int `json:"rtprio"` // (40) %u * Policy int `json:"policy"` // (41) %u * DelayAcctBlkIOTicks uint64 `json:"delayacct_blkio_ticks"` // (42) %llu GuestTime uint `json:"guest_time"` // (43) %lu CGuestTime int `json:"cguest_time"` // ((44) %ld StartData uint `json:"start_data"` // (45) %lu EndData uint `json:"end_data"` // (46) %lu StartBrk uint `json:"start_brk"` // (47) %lu ArgStart uint `json:"arg_start"` // (48) %lu ArgEnd uint `json:"arg_end"` // (49) %lu EnvStart uint `json:"env_start"` // (50) %lu EnvEnd uint `json:"env_end"` // (51) %lu ExitCode int `json:"exit_code"` // (52) %d // contains filtered or unexported fields }
func (*ProcStat) CPUTime ¶ added in v0.2.2
CPUTime returns the total CPU user and system time in seconds.
func (*ProcStat) UnmarshalText ¶ added in v0.2.2
type Profile ¶ added in v0.2.0
type Profile struct { // Cgroup: assign to cgroup slice with `CgroupKey` // and eventually adjust scope properties in BaseCgroup BaseCgroup `yaml:"basecgroup,omitempty,flow"` BaseProfile `yaml:"baseprofile,omitempty,flow"` CgroupKey string `yaml:"cgroup,omitempty" json:"cgroup,omitempty"` ProfileKey string `yaml:"profile,omitempty" json:"profile,omitempty"` Origin string `yaml:"origin,omitempty" json:"origin,omitempty"` }
type Request ¶ added in v0.2.1
type Request struct { *BaseRequest *Proc CgroupKey string `json:"cgroup"` ForceCgroup bool `json:"probe_cgroup"` Managed bool `json:"managed"` Quiet bool `json:"quiet"` Verbosity int `json:"verbosity"` }
func NewPathRequest ¶ added in v0.2.1
func NewRequest ¶ added in v0.2.2
func (*Request) MergeFlags ¶ added in v0.2.1
func (r *Request) MergeFlags()
type Rule ¶ added in v0.2.0
type Rule struct { BaseProfile `yaml:"baseprofile,omitempty,flow"` BaseCgroup `yaml:"basecgroup,omitempty,flow"` BaseRule `yaml:"baserule,omitempty,flow"` RuleKey string `yaml:"name,omitempty" json:"name,omitempty"` Origin string `yaml:"origin,omitempty" json:"origin,omitempty"` }
func (*Rule) CgroupEntries ¶ added in v0.2.0
func (r *Rule) CgroupEntries() (BaseCgroup, bool)
func (*Rule) CgroupOnly ¶ added in v0.2.0
func (r *Rule) CgroupOnly()
func (*Rule) GetCredentials ¶ added in v0.2.0
func (*Rule) HasCPUQuota ¶ added in v0.2.0
func (*Rule) HasCgroupKey ¶ added in v0.2.0
func (*Rule) HasIOWeight ¶ added in v0.2.0
func (*Rule) HasIoclass ¶ added in v0.2.0
func (*Rule) HasMemoryHigh ¶ added in v0.2.0
func (*Rule) HasMemoryMax ¶ added in v0.2.0
func (*Rule) HasOomScoreAdj ¶ added in v0.2.0
func (*Rule) HasProfileKey ¶ added in v0.2.0
func (*Rule) SetCredentials ¶ added in v0.2.0
func (r *Rule) SetCredentials()
func (*Rule) SetSliceProperties ¶ added in v0.2.0
type Sched_Param ¶ added in v0.2.2
type Sched_Param struct {
Sched_Priority int
}
type SchedulingPolicy ¶ added in v0.2.2
type SchedulingPolicy struct { Class map[int]string NeedPriority []int NeedCredentials []int Low int High int None int }
var CPU SchedulingPolicy = SchedulingPolicy{ Class: map[int]string{ 0: "SCHED_OTHER", 1: "SCHED_FIFO", 2: "SCHED_RR", 3: "SCHED_BATCH", 5: "SCHED_IDLE", 6: "SCHED_DEADLINE", }, NeedPriority: []int{1, 2}, NeedCredentials: []int{1, 2}, Low: 1, High: 99, None: 0, }
var IO SchedulingPolicy = SchedulingPolicy{ Class: map[int]string{ 0: "none", 1: "realtime", 2: "best-effort", 3: "idle", }, NeedPriority: []int{1, 2}, NeedCredentials: []int{1}, Low: 7, High: 0, None: 4, }
type Struct ¶ added in v0.2.0
type Struct interface { BaseCgroup | Cgroup | BaseProfile | Profile | BaseRule | Rule }