Skip to content

Instantly share code, notes, and snippets.

@pgilad
Last active December 17, 2020 08:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pgilad/64ae6dba94201d64f4635b4a6af4c55f to your computer and use it in GitHub Desktop.
Save pgilad/64ae6dba94201d64f4635b4a6af4c55f to your computer and use it in GitHub Desktop.
Supporting files for my blog post on remote jmx Spring Boot debugging
package com.example.demo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
@RestController
public class DemoController {
@GetMapping("/ping")
public Mono<String> ping() {
return Mono.just("pong");
}
}
monitorRole readonly
controlRole readwrite
monitorRole 123456
controlRole 123456789
#!/usr/bin/env bash
set -euo pipefail
RMI_HOST=$(wget -q -O - http://169.254.169.254/latest/meta-data/public-hostname)
java -Dcom.sun.management.jmxremote \
-Djava.net.preferIPv4Stack=true \
-Djava.rmi.server.hostname=${RMI_HOST} \
-Dcom.sun.management.jmxremote.local.only=false \
-Dcom.sun.management.jmxremote.port=9010 \
-Dcom.sun.management.jmxremote.rmi.port=9010 \
-Dcom.sun.management.jmxremote.authenticate=true \
-Dcom.sun.management.jmxremote.password.file=jmxremote.password \
-Dcom.sun.management.jmxremote.access.file=jmxremote.access \
-Dcom.sun.management.jmxremote.ssl=false \
-jar demo-0.0.1-SNAPSHOT.jar
#!/usr/bin/env bash
set -euo pipefail
java -Dcom.sun.management.jmxremote \
-Djava.net.preferIPv4Stack=true \
-Djava.rmi.server.hostname=localhost \
-Dcom.sun.management.jmxremote.local.only=true \
-Dcom.sun.management.jmxremote.port=9010 \
-Dcom.sun.management.jmxremote.rmi.port=9010 \
-Dcom.sun.management.jmxremote.authenticate=true \
-Dcom.sun.management.jmxremote.password.file=jmxremote.password \
-Dcom.sun.management.jmxremote.access.file=jmxremote.access \
-Dcom.sun.management.jmxremote.ssl=false \
-jar demo-0.0.1-SNAPSHOT.jar
Host server
HostName ec2-11-11-111-111.eu-west-1.compute.amazonaws.com
User ubuntu
IdentityFile ~/.ssh/key.pem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment