Skip to content

Commit

Permalink
Capture /proc/cmdline in health report (#281)
Browse files Browse the repository at this point in the history
So that any checks related to it (e.g. IOMMU configuration) can be performed subsequently.
  • Loading branch information
anjalshireesh authored May 23, 2024
1 parent bdb5329 commit b5c00f3
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion health.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,9 @@ func GetSysConfig(_ context.Context, addr string) SysConfig {
limits, err := proc.Limits()
if err != nil {
sc.Error = "rlimit: " + err.Error()
} else {
sc.Config["rlimit-max"] = limits.OpenFiles
}
sc.Config["rlimit-max"] = limits.OpenFiles
}

zone, _ := time.Now().Zone()
Expand All @@ -468,6 +469,18 @@ func GetSysConfig(_ context.Context, addr string) SysConfig {

sc.Config["thp-config"] = getTHPConfigs()

procCmdLine, err := getProcCmdLine()
if err != nil {
errMsg := "proc-cmdline: " + err.Error()
if len(sc.Error) == 0 {
sc.Error = errMsg
} else {
sc.Error = sc.Error + ", " + errMsg
}
} else {
sc.Config["proc-cmdline"] = procCmdLine
}

return sc
}

Expand Down Expand Up @@ -496,6 +509,14 @@ func getTHPConfigs() map[string]string {
return configs
}

func getProcCmdLine() ([]string, error) {
fs, err := procfs.NewDefaultFS()
if err != nil {
return nil, err
}
return fs.CmdLine()
}

func captureTHPConfig(configs map[string]string, filePath string, cfgName string) {
errFieldName := cfgName + "_error"
data, err := os.ReadFile(filePath)
Expand Down

0 comments on commit b5c00f3

Please sign in to comment.