Skip to content
Permalink
Browse files

Merge pull request #78 from jenkinsci/JENKINS-39150

[FIXED JENKINS-39150] report remoting diagnostics when it's available
  • Loading branch information
kohsuke committed Dec 6, 2016
2 parents c05e6e1 + 1f43ffb commit 5f2f23de4e674a6ca22a1a0578b9c0ffa7a58c7a
Showing with 51 additions and 0 deletions.
  1. +51 −0 src/main/java/com/cloudbees/jenkins/support/impl/RemotingDiagnostics.java
@@ -0,0 +1,51 @@
package com.cloudbees.jenkins.support.impl;

import com.cloudbees.jenkins.support.api.Component;
import com.cloudbees.jenkins.support.api.Container;
import com.cloudbees.jenkins.support.api.PrintedContent;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.remoting.Channel;
import hudson.security.Permission;
import jenkins.model.Jenkins;

import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Set;

/**
* Captures diagnostics information from remoting channels.
*
* @author Kohsuke Kawaguchi
*/
public class RemotingDiagnostics extends Component {

@NonNull
@Override
public Set<Permission> getRequiredPermissions() {
return Collections.singleton(Jenkins.ADMINISTER);
}

@NonNull
@Override
public String getDisplayName() {
return "Remoting Channel Diagnostics";
}

@Override
public void addContents(@NonNull Container container) {
container.add(new PrintedContent("channel-diagnostics.md") {
@Override
protected void printTo(PrintWriter out) throws IOException {
// this method is new in remoting. see JENKINS-39150 change in remoting
try {
Method m = Channel.class.getMethod("dumpDiagnosticsForAll", PrintWriter.class);
m.invoke(null,out);
} catch (Exception e) {
e.printStackTrace(out);
}
}
});
}
}

0 comments on commit 5f2f23d

Please sign in to comment.
You can’t perform that action at this time.