Java Dynamic Management Kit 5.1 Tutorial

18.2 SNMP Table Instrumentation

The example shown in 18.1 Simple SNMP Tables showed simply how to use Java DMK to add and remove rows from an SNMP table. The example presented in this section goes further, and demonstrates how to add instrumentation to an SNMP table.

This example is based on the classes in the examplesDir/current/Snmp/MBeanTable directory. It defines a MIB called JMX-MBEAN-SERVER-MIB that exposes the content of an MBean server through SNMP. To achieve this, JMX-MBEAN-SERVER-MIB defines two SNMP tables:

18.2.1 Classes Generated by mibgen

Before you can proceed with this example, you need to generate the JMX-MBEAN-SERVER-MIB and it's associated classes, by using the mibgen compiler supplied with Java DMK. For details of the mibgen compiler, see the Java Dynamic Management Kit 5.1 Tools Reference Guide.

To Generate the JMX-MBEAN-SERVER-MIB

The example MIB is contained in the configuration file JMX-MBEAN-SERVER-MIB.mib, which is found in examplesDir/current/Snmp/MBeanTable. You should run the example from within this directory.

  1. Ensure that your PATH environment variable knows where to find mibgen.

    In a default installation, mibgen is found in installDir/bin.

  2. Create a new directory, generated, inside examplesDir/current/Snmp/MBeanTable.


    $ mkdir generated
    

    This directory is where mibgen generates the classes associated with JMX-MBEAN-SERVER-MIB.mib.

  3. Run the mibgen compiler.


    $ mibgen -X:use-display-hint -d generated JMX-MBEAN-SERVER-MIB.mib
    

    The advanced mibgen option use-display-hint instructs mibgen to generate an attribute of type String for any object using a textual convention whose DISPLAY-HINT is 255a. This option is used because JMX-MBEAN-SERVER-MIB defines textual conventions (for example, JmxMBeanObjectNameTC) which must be translated into java.lang.String attributes, rather than the default Byte[] attributes.

    The -d generated option sends the output of mibgen to the newly created generated directory

Within the generated directory, you see that mibgen has generated the following Java classes.

18.2.2 Customized Classes

As was the case for the simple SNMP table example, to be able to tie the code generated by mibgen to its proper instrumentation, you must extend the classes generated by mibgen in a series of custom classes. The customized classes are those provided in the examplesDir/current/Snmp/MBeanTable directory.

The customized extensions to the generated classes add the following functionality:

Aspects of the JmxMBeanServerImpl and JmxMBeanEntryImpl classes are examined in more detail in the following sections.

18.2.2.1 JmxMBeanServerImpl

As stated previously, JmxMBeanServerImpl extends the JmxMBeanServer empty skeleton class. JmxMBeanServerImpl also instantiates a subclass of TableJmxMBeanTable, to mirror the MBeans registered in an MBean server.


Example 18–4 Subclassing TableJmxMBeanTable

[...]
    private final void inittables() {

       JmxMBeanTable = new TableJmxMBeanTable(myMib,null) {
             public Object createJmxMBeanEntryMBean(SnmpMibSubRequest req,
                                                    SnmpOid rowOid, 
                                                    int depth, 
                                                    ObjectName entryObjName,
                                                    SnmpMibTable meta, 
                                                    Integer  aJmxMBeanIndex)
                 throws SnmpStatusException  {

                 return JmxMBeanServerImpl.this.
                    createJmxMBeanEntryMBean(req,rowOid,depth,entryObjName,
                                                 meta,aJmxMBeanIndex);
                }

                public void removeEntryCb(int pos, SnmpOid row, 
                                          ObjectName name,
                                          Object entry, SnmpMibTable meta)
                    throws SnmpStatusException {
                    super.removeEntryCb(pos,row,name,entry,meta);
                    final JmxMBeanEntryMBean e = 
                        (JmxMBeanEntryMBean) entry;
                    final EnumJmxMBeanRowStatus destroy =
                         new EnumJmxMBeanRowStatus(EnumRowStatus.destroy);
                    e.setJmxMBeanRowStatus(destroy);
                }
            };
	
        JmxMBeanTable.setCreationEnabled(true);
    }

[...]

In Example 18–4, JmxMBeanServerImpl defines a method, inittables, to instantiate and initialize its table objects. The inittables method creates a new instance of TableJmxMBeanTable, and overrides it so that its createJmxMBeanEntryMBean method returns a JmxMBeanEntryImpl object instead of the default JmxMBeanEntry object. This is done by defining a new createJmxMBeanEntryMBean method in the customized JmxMBeanEntryImpl class (see Example 18–5), and calling it on the parent JmxMBeanServerImpl object from the overridden TableJmxMBeanTable object, as shown in Example 18–4.

