Skip to content
Permalink
Browse files

[JENKINS-39150] report remoting diagnostics when it's available

Since this plugin cannot assume the version of core, access the method
in question via reflection (and also report the failure to find that
method, so that we have evidence either way.)
  • Loading branch information
kohsuke committed Oct 21, 2016
1 parent b7e93c4 commit 1f43ffb1e0cdf7de4ab1090aedf2b623f151e006
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 1f43ffb

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