Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SERVER-9644: HP-UX support for Process Monitoring Extension #17

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ public static List<String> execute(String command) {
return init(command, null);
}

public static List<String> init(String command, List<String> env) {
public static List<String> init(String command, String[] env) {
Process process;
long startTime = System.currentTimeMillis();
try {
logger.debug("Executing the command " + command);
if (env != null) {
process = Runtime.getRuntime().exec(command, env.toArray(new String[1]));
process = Runtime.getRuntime().exec(command, env);
} else {
process = Runtime.getRuntime().exec(command);
}
Expand All @@ -62,7 +62,7 @@ public static List<String> init(String command, List<String> env) {
}
}

public List<String> execute(String command, List<String> env) {
public static List<String> execute(String command, String[] env) {
return init(command, env);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public class MonitorConstants {
public static final String AIX_PROCESS_LIST_COMMAND = "ps -eo pid,pcpu=CPU%,pmem=Memory%,rss=RSS,args";

// HP-UX
public static final String HP_UX_PROCESS_LIST_COMMAND = "ps -eo pid,pcpu,vsz,args";

// For Memory machinfo | grep -i memory doesn't work on HP-UX 11.1x, so parsing top command
public static final String HPUX_TOP_COMMAND = "top -d 1";
// UNIX95= ps -eo pid,pcpu,vsz,args
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class AIXParser extends Parser {
public static final Logger logger = ExtensionsLoggerFactory.getLogger(AIXParser.class);

public Map<String, ProcessData> fetchMetrics(Map<String, ?> config) {
return fetchMetrics(config, getProcessListCommand(getCommands(config)));
return fetchMetrics(config, getProcessListCommand(getCommands(config)), null);
}

private String getProcessListCommand(Map<String, String> commands) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,35 @@

package com.appdynamics.extensions.process.parser;

import com.appdynamics.extensions.process.common.MonitorConstants;
import com.appdynamics.extensions.process.data.ProcessData;
import com.google.common.base.Strings;

import java.util.Map;

import static com.appdynamics.extensions.process.common.MonitorConstants.HP_UX;
import static com.appdynamics.extensions.process.common.MonitorConstants.PROCESS;

public class HPUXParser extends Parser {
public Map<String, ProcessData> fetchMetrics(Map<String, ?> config) {
return null;
String[] envp = {"UNIX95= "};
return fetchMetrics(config, getProcessListCommand(getCommands(config)), envp);
}

public String getProcessGroupName() {
return "HP-UX Processes";
}

private String getProcessListCommand(Map<String, String> commands) {
String cmd;
if (commands != null && !Strings.isNullOrEmpty(commands.get(PROCESS))) {
cmd = commands.get(PROCESS);
} else {
cmd = MonitorConstants.HP_UX_PROCESS_LIST_COMMAND;
}
return cmd;
}
protected Map<String, String> getCommands(Map<String, ?> config) {
return null;
return (Map) config.get(HP_UX);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class LinuxParser extends Parser {
public static final Logger logger = ExtensionsLoggerFactory.getLogger(LinuxParser.class);

public Map<String, ProcessData> fetchMetrics(Map<String, ?> config) {
return fetchMetrics(config, getProcessListCommand(getCommands(config)));
return fetchMetrics(config, getProcessListCommand(getCommands(config)), null);
}

private String getProcessListCommand(Map<String, String> commands) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public abstract class Parser {

public abstract Map<String, ProcessData> fetchMetrics(Map<String, ?> config);

public Map<String, ProcessData> fetchMetrics(Map<String, ?> config, String cmd) {
public Map<String, ProcessData> fetchMetrics(Map<String, ?> config, String cmd, String[] envp) {
List<Instance> instances = new ConfigProcessor().processConfig(config);
List<String> processListOutput = CommandExecutor.execute(cmd);
List<String> processListOutput = CommandExecutor.execute(cmd, envp);
AssertUtils.assertNotNull(processListOutput, "The output from " + cmd + " is null");
List<String> headers = getHeaders(processListOutput, cmd);
ListMultimap<String, String> filteredProcessLines = filterProcessLinesFromCompleteList(processListOutput.subList(1, processListOutput.size()), instances, headers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class SolarisParser extends Parser {
public static final Logger logger = ExtensionsLoggerFactory.getLogger(SolarisParser.class);

public Map<String, ProcessData> fetchMetrics(Map<String, ?> config) {
return fetchMetrics(config, getProcessListCommand(getCommands(config)));
return fetchMetrics(config, getProcessListCommand(getCommands(config)), null);
}

private String getProcessListCommand(Map<String, String> commands) {
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/conf/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ solaris:
aix:
process: "ps -eo pid,pcpu=CPU%,pmem=Memory%,rss=RSS,args"

hp-ux:
process: "ps -eo pid,pcpu,vsz,args"

metrics:
- "%CPU":
alias: "CPU%"
- VSZ:
alias: "Virtual Memory Size"
- CPU%:
multiplier: 1
- Memory%:
Expand Down