-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bump version to 1.6.0-SNAPSHOT before we start conversion * Jlinked application support * Use two test-servers. One for JDK8 and one for JDK11 * Update certificates
- Loading branch information
Showing
54 changed files
with
1,974 additions
and
1,382 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
name: Java CI | ||
on: [ push ] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: '11' | ||
java-package: jdk | ||
- name: Build with Gradle | ||
run: ./gradlew build -i -s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,22 +89,21 @@ $ ./bin/nrjmx -hostname localhost -port 1689 -uriPath "org.opends.server.protoco | |
|
||
If you are having difficulties with `nrjmx` to get data out of your JMX service, we provide a CLI tool (`jmxterm`) to help you [troubleshoot](./TROUBLESHOOT.md). | ||
|
||
|
||
## Building | ||
|
||
nrjmx uses Maven for generating the binaries: | ||
nrjmx uses Gradle for generating the binaries: | ||
|
||
```bash | ||
$ mvn package | ||
$ ./gradlew build | ||
``` | ||
|
||
This creates the `nrjmx.jar` file under the `./bin/` directory. Copy the `bin/nrjmx` and `bin/nrjmx.jar` files to your preferred location. Both files must | ||
be located under the same folder. | ||
|
||
It also creates DEB and RPM packages to automatically install nrjmx. If you want to skip the creation of DEB and RPM packages (for example, because your development machine does not provide the required tools), you can disable the `deb` and `rpm` Maven profiles from the command line: | ||
This creates the modularised `nrjmx.jar` file under the `./build/libs` directory as well as a `tar` and `zip` under the `build/distributions` directory. It can also build RPM & DEB packages. | ||
|
||
```bash | ||
mvn clean package -P \!deb,\!rpm,\!tarball,\!test | ||
$ ./gradlew buildDeb # Debian package | ||
$ ./gradlew buildRpm # RPM package | ||
$ ./gradlew distTar # Tar ball | ||
$ ./gradlew distZip # ZIP package | ||
``` | ||
|
||
## Support | ||
|
@@ -113,6 +112,91 @@ New Relic hosts and moderates an online forum where customers can interact with | |
|
||
https://discuss.newrelic.com/c/support-products-agents/new-relic-infrastructure | ||
|
||
## Using testservers for testing | ||
|
||
It builds a test service that introduces some monitoring. | ||
|
||
### Build | ||
|
||
`./gradlew :test-server-jdk8:build` will generate both a runnable jar file as well as copy the appropriate files from `src/docker` to a location where it can be used to build a container. | ||
Replace `test-server-jdk8` with `test-server-jdk11` to build a runnable jar with JDK11 | ||
|
||
|
||
### Run (with JMX enabled) | ||
|
||
The project itself does not run the container. | ||
Instead this happens when `./gradlew :test` is executed. | ||
The containers are built from within testcontainers and then executed. | ||
|
||
It uses the following ports: | ||
|
||
* `4567`: HTTP REST port | ||
* `7199`: JMX RMI port | ||
|
||
If you want to enable SSL, `JAVA_OPTS` should be: | ||
|
||
``` | ||
-Dcom.sun.management.jmxremote.authenticate=false | ||
-Dcom.sun.management.jmxremote.ssl=true | ||
-Dcom.sun.management.jmxremote.ssl.need.client.auth=true | ||
-Dcom.sun.management.jmxremote.registry.ssl=true | ||
-Djavax.net.ssl.keyStore=/serverkeystore | ||
-Djavax.net.ssl.keyStorePassword=serverpass | ||
-Djavax.net.ssl.trustStore=/servertruststore | ||
-Djavax.net.ssl.trustStorePassword=servertrustpass | ||
``` | ||
|
||
(This is already done with the test code). | ||
|
||
## Building the container manually | ||
|
||
If you need to build and run the container manually then you can do: | ||
|
||
``` | ||
./gradlew :test-server-jdk8:install | ||
docker build test-server-jdk8/build/install/test-server-jdk8 | ||
``` | ||
|
||
(Replace with `test-server-jdk11` as appropriate). | ||
|
||
### REST API: | ||
|
||
In the port `4567`: | ||
|
||
* `POST /cat` | ||
* BODY: `{"name":"Isidoro"}` would register in JMX a cat named Isidoro to the registry name | ||
|
||
* `PUT /clear` | ||
* Will clear all the cats from JMX | ||
|
||
### Example JMX test | ||
|
||
``` | ||
$ curl -X POST -d '{"name":"Isidoro"}' http://localhost:4567/cat | ||
ok! | ||
$ curl -X POST -d '{"name":"Heathcliff"}' http://localhost:4567/cat | ||
ok! | ||
$ ./nrjmx | ||
test:type=Cat,* | ||
{"test:type\u003dCat,name\u003dIsidoro,attr\u003dName":"Isidoro","test:type\u003dCat,name\u003dHeathcliff,attr\u003dName":"Heathcliff"} | ||
$ curl -X PUT http://localhost:4567/clear | ||
ok! | ||
$ ./nrjmx | ||
test:type=Cat,* | ||
{} | ||
``` | ||
|
||
### Re-generating keys | ||
|
||
``` | ||
keytool -genkeypair -dname "cn=server, ou=nrjmx, o=NR, c=US" -keystore serverkeystore -keyalg RSA -alias serverkey -validity 180 -storepass serverpass -keypass serverpass | ||
keytool -exportcert -keystore serverkeystore -alias serverkey -storepass serverpass -file server.cer | ||
keytool -import -v -trustcacerts -alias serverkey -file server.cer -keystore clienttruststore -storepass clienttrustpass -noprompt | ||
keytool -genkeypair -dname "cn=client, ou=test, o=NR, c=US" -keystore clientkeystore -keyalg RSA -alias clientkey -validity 180 -storepass clientkeystore -keypass clientkeystore | ||
keytool -exportcert -keystore clientkeystore -alias clientkey -storepass clientkeystore -file client.cer | ||
keytool -import -v -trustcacerts -alias clientkey -file client.cer -keystore servertruststore -storepass servertrustpass -noprompt | ||
``` | ||
|
||
## Contributing | ||
We encourage your contributions to improve New Relic JMX fetcher! Keep in mind when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project. | ||
If you have any questions, or to execute our corporate CLA, required if your contribution is on behalf of a company, please drop us an email at [email protected]. | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
import org.redline_rpm.header.Architecture.X86_64 | ||
import org.redline_rpm.header.Os.LINUX | ||
import fi.linuxbox.gradle.download.Download | ||
|
||
plugins { | ||
java | ||
`maven-publish` | ||
id("org.beryx.jlink") version ("2.21.2") | ||
id("org.ysb33r.java.modulehelper") version ("0.9.0") | ||
id("com.github.sherter.google-java-format") version ("0.8") | ||
id("nebula.ospackage") version ("8.4.1") | ||
id("fi.linuxbox.download") version ("0.6") | ||
} | ||
|
||
val jmxTermVersion: String by project | ||
|
||
allprojects { | ||
repositories { | ||
mavenCentral() | ||
maven { | ||
url = uri("https://repo.maven.apache.org/maven2") | ||
} | ||
} | ||
} | ||
|
||
configurations.create("jmxterm") | ||
|
||
dependencies { | ||
implementation("commons-cli:commons-cli:1.4") | ||
implementation("com.google.code.gson:gson:2.8.0") | ||
} | ||
|
||
extraJavaModules { | ||
module("commons-cli-1.4.jar", "commons.cli", "1.4") { | ||
exports("org.apache.commons.cli") | ||
} | ||
module("gson-2.8.0.jar", "com.google.code.gson", "2.8.0") { | ||
exports("com.google.gson") | ||
} | ||
} | ||
|
||
java { | ||
modularity.inferModulePath.set(true) | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>("nrjmx") { | ||
from(components["java"]) | ||
} | ||
} | ||
} | ||
|
||
application { | ||
mainClass.set("org.newrelic.nrjmx.Application") | ||
mainModule.set("org.newrelic.nrjmx") | ||
} | ||
|
||
jlink { | ||
} | ||
|
||
tasks.named<JavaCompile>("compileJava") { | ||
options.javaModuleVersion.set(provider({ project.version as String })) | ||
} | ||
|
||
tasks.test { | ||
enabled = false | ||
} | ||
|
||
tasks.register<Download>("downloadJmxTerm") { | ||
group = "JmxTerm" | ||
description = "Downloads jmxterm" | ||
from ("https://github.com/jiaqi/jmxterm/releases/download/v${jmxTermVersion}/jmxterm-${jmxTermVersion}-uber.jar") | ||
to ("${buildDir}/jmxterm/lib/jmxterm-uber.jar") | ||
} | ||
|
||
tasks.register<CreateStartScripts>("jmxtermScripts") { | ||
group = "JmxTerm" | ||
description = "Scripts to wrap jmxterm" | ||
applicationName = "jmxterm" | ||
outputDir = file("${buildDir}/jmxterm/bin") | ||
mainClassName = "" | ||
(unixStartScriptGenerator as TemplateBasedScriptGenerator).template = project.resources.text.fromFile(file("src/jmxterm/jmxterm.template.sh")) | ||
(windowsStartScriptGenerator as TemplateBasedScriptGenerator).template = project.resources.text.fromFile(file("src/jmxterm/jmxterm.template.bat")) | ||
} | ||
|
||
|
||
tasks.buildDeb { | ||
dependsOn(tasks.jlink) | ||
|
||
from("${buildDir}/jmxterm") { | ||
include ("lib/jmxterm-uber.jar") | ||
into("/usr/lib/${project.name}") | ||
} | ||
|
||
from("src/deb/usr/bin") { | ||
into("/usr/bin") | ||
include("**") | ||
fileMode = 0x1ED | ||
} | ||
from("${buildDir}/image") { | ||
into("/usr/lib/${project.name}") | ||
} | ||
from("LICENSE") { | ||
into("/usr/share/doc/${project.name}") | ||
} | ||
from("README.md") { | ||
into("/usr/share/doc/${project.name}") | ||
} | ||
} | ||
|
||
tasks.buildRpm { | ||
setRelease("1") | ||
setArch(X86_64) | ||
setOs(LINUX) | ||
setVendor("New Relic Infrastructure Team <[email protected]>") | ||
setPackageGroup("Application/System") | ||
setLicense("Apache 2.0") | ||
|
||
dependsOn(tasks.jlink) | ||
|
||
from("${buildDir}/jmxterm") { | ||
include ("lib/jmxterm-uber.jar") | ||
into("/usr/lib/${project.name}") | ||
} | ||
|
||
from("src/rpm/usr/bin") { | ||
into("/usr/bin") | ||
include("**") | ||
fileMode = 0x1ED | ||
} | ||
from("${buildDir}/image") { | ||
into("/usr/lib/${project.name}") | ||
} | ||
from("LICENSE") { | ||
into("/usr/share/doc/${project.name}") | ||
addParentDirs = false | ||
} | ||
from("README.md") { | ||
into("/usr/share/doc/${project.name}") | ||
addParentDirs = false | ||
} | ||
} | ||
|
||
tasks.distZip { | ||
dependsOn("downloadJmxTerm","jmxtermScripts") | ||
from("${buildDir}/jmxterm") { | ||
include ("**") | ||
into ("${project.name}-${project.version}") | ||
} | ||
} | ||
|
||
tasks.distTar { | ||
dependsOn("downloadJmxTerm","jmxtermScripts") | ||
from("${buildDir}/jmxterm") { | ||
include ("**") | ||
into ("${project.name}-${project.version}") | ||
} | ||
} | ||
|
||
tasks.register("package") { | ||
group = "Distribution" | ||
description = "Builds all packages" | ||
dependsOn("distTar", "distZip", "buildDeb", "buildRpm") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
group=nrjmx | ||
version=1.6.0-SNAPSHOT | ||
description=The New Relic JMX tool provides a command line tool to connect to a JMX server and retrieve the MBeans it exposes | ||
jmxTermVersion=1.0.2 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.