Skip to content

Commit

Permalink
#4
Browse files Browse the repository at this point in the history
.classpath
.settings/org.eclipse.core.resources.prefs
.settings/org.eclipse.jdt.core.prefs
~~~
eclipse config

pom.xml
~~~
upgrade jsch from 0.1.54.1 to 0.1.55.1

java from 7 to 8 because jsch require 0.1.55.1 require java8 min

src/main/java/io/jenkins/plugins/sample/MTRBuilder.java
~~~
support report cycle count
support packet size

src/main/resources/io/jenkins/plugins/sample/MTRBuilder/config.jelly
~~~
support report cycle count
support packet size

src/main/resources/io/jenkins/plugins/sample/MTRBuilder/config.properties
~~~
support report cycle count
support packet size
  • Loading branch information
jasonwee committed Aug 14, 2021
1 parent 115e6fe commit 951d831
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="src/main/java">
Expand Down Expand Up @@ -770,6 +771,7 @@
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
Expand Down
2 changes: 2 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//target/generated-sources/localizer=UTF-8
encoding//target/generated-test-sources/injected=UTF-8
encoding/<project>=UTF-8
3 changes: 3 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.7
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<properties>
<!-- Baseline Jenkins version you use to build the plugin. Users must have this version or newer to run. -->
<jenkins.version>2.7.3</jenkins.version>
<java.level>7</java.level>
<java.level>8</java.level>
<!-- Other properties you may want to use:
~ jenkins-test-harness.version: Jenkins Test Harness version you use to test the plugin. For Jenkins version >= 1.580.1 use JTH 2.0 or higher.
~ hpi-plugin.version: The HPI Maven Plugin version used by the plugin..
Expand All @@ -47,7 +47,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54.1</version>
<version>0.1.55.1</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down
25 changes: 23 additions & 2 deletions src/main/java/io/jenkins/plugins/sample/MTRBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,24 @@ public class MTRBuilder extends Builder implements SimpleBuildStep {
private String sshPassword;
private int sshPort;

private int packetSize;
private int reportCount;

private String ip2locationPyPath;

private StringBuffer mtrOutputs;
private Map<String, Integer> ids;
private Integer id;

@DataBoundConstructor
public MTRBuilder(String nodes, String sshUsername, String sshKeyfile, String sshPassword, int sshPort, String ip2locationPyPath) {
public MTRBuilder(String nodes, String sshUsername, String sshKeyfile, String sshPassword, int sshPort, int packetSize, int reportCount, String ip2locationPyPath) {
this.nodes = nodes;
this.sshUsername = sshUsername;
this.sshKeyfile = sshKeyfile;
this.sshPassword = sshPassword;
this.sshPort = sshPort;
this.packetSize = packetSize;
this.reportCount = reportCount;
this.ip2locationPyPath = ip2locationPyPath;
}

Expand Down Expand Up @@ -102,6 +107,22 @@ public void setSshPort(int sshPort) {
this.sshPort = sshPort;
}

public int getPacketSize() {
return packetSize;
}

public void setPacketSize(int packetSize) {
this.packetSize = packetSize;
}

public int getReportCount() {
return reportCount;
}

public void setReportCount(int reportCount) {
this.reportCount = reportCount;
}

public String getIp2locationPyPath() {
return ip2locationPyPath;
}
Expand Down Expand Up @@ -178,7 +199,7 @@ public void perform(Run<?, ?> run, FilePath workspace, Launcher launcher, TaskLi
n2.setTitle(title);
mtrReport.addNode(n2);

String mtrCommand = String.format("sudo mtr --report-wide -s 10 -r -c 10 %s", dNode);
String mtrCommand = String.format("sudo mtr --report-wide -s %s -r -c %s %s", getPacketSize(), getReportCount(), dNode);
listener.getLogger().println("running command '" + mtrCommand + "' on " + sNode);

executeCommand(listener.getLogger(), mtrCommand, false, sNode, mtrOutput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@
<f:entry title="${%Nodes}" field="nodes">
<f:textarea />
</f:entry>
<f:entry title="${%PacketSize}" field="packetSize">
<f:textbox default="10" />
</f:entry>
<f:entry title="${%ReportCount}" field="reportCount">
<f:textbox default="10" />
</f:entry>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ SSHKeyfile=SSH KeyFile
SSHPassword=SSH Password
SSHPort=SSH Port
IP2LocationPyPath=IP2Location python path
Nodes=Node Pair
Nodes=Node Pair
PacketSize=Packet Size
ReportCount=Report cycle count

0 comments on commit 951d831

Please sign in to comment.