Rename spring-boot-starter-shell -> remote-shell
Fixes gh-462
This commit is contained in:
@@ -0,0 +1 @@
|
||||
provides: crash.cli,crash.shell,crash.plugins.cron,crash.embed.spring,crash.connectors.telnet,crash.connectors.ssh
|
||||
@@ -0,0 +1,29 @@
|
||||
package commands
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.AutoConfigurationReportEndpoint
|
||||
|
||||
class autoconfig {
|
||||
|
||||
@Usage("Display auto configuration report from ApplicationContext")
|
||||
@Command
|
||||
void main(InvocationContext context) {
|
||||
context.attributes['spring.beanfactory'].getBeansOfType(AutoConfigurationReportEndpoint.class).each { name, endpoint ->
|
||||
def report = endpoint.invoke()
|
||||
out.println "Endpoint: " + name + "\n\nPositive Matches:\n================\n"
|
||||
report.positiveMatches.each { key, list ->
|
||||
out.println key + ":"
|
||||
list.each { mandc ->
|
||||
out.println " " + mandc.condition + ": " + mandc.message
|
||||
}
|
||||
}
|
||||
out.println "\nNegative Matches\n================\n"
|
||||
report.negativeMatches.each { key, list ->
|
||||
out.println key + ":"
|
||||
list.each { mandc ->
|
||||
out.println " " + mandc.condition + ": " + mandc.message
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package commands
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.BeansEndpoint
|
||||
|
||||
class beans {
|
||||
|
||||
@Usage("Display beans in ApplicationContext")
|
||||
@Command
|
||||
def main(InvocationContext context) {
|
||||
def result = [:]
|
||||
context.attributes['spring.beanfactory'].getBeansOfType(BeansEndpoint.class).each { name, endpoint ->
|
||||
result.put(name, endpoint.invoke())
|
||||
}
|
||||
result.size() == 1 ? result.values()[0] : result
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package commands
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.Endpoint
|
||||
import org.springframework.boot.actuate.endpoint.jmx.*
|
||||
|
||||
@Usage("Invoke actuator endpoints")
|
||||
class endpoint {
|
||||
|
||||
@Usage("List all available and enabled actuator endpoints")
|
||||
@Command
|
||||
def list(InvocationContext context) {
|
||||
|
||||
context.attributes['spring.beanfactory'].getBeansOfType(Endpoint.class).each { name, endpoint ->
|
||||
if (endpoint.isEnabled()) {
|
||||
out.println name
|
||||
}
|
||||
}
|
||||
""
|
||||
}
|
||||
|
||||
@Usage("Invoke provided actuator endpoint")
|
||||
@Command
|
||||
def invoke(InvocationContext context, @Usage("The name of the Endpoint to invoke") @Required @Argument String name) {
|
||||
|
||||
// Don't require passed argument to end with 'Endpoint'
|
||||
if (!name.endsWith("Endpoint")) {
|
||||
name = name + "Endpoint"
|
||||
}
|
||||
|
||||
context.attributes['spring.beanfactory'].getBeansOfType(Endpoint.class).each { n, endpoint ->
|
||||
if (n.equals(name) && endpoint.isEnabled()) {
|
||||
|
||||
EndpointMBean mbean = context.attributes['spring.beanfactory'].getBean(EndpointMBeanExporter.class).getEndpointMBean(name, endpoint)
|
||||
if (mbean instanceof DataEndpointMBean) {
|
||||
out.println mbean.getData()
|
||||
}
|
||||
else {
|
||||
out.println mbean.endpoint.invoke()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
""
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
welcome = { ->
|
||||
if (!crash.context.attributes['spring.environment'].getProperty("spring.main.show_banner", Boolean.class, Boolean.TRUE)) {
|
||||
return ""
|
||||
}
|
||||
|
||||
// Resolve hostname
|
||||
def hostName;
|
||||
try {
|
||||
hostName = java.net.InetAddress.getLocalHost().getHostName();
|
||||
}
|
||||
catch (java.net.UnknownHostException ignore) {
|
||||
hostName = "localhost";
|
||||
}
|
||||
|
||||
// Get Spring Boot version from context
|
||||
def version = crash.context.attributes.get("spring.boot.version")
|
||||
|
||||
return """\
|
||||
. ____ _ __ _ _
|
||||
/\\\\ / ___'_ __ _ _(_)_ __ __ _ \\ \\ \\ \\
|
||||
( ( )\\___ | '_ | '_| | '_ \\/ _` | \\ \\ \\ \\
|
||||
\\\\/ ___)| |_)| | | | | || (_| | ) ) ) )
|
||||
' |____| .__|_| |_|_| |_\\__, | / / / /
|
||||
=========|_|==============|___/=/_/_/_/
|
||||
:: Spring Boot :: (v$version) on $hostName
|
||||
""";
|
||||
}
|
||||
|
||||
prompt = { ->
|
||||
return "> ";
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package commands
|
||||
|
||||
import org.crsh.text.ui.UIBuilder
|
||||
import org.springframework.boot.actuate.endpoint.MetricsEndpoint
|
||||
|
||||
class metrics {
|
||||
|
||||
@Usage("Display metrics provided by Spring Boot")
|
||||
@Command
|
||||
public void main(InvocationContext context) {
|
||||
|
||||
context.takeAlternateBuffer();
|
||||
try {
|
||||
while (!Thread.interrupted()) {
|
||||
out.cls()
|
||||
out.show(new UIBuilder().table(columns:[1]) {
|
||||
header {
|
||||
table(columns:[1], separator: dashed) {
|
||||
header(bold: true, fg: black, bg: white) { label("metrics"); }
|
||||
}
|
||||
}
|
||||
row {
|
||||
table(columns:[1, 1]) {
|
||||
header(bold: true, fg: black, bg: white) {
|
||||
label("NAME")
|
||||
label("VALUE")
|
||||
}
|
||||
|
||||
context.attributes['spring.beanfactory'].getBeansOfType(MetricsEndpoint.class).each { name, metrics ->
|
||||
metrics.invoke().each { k, v ->
|
||||
row {
|
||||
label(k)
|
||||
label(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
out.flush();
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
context.releaseAlternateBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user