The removeEntryCb method is overridden, so that table entries representing MBeans also delete their associated entries in the jmxMBeanAtrrTable by calling setJmxMBeanRowStatus(destroy) when they are removed from the jmxMBeanTable.


Example 18–5 createJmxMBeanEntryMBean Method

[...]
    private Object createJmxMBeanEntryMBean(SnmpMibSubRequest req,
					                                SnmpOid rowOid, 
					                                int depth, 
					                                ObjectName entryObjName,
					                                SnmpMibTable meta, 
					                                Integer  aJmxMBeanIndex)
	         throws SnmpStatusException  {

		      SnmpVarBind rowStatusVb = req.getRowStatusVarBind();

	         if (rowStatusVb == null) 
	             throw new SnmpStatusException(
		                    SnmpStatusException.snmpRspNoCreation);

		      if (! isAvailable(aJmxMBeanIndex.intValue())) {
	             if (Boolean.getBoolean("info"))
                 System.out.println("Index is not suitable: " 
                     + aJmxMBeanIndex);
	             throw new SnmpStatusException(
		                    SnmpStatusException.snmpRspInconsistentValue);
	         }

		      JmxMBeanEntryImpl entry = 
	             new JmxMBeanEntryImpl(myMib,this);
	         entry.JmxMBeanIndex = aJmxMBeanIndex;

		      entry.createFromRemote(req,rowStatusVb);
	         return entry;
    }

[...]

As shown in Example 18–4, the createJmxMBeanEntryMBean method is called when a remote SNMP Manager creates a new row in a jmxMBeanTable. Example 18–5 shows how the createJmxMBeanEntryMBean method is overridden by the JmxMBeanServerImpl class, to add new entries in the jmxMBeanAttrTable as the rows are created in the table.

Of the parameters the customized version of createJmxMBeanEntryMBean takes when it is started, the following are the most significant..

The createJmxMBeanEntryMBean method checks first of all whether the VarBind list found when req calls getRowStatusVarBind() is valid. It then checks whether the row's OID index is available. Once it has established that both the VarBind and the index are viable, it proceeds to create a JmxMBeanEntryImpl instance, entry. Calling createFromRemote() at this point ensures that createMBean() will be called when the new entry is eventually activated.

As mentioned previously, JmxMBeanServerImpl is also configured to listen for notifications of the type MBeanServerNotifications coming from the MBean server.


Example 18–6 Listening for Notifications

[...]
public synchronized void start() {

	  started = true;
	  try {
	    	 final ObjectName delegate = 
		       new ObjectName("JMImplementation:type=MBeanServerDelegate");
	       myMib.getMibServer().
		       addNotificationListener(delegate,mbsListener,null,null);

	       try {
				   Set mbeans = myMib.getMibServer().queryNames(null,null);
            for (final Iterator it = mbeans.iterator(); 
                it.hasNext();) {
		             final ObjectName name = (ObjectName) it.next();
		             if (mustShow(name)) showMBean("start",name);
		         }
	        } catch (Exception x) {
		         try {
		             myMib.getMibServer().
			              removeNotificationListener(delegate,mbsListener);
		         } catch (Exception e) { /* OK */ }
		         throw x;
	        }
	    } catch (Exception x) {
	        started = false;	    
	        System.err.println("Failed to start MBean Table: " + x);
	        if (Boolean.getBoolean("debug")) x.printStackTrace();
	    }
}

[...]

The start() method shown in Example 18–5 starts a notification listener in the MIB server that listens out for notifications from the MBeanServerDelegate. It also populates the jmxMBeanTable and jmxMBeanAttrTable with the initial content of the MBean server. These tables are then updated as and when notifications are received, as shown in Example 18–7.


Example 18–7 Handling Notifications

[...]

private void handleMBSNotification(Notification notif, Object handback) {
	
	  synchronized(this) { if (!started) return; }

  	  if (notif instanceof MBeanServerNotification) {
	        final MBeanServerNotification n = 
		          (MBeanServerNotification) notif;
	        final String nt = n.getType();
	        final ObjectName mbeanName = n.getMBeanName();
	    
	        if (MBeanServerNotification.REGISTRATION_NOTIFICATION.
		         equals(nt)) {

             synchronized (this) {
		         if (mustShow(mbeanName)) { 
			          showMBean(nt,mbeanName);
		         }
   		  } 
	     } else if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.
   		       equals(nt)) {

     		synchronized (this) {
		        if (mustHide(mbeanName)) {
			         hideMBean(nt,mbeanName);
		        }
  		  }
	     }
	  }
}

