Table of Contents
Table of Contents
CRaSH is a shell that extends JVM. With CRaSH, you will connect with a shell directly on a JVM. Moreover, you could add your command (Java/Groovy) and that's why CRaSH is really interesting.
Monitoring JVM and make your own dashboard command.
Make command for your application (add data in a cache, add user, monitor jobs ).
Make your JMX command.
See documentation : reference.html#running
See documentation Connection in Shell Usage chapter reference.html#connection
The best way to create a command is to use CRaSH utilities. See command as a class : reference.html#command_as_class
In most cases, when you created a command, it's a syntax error in a command. Check your import and syntax with your ide.
You have to launch CRaSH in standalone mode once. Then, it will appears in $CRASH_HOME/conf/
It could happen when you have an error in your command. For example :
% jdbc select se Remoting issue
Table of Contents
In this cookbook, you will learn how to create a simple script command. You will see that you can create it dynamically without restarting CRaSH.
A better solution to create a command is to use CRaSH class.It provides tools to simply command creation.
cd $CRASH_HOME/bin ./crash.sh Type help at prompt
You will see something like :
Try one of these commands with the -h or --help switch: NAME DESCRIPTION clock dashboard date show the current time env display the term env filter hello help provides basic help java various java language commands jdbc JDBC connection jmx Java Management Extensions jndi Java Naming and Directory Interface jpa Java persistance API jvm JVM informations log logging commands man format and display the on-line manual pages shell shell related command sleep sleep for some time sort Sort a map system vm system properties commands thread JVM thread commands
To add a command to CRaSH. You have to add a groovy file in the cmd directory :
cd $CRASH_HOME/cmd vi test.groovy
Put the following in test.groovy :
for (int i = 0;i < 10;i++) { System.out.println("CRaSH is cool !"); }
In this example, we create a command by using Java syntax. It's because Groovy understand Java Syntax. So you could begin to develop your command in Java and when you want try cool Groovy stuff.
Type help again at prompt and you will see test
command.
% help Try one of these commands with the -h or --help switch: NAME DESCRIPTION clock dashboard date show the current time env display the term env filter hello help provides basic help java various java language commands jdbc JDBC connection jmx Java Management Extensions jndi Java Naming and Directory Interface jpa Java persistance API jvm JVM informations log logging commands man format and display the on-line manual pages shell shell related command sleep sleep for some time sort Sort a map system vm system properties commands test thread JVM thread commands
Table of Contents
Here is an example for printing an array :
import org.crsh.text.ui.UIBuilder UIBuilder ui = new UIBuilder(); ui.table(separator: dashed) { header(decoration: bold, foreground: black, background: white) { label("ATTRIBUTE NAME"); label("ACCESS"); label("TYPE"); label("DESCRIPTION"); label("ATTRIBUTE VALUE") } for(Attr tmpAttr : lst) { if (null != tmpAttr) { row() { label(tmpAttr.name, foreground: red); label(tmpAttr.access); label(tmpAttr.type); label(tmpAttr.desc); label(tmpAttr.attrs.toString()); } } } } out << ui;
To define an array, you will use elements like header, label ... If you want to see an example, edit dashboard.groovy in $CRASH_HOME/cmd/base/
Define table.
Attribute can be add to table element.
Table of Contents
This chapter provides various recipes using the attach mechanism of CRaSH.
In this recipe you will learn how to attach CRaSH to several JVM running on the local host. Each JVM will be accessible using the SSH connector. To achieve this goal we need to
attach CRaSH to one or several virtual machines
use the non-interactive mode
set the SSH port to 0 to avoid port collisions
crash.sh --non-interactive --property crash.ssh.port=0 PID1 PID2 PID3 ...
The execution of CRaSH will last a few seconds, the process will end when all JVM will have their own agent.