Command Line Client for JMX
JMX is a mechanism where we can used to monitor and control our java applications remotely. We can expose variables and methods to outside using JMX. To access these exposed variables or methods, we have to use JMX Client. JConsole is the JMX client application shipped with Java. It is a swing based application.
There is nothing wrong with JConsole if I'm using it in from my desktop. But issue is when I want to run it on a remote machine through ssh, I can't use X because of bandwidth limitations. So ideal tool for such situation is to use CLI tool.
After searching few minutes in goolgle I found this cute little tool called "Jmxterm (JMX Terminal)". It is again a Java application and give you all the features you need when you use JMX. It is really user friendly as well. It has auto command completion and also can remember previous command you used. It is just like bash.
[sandarenu@localhost jmx-commandline]$ java -jar jmxterm-1.0-alpha-4-uber.jar
Welcome to JMX terminal. Type "help" for available commands.
$>help
#following commands are available to use:
about - Display about page
bean - Display or set current selected MBean.
beans - List available beans under a domain or all domains
bye - Terminate console and exit
close - Close current JMX connection
domain - Display or set current selected domain.
domains - List all available domain names
exit - Terminate console and exit
get - Get value of MBean attribute(s)
help - Display available commands or usage of a command
info - Display detail information about an MBean
jvms - List all running local JVM processes
open - Open JMX session or display current connection
option - Set options for command session
quit - Terminate console and exit
run - Invoke an MBean operation
set - Set value of an MBean attribute
$>jvms
2686 ( ) -
12216 ( ) - jmxterm-1.0-alpha-4-uber.jar
12200 ( ) - hsendidmobile.ss7.sampleapp.performance.ApplicationStarter
$>open 12200
$>bean Performance:name=smsSender,type=map
#bean is set to Performance:name=smsSender,type=map
$>info
#mbean = Performance:name=smsSender,type=map
#class name = hsendidmobile.ss7.sampleapp.performance.sms.ForwardMoSenderMBean
#there is no attribute
# operations
%0 - int currrentTps()
%1 - void sendMessage()
%2 - void sendTps(int p1)
%3 - void sendTpsParallay(int p1,int p2)
%4 - void stopSending()
#there's no notifications
$>run sendMessage
#calling operation sendMessage of mbean Performance:name=smsSender,type=map
#operation returns:
null
Thanks man this really helped.
Post a Comment