[...]

The handleMBSNotification method that JmxMBeanServerImpl defines begins by checking that the correct type of notification has been received. If the notification is of the type MBeanServerNotification.REGISTRATION_NOTIFICATION, then a method named showMBean() is called. Otherwise, if MBeanServerNotification.UNREGISTRATION_NOTIFICATION is received, then the MBean is hidden with a call to hideMBean. The showMBean() method is shown in Example 18–8.


Example 18–8 Exposing MBeans through the SNMP Tables

[...]

private void showMBean(String operation,ObjectName name,int index) {
	   try {
	       JmxMBeanEntry entry = new JmxMBeanEntryImpl(myMib,this);
	       entry.JmxMBeanIndex = new Integer(index);
	       entry.setJmxMBeanObjectName(name.toString());
	       JmxMBeanTable.addEntry(entry);
	       names.put(name, entry);
	       entry.setJmxMBeanRowStatus(
		           new EnumJmxMBeanRowStatus(EnumRowStatus.active));
	       if (Boolean.getBoolean("info")) 
		        System.out.println("ADDED: JmxMBeanTable["+index+"]="+name);
	   } catch (Exception x) {
	       System.err.println("Failed to add MBean entry: " + name);
	       if (Boolean.getBoolean("debug")) x.printStackTrace();
	   }
}

[...]

The showMBean method adds the MBeans that handleMBSNotification learns about to the SNMP table JmxMBeanTable as JmxMBeanEntryImpl row entries. The status of the row is set to active. The MBean discovered by the notification listener is thus entered in the SNMP table as a row entry.

18.2.2.2 JmxMBeanEntryImpl

As mentioned previously, the JmxMBeanEntryImpl objects keep the jmxMBeanAttrTable updated. Example 18–9 and Example 18–10 show how JmxMBeanEntryImpl changes the status of rows, activates rows, and destroys them.


Example 18–9 Changing the Row Status

[...]

public synchronized void setJmxMBeanRowStatus(EnumJmxMBeanRowStatus x) 
	   throws SnmpStatusException {
	   switch (x.intValue()) {
	   case EnumRowStatus.active:
	       if (! (JmxMBeanRowStatus.intValue() == EnumRowStatus.active))
		        activate();
	       break;
	   case EnumRowStatus.notReady:
	       break;
	   case EnumRowStatus.notInService:
	       super.setJmxMBeanRowStatus(x);
	       break;
	   case EnumRowStatus.destroy:
	       destroy();
	       break;
	   default:
	       throw new SnmpStatusException(SnmpStatusException.
					                          snmpRspInconsistentValue);
	   }
}

[...]

The setJmxMBeanRowStatus method shown above is called by the SNMP runtime when the row is created remotely. It is also called explicitly by JmxMBeanEntryImpl when the row is created after receiving an MBean server notification.


Example 18–10 Activating and Destroying Rows

private void activate() throws SnmpStatusException {
	   if ((remoteCreation) && (mbean == null || name == null))
	       throw new SnmpStatusException(SnmpStatusException.snmpRspGenErr);
	   try {

	        if (remoteCreation) {
		         myGroup.registerMBean(mbean,name,this);
		         initJmxMBean(name);
		         remoteCreation = false;
		         mbean = null;
	        } 

	        exposedAttrCount = myGroup.addAttributes(name,this);
	        if (Boolean.getBoolean("info")) 
		         System.out.println(name.toString()+ ": added " + 
				                      exposedAttrCount
				                      + " attribute(s).");
	        JmxMBeanRowStatus = 
		         new EnumJmxMBeanRowStatus(EnumRowStatus.active);
	   } catch (Exception x) {
	        SnmpStatusException sn = 
		         new SnmpStatusException(SnmpStatusException.snmpRspGenErr);
	        sn.initCause(x);
	        throw sn;
	   }
}

private void destroy() throws SnmpStatusException {
  	try {
	       JmxMBeanRowStatus = 
		        new EnumJmxMBeanRowStatus(EnumRowStatus.notInService);
	       if (name != null && remoteDeletion)
		        myGroup.unregisterMBean(name,this);
	       remoteCreation = false;
	       mbean = null;	
	       if (name != null) 
		        myGroup.removeAttributes(name,this);
	       attrList = null;
	   } catch (Exception x) {
	       SnmpStatusException sn = 
		        new SnmpStatusException(SnmpStatusException.snmpRspGenErr);
	       sn.initCause(x);
	       throw sn;
	   }
}

