summaryrefslogtreecommitdiffstats
path: root/node-admin
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2021-09-14 16:15:47 +0200
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2021-09-15 12:49:45 +0200
commit9fb7c0d06d3fe37521c910b1ea3121e7682df4c1 (patch)
treed15d915dc18b764fb1340d89e3c14819401873a7 /node-admin
parent3fe3c64f15774aaf7d2f18d1fa5931a3b1bc16d4 (diff)
Add method to find Vespa service pid
Diffstat (limited to 'node-admin')
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/servicedump/AbstractProducer.java6
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/servicedump/PerfReportProducer.java6
2 files changed, 7 insertions, 5 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/servicedump/AbstractProducer.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/servicedump/AbstractProducer.java
index de00b119cd0..eabf38d5f64 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/servicedump/AbstractProducer.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/servicedump/AbstractProducer.java
@@ -6,6 +6,7 @@ import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentContext;
import com.yahoo.vespa.hosted.node.admin.task.util.process.CommandResult;
import java.io.IOException;
+import java.nio.file.Path;
import java.util.List;
import java.util.logging.Logger;
import java.util.stream.Collectors;
@@ -45,5 +46,10 @@ abstract class AbstractProducer implements ArtifactProducer {
return result;
}
+ protected int findVespaServicePid(NodeAgentContext ctx, String configId) throws IOException {
+ Path findPidBinary = ctx.pathInNodeUnderVespaHome("libexec/vespa/find-pid");
+ CommandResult findPidResult = executeCommand(ctx, List.of(findPidBinary.toString(), configId), true);
+ return Integer.parseInt(findPidResult.getOutput());
+ }
}
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/servicedump/PerfReportProducer.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/servicedump/PerfReportProducer.java
index f2725f4ba45..1407153f50f 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/servicedump/PerfReportProducer.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/servicedump/PerfReportProducer.java
@@ -4,10 +4,8 @@ package com.yahoo.vespa.hosted.node.admin.maintenance.servicedump;
import com.yahoo.vespa.hosted.node.admin.container.ContainerOperations;
import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentContext;
import com.yahoo.vespa.hosted.node.admin.task.util.file.UnixPath;
-import com.yahoo.vespa.hosted.node.admin.task.util.process.CommandResult;
import java.io.IOException;
-import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
@@ -25,9 +23,7 @@ class PerfReportProducer extends AbstractProducer {
@Override
public void produceArtifact(NodeAgentContext context, String configId, ServiceDumpReport.DumpOptions options,
UnixPath resultDirectoryInNode) throws IOException {
- Path findPidBinary = context.pathInNodeUnderVespaHome("libexec/vespa/find-pid");
- CommandResult findPidResult = executeCommand(context, List.of(findPidBinary.toString(), configId), true);
- String pid = findPidResult.getOutput();
+ int pid = findVespaServicePid(context, configId);
int duration = options != null && options.duration() != null && options.duration() > 0
? options.duration().intValue() : 30;
List<String> perfRecordCommand = new ArrayList<>(List.of("perf", "record"));