Skip to content

Commit

Permalink
chore(proctree): rename cmdline flags to -cache
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeldtinoco committed Sep 18, 2023
1 parent 81f452e commit 3c79d54
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/tracee/cmd/root.go
Expand Up @@ -227,7 +227,7 @@ func initCmd() error {
"proctree",
"t",
[]string{"none"},
"[process|thread]\t\t\tControl process tree cache sizes",
"[process|thread]\t\t\tControl process tree options",
)
err = viper.BindPFlag("proctree", rootCmd.Flags().Lookup("proctree"))
if err != nil {
Expand Down
22 changes: 11 additions & 11 deletions pkg/cmd/flags/proctree_cache.go
Expand Up @@ -14,12 +14,12 @@ func procTreeHelp() string {
Example:
--proctree enabled | will enable the process tree with default settings (disabled by default).
--proctree process=8192 | will cache up to 8192 processes in the tree (LRU cache).
--proctree thread=4096 | will cache up to 4096 threads in the tree (LRU cache).
--proctree process-cache=8192 | will cache up to 8192 processes in the tree (LRU cache).
--proctree thread-cache=4096 | will cache up to 4096 threads in the tree (LRU cache).
Use comma OR use the flag multiple times to choose multiple options:
--proctree process=X,thread=Y
--proctree process=X --proctree thread=Y
--proctree process-cache=X,thread-cache=Y
--proctree process-cache=X --proctree thread-cache=Y
`
}

Expand All @@ -36,36 +36,36 @@ func PrepareProcTree(cacheSlice []string) (proctree.ProcTreeConfig, error) {
return config, fmt.Errorf(procTreeHelp())
}
if strings.HasPrefix(slice, "none") {
logger.Debugw("proctree cache has default size")
return config, nil
}

values := strings.Split(slice, ",")

for _, value := range values {
if strings.HasPrefix(value, "enabled") {
logger.Debugw("proctree is enabled")
config.Enabled = true
continue
}
if strings.HasPrefix(value, "process=") {
num := strings.TrimPrefix(value, "process=")
if strings.HasPrefix(value, "process-cache=") {
num := strings.TrimPrefix(value, "process-cache=")
size, err := strconv.Atoi(num)
if err != nil {
return config, err
}
if size > 4096 { // minimum size is 4096 (or the default is used)
if size >= 4096 { // minimum size is 4096 (or the default is used)
config.ProcessCacheSize = size
}
config.Enabled = true
continue
}
if strings.HasPrefix(value, "thread=") {
num := strings.TrimPrefix(value, "thread=")
if strings.HasPrefix(value, "thread-cache=") {
num := strings.TrimPrefix(value, "thread-cache=")
size, err := strconv.Atoi(num)
if err != nil {
return config, err
}
if size > 4096 { // minimum size is 4096 (or the default is used)
if size >= 4096 { // minimum size is 4096 (or the default is used)
config.ThreadCacheSize = size
}
config.Enabled = true
Expand Down

0 comments on commit 3c79d54

Please sign in to comment.