diff --git a/changelog.html b/changelog.html
index 6477983581..5203618296 100644
--- a/changelog.html
+++ b/changelog.html
@@ -58,7 +58,8 @@ Upcoming changes
, Stapl
rsp.sendRedirect2("threadDump");
}
+ /**
+ * Obtains the thread dump of all slaves (including the master.)
+ *
+ *
+ * Since this is for diagnostics, it has a built-in precautionary measure against hang slaves.
+ */
+ public Map> getAllThreadDumps() throws IOException, InterruptedException {
+ checkPermission(ADMINISTER);
+
+ // issue the requests all at once
+ Map>> future = new HashMap>>();
+ for (Computer c : getComputers()) {
+ future.put(c.getName(), RemotingDiagnostics.getThreadDumpAsync(c.getChannel()));
+ }
+
+ // if the result isn't available in 5 sec, ignore that.
+ // this is a precaution against hang nodes
+ long endTime = System.currentTimeMillis() + 5000;
+
+ Map> r = new HashMap>();
+ for (Entry>> e : future.entrySet()) {
+ try {
+ r.put(e.getKey(), e.getValue().get(endTime-System.currentTimeMillis(), TimeUnit.MILLISECONDS));
+ } catch (Exception x) {
+ StringWriter sw = new StringWriter();
+ x.printStackTrace(new PrintWriter(sw,true));
+ r.put(e.getKey(), Collections.singletonMap("Failed to retrieve thread dump",sw.toString()));
+ }
+ }
+ return r;
+ }
+
public synchronized Item doCreateItem( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
return itemGroupMixIn.createTopLevelItem(req, rsp);
}
diff --git a/core/src/main/java/hudson/util/RemotingDiagnostics.java b/core/src/main/java/hudson/util/RemotingDiagnostics.java
index 326d1c7438..cc86c37bb9 100644
--- a/core/src/main/java/hudson/util/RemotingDiagnostics.java
+++ b/core/src/main/java/hudson/util/RemotingDiagnostics.java
@@ -27,8 +27,10 @@ import groovy.lang.GroovyShell;
import hudson.FilePath;
import hudson.Functions;
import hudson.model.Hudson;
+import hudson.remoting.AsyncFutureImpl;
import hudson.remoting.Callable;
import hudson.remoting.DelegatingCallable;
+import hudson.remoting.Future;
import hudson.remoting.VirtualChannel;
import hudson.security.AccessControlled;
import org.kohsuke.stapler.StaplerRequest;
@@ -78,6 +80,12 @@ public final class RemotingDiagnostics {
return channel.call(new GetThreadDump());
}
+ public static Future