aish11
October 6, 2011, 1:57am
1
Hi All,
I am new to JMX.Can anybody tell me how to use this it on unix server.
Using JMX i want to check the system monitoring(%cpu utilization , size utilization )how to start JMX on UNIX
Thanks
Because of JMX is part of Java and runs inside a Java Virtual Machine, there should be no problem to start JMX in the same way like you do on windows.
Maybe you could tell some more infos what you exactly want to do? Or, how you are trying to start and what exactly you are "starting"
aish11
October 10, 2011, 2:05am
3
Hi spidi4u,
AS i googled , found that we are using JMX for the monitoring purpsoe.
on unix server , using unix commands i am trying to monitor %cpu for each processid
Eg:process id 3456 -takes 78% of cpu
using unix "top" command i can find the %cpu utilization
but i want to know again detailed reasons, means where we need 78%
exactly
Eg :from 78 % , 20%...is fror some reasons 30 % is for ...
28% is ...
but want to know that wheter there is a programm for this , or how can we do the same on servers using JMX.
using JMX i want monitor size utilization , time utilization , %cpu ,%mem
please help me to start this, give me some simple examples.
ah ok i see, so your problem isn�t really JMX. Your real problem is a good UNIX command which gives you detailed information about CPU/Mem Usage.
Ok I think we can find som solution for that, but please excuse I�m also no Unix pro at all...
Could you tell me what kind of UNIX you are using? If we find a good UNIX command, there should be no problem to use this with JMX
---------- Post updated at 10:23 ---------- Previous update was at 08:56 ----------
to my mind, if you type "top" there should be a table summary of all pids and there should also be a column of %cpu and %mem... isnt it?
just looks like that:
source: cyberciti.biz
aish11
October 11, 2011, 5:31am
5
what u have said is right.
but from business perspective, we can find some cpu utilization only using with JMX not unix. I also dont know how to use that.
so need one simple example of JMX . so that i can improve in it.
ah ok... so plz tell me, how you are using JMX... do you use that jconsole or do you use it on command-line? I still remember JMX just starts with a MBean right? and then you use that MBean with any visulization... maybe also a http-connector or the jconsole...
Could you plz post that MBean which you are using? the code of it. I guess its something that simply executes a command in shell or cmd or whatever on the target host. Right?
---------- Post updated at 12:07 ---------- Previous update was at 12:04 ----------
sorry i guess i misunderstood your last question... do you have any JMX running? Or are you still trying to find out how JMX works? Do you need a tutorial?
aish11
October 11, 2011, 6:30am
7
I dont have any JMX running.I got some points from google about Mbean and all... but it just information for me, practically dont know. better to give me some easy tutorial. I want to know how JMX works
Thanks
---------- Post updated at 05:30 AM ---------- Previous update was at 05:24 AM ----------
I have just tried one simple command
jconsole 4882
-bash: jconsole: command not found
i also want to know the difference between jconsole and JMX
do you have some knowledge in Java? you will need it.
if you got some, you can read about JMX... --> Java Management Extensions.
That means JMX is just an extension of java which offers you the abbility to monitor&manage simple processes and more...
I used it some months ago to start processes on remote hosts.
JMX is the thing which does all the commands and jconsole is one example that visualizes the results of JMX.
---------- Post updated at 13:24 ---------- Previous update was at 13:23 ----------
Are you german? if so, you could use this tutorial, it�s quite good:
JMX (Java Management Extensions)
aish11
October 12, 2011, 2:02am
9
Hi,
i am having idea about java, but not perfect.I have created one small programm of "helloworld" on eclipse (SDE6.0_Enterprise)
class
HelloWorld {
public
staticvoid main(String[] args)
{
System.out.println("Hello World!");
}
}
can i monitor this using jmx or jconsole.
if yes ...then how?
and sorry , i am not german.
Thanks
[/LEFT]
Spidi4u
October 12, 2011, 3:02am
10
yes thats possible... but your code must be an mbean.
so something like a helloworld-mbean could look like this:
Here�s a part of an english tutorial. I�d like to cloak that, but it seems not possible @ Senior Advisor - http://www.unix.com
The JMX Technology Programming Model
Using JMX to instrument your applications, services, or devices for manageability is simple. This is because JMX technology shares Java's object model. If you are familiar with Java and its JavaBeans component model, you already know 95% of all you need to know.
As mentioned previously, an MBean is a Java object that follows some standard design patterns and naming conventions. It can represent a device, application, or any resource that needs to be managed. An MBean exposes a management interface or a set of readable and/or writable attributes and a set of invokable operations, along with a self-description. Note that the management interface does not change through the life of an MBean instance.
Sample Application
This simple application manages a resource. You will create a simple standard MBean that exposes a String object and an operation. For more JMX technology examples, please see the JMX Tutorial .
The first step is to develop the MBean interface. In this application, the interface is called HelloMBean, which declares three methods: one getter, one setter, and one for saying hello as shown in Code Sample 1.
Code Sample 1: HelloMBean.java
http://java.sun.com/im/a.gif
public interface HelloMBean {
public void setMessage(String message);
public String getMessage(); public void sayHello();
}
The next step is to implement the MBean interface. A sample implementation is shown in the following Code Sample.
Code Sample 2: Hello.java
http://java.sun.com/im/a.gif
public class Hello implements HelloMBean {
private String message = null;
public Hello() {
message = "Hello there";
}
public Hello(String message) {
this.message = message;
}
public void setMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
public void sayHello() {
System.out.println(message);
}
}
Congratulations! You have created your first MBean. The next step is to test the MBean, by developing a JMX agent in which you register the MBean. A JMX agent is a component in the agent level and acts as a container for the MBean. A sample agent, SimpleAgent, is provided in Code Sample 3. This agent performs the following tasks:
Gets the platform MBeanServer
Registers an instance of the Hello MBean
Code Sample 3: SimpleAgent.java
http://java.sun.com/im/a.gif
import javax.management.*;
import java.lang.management.*;
public class SimpleAgent {
private MBeanServer mbs = null;
public SimpleAgent() { // Get the platform MBeanServer
mbs = ManagementFactory.getPlatformMBeanServer(); // Unique identification of MBeans
Hello helloBean = new Hello();
ObjectName helloName = null;
try { // Uniquely identify the MBeans and register them with the platform MBeanServer
helloName = new ObjectName("SimpleAgent:name=hellothere");
mbs.registerMBean(helloBean, helloName);
} catch(Exception e) {
e.printStackTrace();
}
} // Utility method: so that the application continues to run
private static void waitForEnterPressed() {
try {
System.out.println("Press to continue...");
System.in.read();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String argv[]) {
SimpleAgent agent = new SimpleAgent();
System.out.println("SimpleAgent is running...");
SimpleAgent.waitForEnterPressed();
}
}
The java.lang.management.ManagementFactory class is a factory class for getting managed beans for the Java platform. In this example, the getPlatformMBeanServer() method is used to get the platform MBeanServer, which is the interface for MBean manipulation on the agent side. It contains the methods necessary for the creation, registration, and deletion of MBeans. The MBeanServer is the core component of the JMX agent infrastructure.
To experiment with this application, do the following:
Create a directory of your choice (such as jmx-example)
Copy Code Samples 1, 2, and 3 into that directory
Compile all the .java files using javac
Run SimpleAgent. In order to use the jconsole tool to manage it, you should run the SimpleAgent as follows: prompt> java -Dcom.sun.management.jmxremote SimpleAgent
Note: The -Dcom.sun.management.jmxremote system property creates an RMI connector to the platform MBeanServer. For information on the RMI connector, see the coming section, Using the RMI Connector .
Connect to the JMX agent using the jconsole tool. Run the jconsole tool from the command line. Once you start jconsole, it will display the list of local processes to be monitored as shown in Figure 2.
Now, you can connect to the service. Once connected, select the MBeans tab so that
you can list the MBeans and manage them as shown in Figure 3.
source: Getting Started with Java Management Extensions (JMX): Developing Management and Monitoring Solutions
Hope that small tutorial may help you
1 Like