Example 18–10 shows the activate and destroy methods defined by JmxMBeanEntryImpl. The activate method verifies first of all whether the row was created remotely or locally, and acts differently depending on the answer. If the row was created remotely by calling the createFromRemote method, the row entry registers the requested MBean in the MBean. If the row is created locally, this means that the request to create the row was made by an existing registered MBean, so there is no need to register it again in the MBean server.

The destroy method is created when the row is removed, either locally by handleMBeanServerNotification or remotely. The destroy method is called by removeEntryCb, which itself is called when the row is removed from the table, whether remotely or locally.

18.2.3 Point of Entry into the SNMP Table Instrumentation Example

In this example, the table instrumentation operations shown in the preceding sections are all demonstrated by a single class, the Agent. The fact that this Agent class creates MBeans, and registers them in an MBean server so that they can be mirrored by the SNMP MIB, is irrelevant to this example. The real purpose of the Agent is to demonstrate how to add instrumentation to the SNMP tables using Java DMK technology, not to demonstrate what the example actually does.


Example 18–11 Making an MBean Server Accessible by an SNMP Manager

public class Agent {
    public interface SimpleMBean {
	       public String getName();
	       public int    getCount();
	       public void   reset();
    }

    public static class Simple implements SimpleMBean {
	       public Simple() {
	           this(null);
	       }
    // Define MBean operations    
    [...]
    }

    public static MBeanServer getPlatformMBeanServer() {
	        final MBeanServer test = MBeanServerFactory.createMBeanServer();
	        final MBeanServer first = (MBeanServer)
	           MBeanServerFactory.findMBeanServer(null).get(0);
	        if (test != first) MBeanServerFactory.releaseMBeanServer(test);
	        return first;
    }

    public int populate(MBeanServer server, int mbeanCount) {
	      int count = 0;
	      for (int i=0; i<mbeanCount; i++) {
	          try {
		            final SimpleMBean simple = new Simple();
		            final ObjectName name = 
		               new ObjectName("Example:type=Simple,name="+
				                         simple.getName());
		            server.registerMBean(simple,name);
		            count ++;
		            System.out.println("Registered MBean: " + name);
	          } catch (Exception x) {
		            System.err.println("Failed to register MBean: " + x);
		            debug(x);
	          }
	      }
	      return count;
    }

    public int depopulate(MBeanServer server, int mbeanCount) {
	      int count = 0;
	      while (true) {
	          try { 
		           final ObjectName pattern = 
		              new ObjectName("Example:type=Simple,*");
		           Set mbeans = server.queryNames(pattern,null);
		           if (mbeans.isEmpty()) break;
		           for (Iterator it=mbeans.iterator(); it.hasNext() ; ) {
		                if (count == mbeanCount) return count;
		                final ObjectName next = (ObjectName) it.next();
		                try {
			                  server.unregisterMBean(next);
			                  count++;
                        System.out.println("Deregistered MBean: " 
                                            + next);
		                } catch (InstanceNotFoundException x) {
			               continue;
		                }
		           }
		           if (count >= mbeanCount) break;
	          } catch (Exception x) {
		           System.err.println("Unexpected exception: " + x);
		           debug(x);
		           break;
	          }
	      }
	      return count;
   }
[...]

The Agent class shown in Example 18–11 defines a basic MBean called SimpleMBean, that performs very basic MBean operations. The getPlatformMBeanServer method is used to obtain the first MBean server that has been created in this session by the MBeanServerFactory.


Example 18–12 Creating an SNMPv3 Adaptor Server and JMX-MBEAN-SERVER-MIB

[...]

