This commit is contained in:
spiritlhl
2024-07-01 14:58:24 +00:00
parent 910b7cd913
commit 6626e2a8ce
4 changed files with 135 additions and 13 deletions

25
system/sysctl.go Normal file
View File

@@ -0,0 +1,25 @@
package system
import (
"os/exec"
"strings"
)
func checkSysctlVersion() bool {
out, err := exec.Command("sysctl", "--version").Output()
if err != nil {
return false
}
if strings.Contains(string(out), "error") {
return false
}
return true
}
func getSysctlValue(key string) (string, error) {
out, err := exec.Command("sysctl", "-n", key).Output()
if err != nil {
return "", err
}
return strings.TrimSpace(string(out)), nil
}