The samples subdirectory contains samples that illustrate some of the functionality that is provided in this release.
The NotificationSample program obtains an RMI connection to the JMX MBeanServer, and listens for JMX notifications generated by the ServicesManager MBean, which are sent whenever a service MBean changes state, or an operation is performed on it. For example, if EAServer is shut down (or crashes), this generates events that are picked up by NotificationSample.
To run the NotificationSample program:
Change to the ROOT/bin directory, and run:
runSample.sh samples/NotificationSample <host> <rmiport> <user> <pwd>
Where:
host is the host where the JMX agent is running.
rmiport is the port used by the RMI registry; the default is 1099.
user is the RMI user to connect; the default is “sybrmiclient”.
pwd is the password for the user; the default is “_5y6rm1cl1en4”.
The EASLogMonitorSample sample obtains an RMI connection to the JMX MBeanServer, and monitors the contents of the EAServer error log, checking for a string that, if seen, triggers a service restart, using the service interface exposed over JMX. To run the program:
Change to the ROOT/bin directory, and run:
runSample.sh samples/EASLogMonitorSample [-v] [-rebootString <string>] \ <host> <rmiport> <user> <pwd>
Where:
-v
indicates
that the contents of the log file are to be printed.
-rebootString <string>
sets
the reboot string, which can trigger a service restart; the default
is “NO_PERMISSION”.
host is the host where the JMX agent is running.
rmiport is the port used by the RMI registry; the default is 1099.
user is the RMI user to connect; the default is “sybrmiclient”.
pwd is the password for the user; the default is “_5y6rm1cl1en4”.
SimpleMBean extends com.sybase.management.jmx.services.ServiceSupport, a Sybase-provided abstract class, which you can use to build services. To use SimpleMBean, you must first register it with the JMX MBeanServer. You can either:
Use an XML file to load it when the JMX MBeanServer starts, or
Dynamically install it later, using the JMX MLET service. To implement this approach, read the appropriate JMX documentation.
To implement the first approach:
Create a JAR file called simple.jar that contains the Simple.class and SimpleMBean.class files, which are created when you compile the sources. Put simple.jar in the lib subdirectory.
Create an XML file called test.xml, similar to the following:
<?xml version="1.0" encoding="UTF-8"?> <mbeans> <mbean name="test:Name=Test" code="samples.Simple" archive="file:XXX-ROOT-XXX/lib/simple.jar"> </mbean> <service name="Test" type="test" mbean="test:Name=Test" startmode="manual"> </service> </mbeans>
Replace XXX-ROOT-XXX with the location of the Systems Management installation.
Edit the ROOT/agent.props file, and set the value of the products property to:
com.sybase.management.jmx.boot.products= (name=EAS,url=file:XXX-ROOT-XXX/eas.xml), (name=NetSNMP,url=file:XXX-ROOT-XXX/netsnmp.xml), (name=Test,url=file:XXX-ROOT-XXX/test.xml)
Replace XXX-ROOT-XXX with the location of the system management installation. The products property now refers to the test.xml file that you just created.
Stop and restart the JMX MBeanServer.
The new Test service should be visible through the Systems Management Console, and you should be able to use the console to start and stop the service, and verify that its state changes appropriately.
Copyright © 2005. Sybase Inc. All rights reserved. |
![]() |