1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
Description: Manually get sysctl key to avoid go-sysctl dependency.
Author: Lena Voytek <lena.voytek@canonical.com>
Last-Update: 2024-04-10
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/system/kernel_param.go
+++ b/system/kernel_param.go
@@ -2,8 +2,10 @@
import (
"context"
+ "errors"
+ "io/ioutil"
+ "strings"
- "github.com/achanda/go-sysctl"
"github.com/goss-org/goss/util"
)
@@ -40,5 +42,9 @@
}
func (k *DefKernelParam) Value() (string, error) {
- return sysctl.Get(k.key)
+ keyData, err := ioutil.ReadFile("/proc/sys/" + strings.Replace(k.key, ".", "/", -1))
+ if err != nil {
+ return "", errors.New("could not find the given key")
+ }
+ return strings.TrimSpace(string(keyData)), nil
}
|