    public void startmib(MBeanServer server,int port) throws IOException {
	      final SnmpV3AdaptorServer adaptor = 
	          new SnmpV3AdaptorServer((InetAddressAcl)null,port);
	      adaptor.enableSnmpV1V2SetRequest();
	      adaptor.start();
	      do {
	          adaptor.waitState(CommunicatorServer.ONLINE,1000);
	      } while (adaptor.getState() == CommunicatorServer.STARTING);

	      final int state = adaptor.getState();
	      if (state != CommunicatorServer.ONLINE) {
	          try { adaptor.stop(); } catch (Exception x) { /* OK */ }
	          throw new IOException("Can't start adaptor: " + 
				                        adaptor.getStateString());
	      }

       JMX_MBEAN_SERVER_MIB_Impl mib = 
              new JMX_MBEAN_SERVER_MIB_Impl(server);

	      try {
	           mib.init();
	           mib.setSnmpAdaptor(adaptor);
	           server.registerMBean(adaptor,null);
	           mib.start();
	      } catch (Exception x) {
	           System.err.println("Failed to register SnmpAdaptor: " + x);
	           try { adaptor.stop(); } catch (Exception e) { /* OK */ }
	           final IOException io = 
		            new IOException("Failed to register SnmpAdaptor");
	           io.initCause(x);
	           throw io;
	      }
       System.out.println("SnmpAdaptor ready at port: " 
                          + adaptor.getPort());
    }
[...]

The Agent class then defines a method, startmib, to instantiate an SNMPv3 adaptor server named adaptor, and creates an instance of the JMX_MBEAN_SERVER_MIB_Impl MIB, named mib. The mib is constructed around an MBean server named server, the content of which is mirrored in this MIB. The MIB is then initialized by a call to the init() method defined by JMX_MBEAN_SERVER_MIB_Impl. The reference to the SNMP protocol adaptor through which the MIB is accessible, in this case adaptor, is set by calling the SnmpMibAgent method setSnmpAdaptor, and this adaptor is then registered as an MBean in the MBean server server. The start() method defined by JMX_MBEAN_SERVER_MIB_Impl is then called. The start() method starts the mbeanServerGroup, which itself is an instance of JmxMBeanServerImpl, and which activates the mirroring of the MBean server in the MIB. See the JMX_MBEAN_SERVER_MIB_Impl.java file in the generated directory for the full implementation of the start() method.


Example 18–13 Starting the Agent

[...]
      public void start(int port, String[] args) throws IOException {
	       final MBeanServer server =  getPlatformMBeanServer();
	       final JMXServiceURL[] urls = new JMXServiceURL[args.length];
	       for (int i=0;i<args.length;i++) {
	            try {
		              urls[i] = new JMXServiceURL(args[i]);
	            } catch (MalformedURLException x) {
		       			throw x;
	            }
	       }
	       for (int i=0;i<urls.length;i++) {
	           try {
		            final JMXConnectorServer s = 
		                    JMXConnectorServerFactory. 
                       newJMXConnectorServer(urls[i],
								  null,null);
		            final ObjectName name = 
                  new ObjectName("Connector:type=
                                 "+s.getClass().getName()+
				                        ",instance="+i);
		            server.registerMBean(s,name);
		            s.start();
		    	   } catch (Exception x) {
		            final String msg = "Failed to start connector: 
                                  " + args[i];
		            System.err.println(msg);
		            final IOException io = new IOException(msg);
		            io.initCause(x);
		            throw io;
	    	      }
	       }

	       populate(server,5);

	       startmib(server,port);
	
	       final Timer timer = new Timer();
	       final long  period= 2000;
	       final long  now=0;
	       final int   max=4;
	       for (int i=0;i<max;i++) {
	           final TimerTask taskAdd = new TimerTask() {
		                public void run() {
                       final MBeanServer server = 
                                getPlatformMBeanServer();
			                 populate(server,1);
		                }
		             };
	           final TimerTask taskRem = new TimerTask() {
		                public void run() {
                       final MBeanServer server = 
                                getPlatformMBeanServer();
			                 depopulate(server,1);
		                }
		             };
	           timer.schedule(taskAdd,now+period*i,2*period*max);
	           timer.schedule(taskRem,now+period*max+period*i,2*period*max);
	       }
    }

