Skip to content

Commit 1f417dc

Browse files
authored
Check required CLIs for gathering performance data (#767)
1 parent 9a730f9 commit 1f417dc

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

utils/utils.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,14 @@ func GetLinperfCmd(encodedAttrs, podName, podNamespace string) string {
234234
linperfCmdArgs = append(linperfCmdArgs, "--ignore-root")
235235
linperfCmd := strings.Join(linperfCmdArgs, FlagDelimiterSpace)
236236

237-
requiredPackages := []string{"procps-ng", "net-tools", "ncurses", "hostname"}
237+
requiredCLIs := []string{"netstat", "ps", "dmesg", "tput", "ifconfig", "vmstat", "top", "uptime", "hostname"}
238238
cmdArgs := []string{}
239-
for _, pkg := range requiredPackages {
240-
cmdArgs = append(cmdArgs, fmt.Sprintf("$pkgcmd list installed %s", pkg))
239+
for _, cli := range requiredCLIs {
240+
cmdArgs = append(cmdArgs, fmt.Sprintf("command -v %s >/dev/null 2>&1", cli))
241241
}
242-
checkPackagesCmd := strings.Join(cmdArgs, " && ") // add spaces for readability
242+
checkCLICmd := strings.Join(cmdArgs, " && ") // add spaces for readability
243243

244-
// linperfCmdWithPids := fmt.Sprintf("mkdir -p %s && PIDS=$(ls -l /proc/[0-9]*/exe | grep \"/java$\" | xargs -L 1 | cut -d ' ' -f9 | cut -d '/' -f 3 ) && PIDS_OUT=$(echo $PIDS | tr '\n' ' ') && ls -l /proc/[0-9]*/exe > /serviceability/%s/%s/test.out && %s \"1\"", outputDir, podNamespace, podName, linperfCmd)
245-
linperfCmdWithPids := fmt.Sprintf("if ! (command -v yum && pkgcmd=yum || pkgcmd=microdnf && %s); then exit 130; elif [ $(df | grep %s -c) -eq 0 ]; then exit 129; else mkdir -p %s && %s \"1\"; fi", checkPackagesCmd, serviceabilityRootDir, outputDir, linperfCmd)
244+
linperfCmdWithPids := fmt.Sprintf("if ! (%s); then exit 130; elif [ $(df | grep %s -c) -eq 0 ]; then exit 129; else mkdir -p %s && %s \"1\"; fi", checkCLICmd, serviceabilityRootDir, outputDir, linperfCmd)
246245
// fmt.Println("Linperf cmd: " + linperfCmdWithPids) // un-commment this line for debugging
247246
return linperfCmdWithPids
248247
}

0 commit comments

Comments
 (0)