JMX monitoring on unix server


 
Thread Tools Search this Thread
Top Forums Programming JMX monitoring on unix server
# 8  
Old 10-11-2011
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)
# 9  
Old 10-12-2011
Hi,

i am having idea about java, but not perfect.I have created one small programm of "helloworld" on eclipse (SDE6.0_Enterprise)

Code:
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

Last edited by aish11; 10-12-2011 at 03:11 AM..
# 10  
Old 10-12-2011
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 - https://www.unix.com

Quote:
The JMX Technology Programming Model
Image

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
Code:
    Image  
    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
Code:
    Image  
    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:
  1. Gets the platform MBeanServer
  2. Registers an instance of the Hello MBean
Code Sample 3: SimpleAgent.java
Code:
    Image  
    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:
  1. Create a directory of your choice (such as jmx-example)
  2. Copy Code Samples 1, 2, and 3 into that directory
  3. Compile all the .java files using javac
  4. 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.
  5. 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.
6. 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
This User Gave Thanks to Spidi4u For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Infrastructure Monitoring

Tuxedo server monitoring

Hi I like to use tmadmin commands to monitor running application in tuxedo server 12c.But When i use tmadmin help command i get only meta commands.But i like to check printconn,printclient,printserver like that.But these commands are not avaialble in list.I here pasted the help command... (0 Replies)
Discussion started by: selva1587
0 Replies

2. UNIX for Dummies Questions & Answers

Server Monitoring Suggestions

Hi all - newb here. We're a Windows shop and I'm looking for something that I could stand up to monitor various aspects of our servers. I'm specifically looking for something that can: verify that servers are up verify services are up verify remote sites are up/accessible monitor CPU &... (2 Replies)
Discussion started by: Phylum
2 Replies

3. UNIX and Linux Applications

JMX Client -MalformedURLException

Hi I am writing a JMX client to fetch the MBeans and its attributes. i am able to display weblogic MBeans using the following code snippet. But my requirement is it should run on Unix box. I copied same client onto unix, then i am getting the following error. ... (1 Reply)
Discussion started by: tripleM
1 Replies

4. Programming

JMX Client MalformedURLException

Hi I am writing a JMX client to fetch the MBeans and its attributes. i am able to display weblogic MBeans using the following code snippet. But my requirement is it should run on Unix box. I copied same client onto unix, then i am getting the following error. ... (0 Replies)
Discussion started by: tripleM
0 Replies

5. Shell Programming and Scripting

JMX monitoring on UNIX

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 (3 Replies)
Discussion started by: aish11
3 Replies

6. Infrastructure Monitoring

Monitoring Solaris 10 Server

Hi, We user What's Up Gold tool for monitoring the WIndows servers. My idea is to add my Solaris 10 server to this monitoring tool. Is it feasible? If yes, can somebody help in configuring the server onto the tool? My current solaris 10 server is i86pc, and has SNMP daemons running. the... (0 Replies)
Discussion started by: EmbedUX
0 Replies

7. Shell Programming and Scripting

Help me monitoring the IO for remote server

Hi guys i have purchased sun server for my visualization project. Request you to help me finding the io for disk . I have put storage(disks) on different location (File Server) and on server (Application) i have configured 4 virtual machines. How would i monitor the io for file server from... (0 Replies)
Discussion started by: pinga123
0 Replies

8. Shell Programming and Scripting

Error in script to automate the daily monitoring process of UNIX server and it's proc

hi friends, I am trying to automate the daily monitoring process of UNIX server and it's processes. the script are below i executed the above script using ksh -x monitortest1.sh in root login . It shows error at some lines . 1. i logged in using root ,but it... (8 Replies)
Discussion started by: rdhaprakasam
8 Replies

9. Shell Programming and Scripting

Linux Server Monitoring Script !!!

I am the Linux Admin in my organisation and need to write a shell script which will monitor the machine statistics every day and will send a consolidated report to me on my email id / will display the output into a file. Does anyone have such kind of script fulfilling this kind of purpose? ... (4 Replies)
Discussion started by: csaha
4 Replies

10. UNIX for Advanced & Expert Users

monitoring server

Hello, I work with 4 flavour of UNIX ( AIX, IRIX, HPUX and SUN). I have a problem maintaing the system. can any one let me know of the software or script that will check the date,time services running or not, perticular machine is up or not and post a mail with all the details. It... (3 Replies)
Discussion started by: pradeepmacha
3 Replies
Login or Register to Ask a Question