|
4.1 Overview
4.3 Loading MIB in JMX Compiler
4.4 Generating Code for the MIB
4.5 Compiling the Generated Code
4.6 Starting and Stopping the Agent
This chapter guides you through a step-by-step procedure to create, compile, and run a simple Multi-Protocol agent. This agent will be created based on the default options provided in the JMX Compiler with support for SNMP, HTTP, TL1, RMI, CORBA, and HTML adaptors.With this agent, you will be able to retrieve the default values provided in the agent.
Please follow the steps given below to create a new project for the simple Multi-Protocol agent :
Start JMX Compiler from the Launcher or by executing the JMXCompiler.bat/JMXCombiler.sh from the <Agent Toolkit Home>/bin directory.
Project Dialog appears with three tabs namely New Project, Open Workspace and Recent Workspace. Project dialog opens with New Project Tab if opened for the first time. If a project already exists, Project dialog appears with Recent Workspaces tab.
Create a new project from the Option File -> New Project. The Project Settings UI opens with the New Project tab enabled.
Select or create a workspace file for your project. There are two options available here :
Add to Current Workspace : This option will be enabled if a workspace is already open in your system. Choosing this option will add your project to the workspace file, which is already open.
Create or add to existing workspace : You can choose this option to create a new workspace file for your project or add your project to an existing workspace file available in your system.
Type the name of the new project file. The default project name is jmxproject01.prj for the first project opened. The JMX Compiler assigns the .prj extension to this file to identify it as the project file. For example, enter simpleJMXAgent and the project is named simpleJMXAgent.prj.
Specify the location where you want to save (and store) the project and its files. You can save them on a local drive in any folder or subfolder (for example, c:/simpleJMXAgent). The new project is created in. /jmxprojects directory by default.
After entering the above information, click the OK button to create a new project in the specify directory. Clicking the cancel button cancels the new project.
The JMX Compiler settings is saved in the <ProjectName>.prj file, which is created for each project in the specified directory. Hence, you can open a particular project anytime with its current settings by selecting the workspace of that project.
4.3 Loading MIB in JMX Compiler
On creating a new project, the workspace dialog opens with the MibView Tab enabled. Please follow the steps given below to load a MIB in the JMX Compiler, for the simpleJMXProject created above:
Load the MIB for which code is to be generated for the project by selecting the MIB -> Load MIB option in the Menu bar or load mib icon in the Toolbar.
The MIBs in <Agent Toolkit Home>/mibs directory get listed. You can make use of these MIBs or a MIB that you have already defined. Browse and select the required MIB File. In this chapter, you will load the AGENT-SAMPLE-MIB for which code is to be generated.
You can also load multiple MIBs in the JMX Compiler by following the above steps.
You will find the MIB displayed as a tree in the top panel of the workspace dialog. The Settings Menu provides various options based on which code is generated. In this example, you implement the simpleJMXAgent with default options.
|
|
Note: You can use MIB Editor to create your own Mib File. MIBs created by other sources can also be used to generate code in the JMX Compiler. To know about the steps involved in defining MIBs using MIB Editor, please refer to the topic Defining a MIB |
4.4 Generating Code for the MIB
Please follow the steps given below to generate code for the AGENT-SAMPLE-MIB. The generated code will be based on the Model MBeans specified by JMX specification.
>Select the Build->Generate Source option or the generate icon on the toolbar, which generates source files corresponding to the AGENT-SAMPLE-MIB.
The Debug window opens and displays information about the generated source files under the projects directory. After the code generation, it says Code generation succeeded for project : simpleJMXAgent.prj.
The files are generated in <Agent Toolkit Home>/jmxprojects/simpleJMXAgent/agent/src directory.
You can also view the files generated for the project in the Fileview Tab of the WorkSpace dialog.
4.5 Compiling the Generated Code
After generating the code for the loaded MIB file(s), the next step in agent development is compiling the source code. You can instrument the source code according to your requirements before compilation. In this example, you compile the source code without any instrumentation. Compiling the generated code can be done either from the JMX Compiler UI or from the Command prompt.
From JMX Compiler UI
Follow the steps given below to compile the generated code from the JMX Compiler UI.
Select the Build -> Compile Source option or the compile icon on the toolbar to compile the source file.
The compilation Output panel opens and displays information about Compilation of files under the projects directory.
On successful compilation, the message Compilation Success is displayed. Now, you have successfully compiled your agent.
From Command Prompt
You can also compile the source from the command prompt. Please follow the steps given below to compile the source files from the command prompt.
Open a command prompt/terminal.
Go to the <Agent Toolkit Home>/jmxprojetcs/simpleJMXAgent directory.
Update the path variable.
Execute the following command javac -d agent\bin agent\src\*.java
|
|
Note: Before executing javac, update the PATH variable, if you want to run the SDK executable javac.exe conveniently from any directory. To know how to set the path variable, please refer to Troubleshooting- General Section |
The above command compiles all the files under agent/src directory. If the compilation is successful, the compiled class files can be found under jmxprojects/simpleJMXAgent/agent/bin directory.
Now, all the files have been compiled and the simpleJMXAgent can be started.
4.6 Starting and Stopping the Agent
After successfully compiling the Multi-Protocol agent, you can start the Agent either from the JMX Compiler UI or from the Command prompt as explained in the proceeding sections.
Starting and Stopping the Agent from JMX Compiler UI
To start the agent,
select Build -> Start Agent
option in the Menu bar. This starts the agent at the default port numbers
specified for the adaptors in the UI options. This action is reflected
with the
following message:
Starting agent of project jmxproject05.prj
RMI Connector Server started t port; [1099]
SnmpAgent is started ... at port 8001
HTTP Connector started at port 8050
CORBA Connector Server started at port:[1050]
TL1 Server started on 9099
To stop the agent,
select Build -> Stop Agent
option in the Menu bar. This action is reflected with the following message:
Stopping agent ..
Agent stopped..
Starting and Stopping From the Commmand Line
Follow the steps given below to start Agent from the command prompt.
Open a command prompt/terminal.
Go to the <Agent Toolkit Home>/jmxprojects/simpleJMXAgent/agent/bin directory where the compiled files are available.
Execute the run.bat/.run.sh
command. This instantiates the different adaptors and starts the Multi-Protocol
agent. The adaptors get started at the default port numbers. The default
port numbers, where they get started are:
HTML Adaptor - 8030
SNMP Adaptor - 8001
RMI Adaptor - 1099
CORBA Adaptor - 1050
HTTP Adaptor - 8050
TL1 Adaptor - 9099
The port numbers can be specified for the different adaptors from
the command line also. The various command line options are :
String usage = "[-a enables_Http_authentication] [-sp
snmp_port] [-hp html_port] [-rp rmi_port] [-cp corba_port] [-hcp http_port]
[-tp tl1_port] [-d debuglevel (1-6)]";
On executing the
run.bat/sh command, the following message is displayed :
RMI Connecter Server started at port:[1099]
SnmpAgent is started... at port 8001
HTML Adaptor started at port 8030
HTTP Connector started at port 8050
CORBA Connecter Server started at port:[1050]
TL1 Server started on 9099
This means that the Multi-Protocol agent has been successfully
started on RMI port 1099, SNMP port 8001, HTML port 8030, HTTP port
8050, CORBA port 1050, and TL1 port 9099.
To stop the Agent, use Ctrl + C, This would kill the application.
Now that the Agent is developed and started, the next step is to test the Multi-Protocol agent by sending SNMP, HTTP, TLI, RMI, CORBA & HTML requests using the respective protocols. To know how to perform Testing on the Multi-Protocol agent, please refer to Testing the Multi-Protocol agent section.
|