SNMP functionality  Creating services

Chapter 13: Using Systems Management

Running the JMX agent

Before you run the JMX agent, verify that the JAVA_HOME environment variable points to a JRE 1.4 installation, and that SybSNMP is running so that the agent can connect to it—see “SNMP master agent”.

StepsStarting the JMX agent on UNIX

  1. Change to the ROOT/bin directory, and enter: [-F agent props] [-h] [-o log] [-v n]

    Table 13-3 defines the command line options.

    Table 13-3: SybAgent start-up options



    -F path

    Specifies the location of the agent.props file, which contains the necesssary configuration to start the agent server. You can make a copy of agent.props, then change any of the settings; for example, to define a different class path, or to include other services.


    Prints the list of start-up options.

    -o log

    Specifies the name of the log file; the default is agent.log.

    -v n

    Writes the debugging messages identified by n to the log file identified by -o. Table 13-4 defines the possible values for n.

    Table 13-4: SybAgent debugging options

    Debugging level

    Generates these messages











StepsStarting the JMX agent on Windows

  1. Change to the ROOT\bin directory, and enter:

    SybAgent.bat [-F agent props] [-h] [-o log] [-v n]

    where Table 13-3 defines the command line options.

StepsStopping the JMX agent on UNIX

  1. Change to the ROOT/bin directory, and enter:

StepsStopping the JMX agent on Windows

  1. Change to the ROOT\bin directory, and enter:


Connecting to the JMX agent

You can access the JMX agent remotely using an RMI connector by writing a client that opens an RMI connection using the classes provided with this release. The client should obtain an object that implements the interface over RMI. This interface provides a number of methods that allow the client to interact with the JMX agent, such as invoking methods on MBeans and obtaining MBean information. However, some methods that are exposed in the interface do not work remotely; for example, the registerMBean API call.

This is an example of a client that accesses the JMX agent:

package client;
import java.util.Properties;

// Simple Client to the JMX agent - just prints number of MBeans

public class Client
  public static void main(String[] args)
     MBeanServer server = null;

     if (args.length < 4)
        System.err.println("usage: Client <host> <port> <user> <password>");

     String host = args[0];
     String port = args[1];
     String user = args[2];
     String password = args[3];

     Properties props = new Properties();

     props.put(MBeanServerLocator.PROVIDER_HOSTNAME, host);
     props.put(MBeanServerLocator.PROVIDER_PORT, port);
     props.put(MBeanServerLocator.SECURITY_PRINCIPAL, user);
     props.put(MBeanServerLocator.SECURITY_CREDENTIALS, password);

     // optional: SSL
     // To verify the server's identity, pass in our truststore 
     // so that we can check that the server's certificate is valid
     //if (args.length < 5)
     //    System.err.println("usage: Client <host> <port> <user> <password> <truststore>");
     //    System.exit(1);
     //String trustStoreFileName = args[4];
     //props.put(MX4JRMIConnectorServerLocator.TRUST_STORE_FILE, trustStoreFileName);
     // To verify the client's identity, pass in a pointer to our keystore
     //if (args.length < 6)
     //    System.err.println("usage: Client <host> <port> <user> <password> <truststore> <keystore>");
     //    System.exit(1);
     //String keyStoreFileName = args[6];
     //props.put(MX4JRMIConnectorServerLocator.KEY_STORE_FILE, keyStoreFileName);

     // get a connection with the remote JMX agent
     server = MX4JRMIConnectorServerLocator.getMBeanServer(props);
     catch (Exception e)
        System.err.println("Failed to connect to the JMX agent: " + e);
     // use the connection ...
     System.out.println("There are " + server.getMBeanCount() + " MBeans");


Copyright © 2005. Sybase Inc. All rights reserved. Creating services