Skip to content

Commit

Permalink
[support/kernel] Add simple globs support for parameter names
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Sep 26, 2024
1 parent 7523cc7 commit 5c8b49e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### [13.6.0](https://kaos.sh/ek/13.6.0)

- `[setup]` Added package to install/uninstall application as a service
- `[support/kernel]` Added simple globs support for parameter names

### [13.5.1](https://kaos.sh/ek/13.5.1)

Expand Down
13 changes: 11 additions & 2 deletions support/kernel/kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,18 @@ func Collect(params ...string) []support.KernelParam {
var result []support.KernelParam

for _, param := range params {
isGlob := strings.HasSuffix(param, "*")
param = strings.TrimRight(param, "*")

for k, v := range kernelParams {
if !strings.HasPrefix(k, param) {
continue
if isGlob {
if !strings.HasPrefix(k, param) {
continue
}
} else {
if k != param {
continue
}
}

value := strings.ReplaceAll(v, "\t", " ")
Expand Down
4 changes: 2 additions & 2 deletions support/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Example of collecting maximum information about the application and system:
WithNetwork(network.Collect("https://cloudflare.com/cdn-cgi/trace")).
WithFS(fs.Collect()).
WithResources(resources.Collect()).
WithKernel(kernel.Collect()).
WithKernel(kernel.Collect("vm.nr_hugepages*", "vm.swappiness")).
Print()
Also, you can't encode data to JSON/GOB and send it to your server instead of printing
Expand All @@ -49,7 +49,7 @@ it to the console.
WithNetwork(network.Collect("https://cloudflare.com/cdn-cgi/trace")).
WithFS(fs.Collect()).
WithResources(resources.Collect()).
WithKernel(kernel.Collect())
WithKernel(kernel.Collect("vm.nr_hugepages*", "vm.swappiness"))
b, _ := json.Marshal(info)
Expand Down

0 comments on commit 5c8b49e

Please sign in to comment.