    public static void initOidTable() {	
	       final SnmpOidTable orig = SnmpOid.getSnmpOidTable();
	       SnmpOidDatabaseSupport mibs = new SnmpOidDatabaseSupport();
	       mibs.add(new JMX_MBEAN_SERVER_MIBOidTable());
	       if (orig != null) mibs.add(orig);
	       SnmpOid.setSnmpOidTable(mibs);
    }
[...]

Agent now defines a start() method of its own. The start method firstly obtains an MBean server instance, server, by calling the getPlatformMBeanServer method defined earlier in the class. It also retrieves any JMX service URLs that might be passed to Agent as arguments when it is launched. If any JMX service URLs are provided at start-time, the Agent.start() method uses them to create JMXConnectorServer instances that it registers in the MBean server server as MBeans.

The MBean server instance server is populated with dummy MBeans by calling the populate() method. These MBeans are mirrored in the MIB, when the mirroring is activated.

The SNMP adaptor and the MIB are started by calling startmib, that was defined in Example 18–12.

Once the startmib method has been called, timer tasks are defined that periodically add and remove MBeans from the MBean server. These periodic tasks serve merely to test and demonstrate that the jmxMBeanTable and jmxMBeanAttrTable are updated accordingly in the MIB.

JMX_MBEAN_SERVER_MIBOidTable metadata definitions for the MIBs are loaded into the global SNMP OID table, to enable the use of symbolic OID names.


Example 18–14 Agent main() Method

[...]
    public static void main(String[] args) {

	       Agent agent = new Agent();
	       try {
	            initOidTable();
             final String portStr = System.getProperty("snmp.port",
                                                       "16161");
	            final int port;
	            try {
		              port = Integer.parseInt(portStr);
	            } catch (Exception x) {
                 System.err.println("Invalid value specified for 
                                    snmp.port: "
				                          + portStr);
		             System.err.println("Error is: " + x);
		             throw x;
	            }
	            System.out.println("Using SNMP port " + port);

	            agent.start(port,args);

	            // Wait forever...
	            Thread.sleep(Long.MAX_VALUE);
	       } catch (Exception x) {
	            System.err.println("Failed to start agent: " + x);
	            debug(x);
	            System.exit(1);
	       }

    }

}

Finally, an instance of Agent, agent, is started on the appropriate SNMP port by calling the start method defined in Example 18–13.

18.2.4 Running the SNMP Table Instrumentation Example

After you have run mibgen to generate JMX_MBEAN_SERVER_MIB and its associated classes, as explained in 18.2.1 Classes Generated by mibgen, you can run the example.

To Run the SNMP Table Instrumentation Example

Run the example from the examplesDir/current/Snmp/MBeanTable directory.

  1. Compile the Java classes in the generated directory.


    $ cd generated
    $ javac -d .. *.java
    

    This creates the compiled *.class files into the examplesDir/current/Snmp/MBeanTable directory, rather than in generated, so that they are accessible to the other classes used in the example.

  2. Compile the Java classes in the examplesDir/current/Snmp/MBeanTable directory.


    $ cd ..
    $ javac -d . *.java
    
  3. Start the Agent.

    You have several options when starting the Agent class.

    • To start the Agent on the default SNMP port, 16161:


      $ java  Agent service:jmx:jmxmp://
      
    • To start the Agent on a port of your choice:


      $ java  -Dsnmp.port=port_number Agent service:jmx:jmxmp://
      
    • To start the Agent with a connector of your choosing, you can specify a different service URL and connector port. For example:


      $ java  Agent JMX_service_URL
      

    In any of the above cases, you see confirmation of the SNMP port used, confirmation of the creation of the connector and then the alternating registration and deregistration of sets of five MBeans.

  4. You can now perform management operations on the Agent.

    Use a JMX management console of your choice to examine the content of the MBean server through a JMXMP connector.

    Use the SNMP management application, easymanager, that is supplied with Java DMK to examine the JMX-MBEAN-SERVER-MIB through SNMP. You can find the easymanager application in the installDir/contributions/easymanager directory.

To Examine JMX-MBEAN-SERVER-MIB Using easymanager
  1. Add the JMX-MBEAN-SERVER-MIBOidTable.class to your classpath.

    Type the following command if you are using a UNIX platform:


    $ export CLASSPATH=$CLASSPATH:examplesDir/current/Snmp/MBeanTable/

    Type the following command if you are using a Windows platform:


    set classpath=%classpath%;examplesDir/current/Snmp/MBeanTable/
  2. Open installDir/contributions/easymanager/bin

  3. Start easymanager.

    If the SNMP agent has been started with the default example port, type the following command.


    $ easymanager.sh -port 16161 

    You can now use easymanager to perform the following operations.

    • Pop up a MIB discovery window.


      discovermib -p JDMK_STD_V2_profile
      
    • Create a new MBean.


      set:2 -w private :<<jmxMBeanObjectName.998,4,Test:name=test1>,
      <jmxMBeanClassName.998,4,Agent$Simple>,
      <jmxMBeanRowStatus.998,2,4>>
      
    • Click on resynch in the MIB discovery window to observer the changes in the MIB.

    • Destroy the MBean you created.


      set:2 -w private :<<jmxMBeanRowStatus.998,2,6>>