This section of the tutorial deals with Starting the Agent and the Shopping Cart Application and testing the Agent using the Manager tools bundled with Agent Toolkit.
Starting the Agent and Application
Please follow the steps given below to run the Agent. This will also start the Shopping Cart Application.
Go to <Agent Toolkit Home>/reference/jmx/agent/bin directory from the command prompt.
Set the JAVA_HOME path in the run.bat/sh file
Now execute run.bat/.sh file.
Once the Agent is started, the Shoppping Cart application UI also gets opened.
The different adaptors gets started in Multi-Protocol agent at the default port numbers listed below:
SNMP Adaptor - 8001
RMI Adaptor - 1099
CORBA Adaptor - 1050
HTTP Adaptor - 8050
TL1 Adaptor - 9099
The Multi-Protocol agent is now running at the port numbers specified above. The Shopping cart application is started and you can find the UI of the Shopping Cart Application displayed, as shown below:
As seen in the above image, you will find the Item count which refers to the Total number of items ordered and the Total Price which refers to the total price of the items ordered. The UI will have all the details about the items sold and the rice of each item items. To order an item, click on the Add button which displays a Pop Up window with a Combo Box listing the Pets that are available in the shop. Specifying the Pet and the Quantity required , a row can be added. On adding a Item, the Item count and Total Price columns will get updated.
Say for example, you add an entry in the Shopping Cart application as follows and click OK,
The entry gets added as below in the UI.
Now in the Agent side, if you are going to do a query for the ShoppingCartTable in the ShoppingCartMib at any point of time, the value that is available in the Application will be received from the Agent. As this is a Multiprotocol Agent you can access the Agent or the Application which are coupled, by means of the supported protocols (SNMP, HTTP, RMI, CORBA, TL1, HTML).
SNMP Testing
The Shopping Cart Agent can be managed through SNMP Manager using the MIB Browser tool. This application creates a Manager environment.
Go to <Agent Toolkit Home>/bin directory and start the MIB Browser application using MibBrowser.bat/.sh file.
Load the ShoppingCartMib.mib from <Agent Toolkit Home>/mibs directory either using the Load MIB Module toolbar icon or File -> Load MIB menu bar.
A Load MIB Dialog opens up wherein you have to go to the URL using the Browse button. Various Load options are available. Let us leave them to be with the default settings.
Click OK and the MIB gets loaded.
Start querying the following groups :
ShoppingCartTable
shoppingCartSummary
The tables can be queried by doing a GET / GET_NEXT/SET request.
The Scalars can be queried with GET / GET-NEXT requests alone as they are read-only variables.
You can find the Agent responding with the values present in the shopping cart. For example, you add an entry using the Shopping Cart application UI for Pet Name "Parrot" and quantity ordered as 1.
On querying the Table columns from the MIB Browser, the following results gets displayed :
PetName : Parrot
Unit Price : $20
Quantity : 1
The scalar group responds with total Item Count as 1 and Price 20.
You can also add/modify/delete entries from the Manager (MIB browser ) . The UI application gets updated with these values.
Say, if the pet "dog" needs to be purchased, the ascii values of d-o-g has to be given as an instance in the MIB Browser object field and a Multivarbind request has to be sent to the Table column. This will add a row and the Shopping Cart Application UI also gets updated with these values. The screenshot given below depicts the scenario :
Even if the row is deleted or modified in the Shopping Cart Application , the values are removed/modified accordingly when queried from MIB Browser. This happens vice versa also.
On Updating a row (Modifying the Quantity of a Pet that is required) or adding a row (ordering one more Pet that is available in the Shop) or deleting a Pet requirement, through the Agent, you will find that the Application gets updated with the requests.
Thus, the Agent can be coupled easily with any of the Application data which in turn can be remotely accessed and managed. To know more about the UserStorageModel instrumentation part have a look at the Instrumenting Tables section. This will give you a clear idea about how to couple your Application and the Generated Agent.
To know more on Testing the Agent using MIB Browser, please refer to Testing the Agent section in Building SNMP Agents of Product Help documentation.
The Shopping Cart application can be managed through the RMI /CORBA/HTTP using MBean Browser.
Go to <Agent Toolkit Home>/bin directory and start the MBean Browser application using MBeanBrowser.bat/.sh file
Select "RMI Client" in the MBean browser and click Operations -> Connect. It gets connected to the Multi-Protocol agent using the RMI protocol. You can see the MBeans defined in the ShoppingCartMibModule listed in the left hand frame of the remote browser. The MBeans are listed under the domain name ShoppingCartAgent.
The following operations can be performed :
GET/SET Scalar Attributes
You can GET and SET scalar attribute values if the attribute is of type read-write. For read only attributes, you can only get the values. In the Shopping Cart application, the scalar attributes TotalItemcount and TotalPrice are read only attributes and hence their values cannot be modified. To access the Scalar attributes of the application,
Select Attributes for type=ShoppingCartSummaryInstrument. When this query is made, the Agent will fetch the value available with the application. You can also get the attribute values by selecting Operations for type=ShoppingCartSummaryInstrument.
GET Table values
Now, let us assume that we have ordered one quantity of each item using the Shopping Cart Application UI. On the Agent side, if you are going to do a query for the ShoppingCartTable at any point of time, the value that is available in the Application will be received from the Agent.
To access the table values, select Attributes for type=ShoppingCartTable. You will now find the values displayed as shown in the screen-shot below. You can also get the attribute values by selecting Operations for type=ShoppingCartTable.
Add / Modify / Delete Row
The customer can also place an order through the Manager application (MBean Browser) by adding an entry using the Add Row option . The Modify Row option can be used to modify an existing entry. The Delete Row option can be used to delete an existing item added by the user. These changes will get reflected in the ShoppingCartTable.
Similarly you can access the value available in the application and add entries by selecting CORBA/HTTP client from the Client Menu. For example, access the scalar attribute values TotalItemCount and TotalPrice using HTTP client. You will find the values displayed as shown in the screen-shot below:
The Shopping Cart application can be managed through the TL1 Adaptor using TL1 Browser.
Go to <Agent Toolkit Home>/bin directory and start the TL1 Browser application using TL1Browser.bat/.sh file . To test the agent using TL1Adaptor, follow the steps given below:
Load ShoppingCartMibModule.tcs file which is under the tcs directory by selecting File -> Load option . A dialog prompts for command set and data set file. Select the Add option to browse and select the ShoppingCartMibModule.tcs file and ShoppingCartMibModule.dat file from the<Agent Toolkit Home>/tcs directory. Click O.K to add it to the TL1 tree.
>Choose Operations -> Connect option in the Menu Bar. Enter the Host Name and Port Number where the agent is running in the dialog box that appears. Click OK. Now, you will be connected to the Agent.
The next step is to Authenticate into the TL1 Agent . To do this, load tl1security.tcs file as specified above from the <Agent Toolkit Home>/tcs directory to login to the TL1 Agent.
Select the command ACT-USER in the TL1 Security tree. The default user name and password for the Administrator are root and public respectively. Hence, select ACT-USER command and specify the user name as root in the AID block and the password (PID) public in the MPB block.
After entering the user name and password values send the input message by selecting the toolbar icon or by selecting Operations ->Send from the menu bar. Now, you will be authenticated into the TL1 Agent. The following autonomous message will be sent by the Agent to notify the completion of authentication.
Now, select ShoppingCartMibModule.tcs file and expand the tree . The following operations can be performed on the ShoppingCartAgent using TL1 Browser.
To query a table object "unitCost" of the "ShoppingCartTable" for a given PetName (index),
Select the object, SHOPPINGCARTMIBMODULE-ShoppingCartTable-unitCost from the Get Command of the TL1 tree. To find the unit Cost of Fish, specify the Index value as "Fish" in the Value field of the Message Payload block. Now, press the icon or choose the Operations -> Send from the menu bar. You will now find the index value added to the Input Message block.
The Agent sends a response message with the unit Cost of Fish as shown in the screen shot below.

Set Table Values
To send a set command for a table column object, "quantity"
of "ShoppingCartTable" for a given PetName (index),
Select the object, SHOPPINGCARTMIBMODULE-ShoppingCartTable-quantity
from the Set Command of the TL1 tree. To change the quantity of fish ordered,
specify the index value and the value to be set in the Value field of
the message payload block as shown in screen-shot below. Now, press the
send icon or choose the Operations -> Send from the menu bar.
You will now find the index value and the set value added to the InputMessage.
The Agent sends a response message with the set value as shown in the
screen shot below.

Get All rows from
the Table
Select the object SHOPPINGCARTMIBMODULE-ShoppingCartTable from the
GetALL Command of the TCS file . Now, press the send icon or choose the
Operations -> Send from the menu bar. The Agent sends a response
message with the values for all the rows of the table as is currently
available with the application, as shown in the screen-shot below :

Create
a new row
To create a new row in the ShoppingCartTable,
Select the table object, SHOPPINGCARTMIBMODULE-ShoppingCartTable under
the create command of the TL1 tree. In the message payload block, specify
the index value of the new row to be created , for example, "Parrot"
and the column values to be set in the new row separated by commas as
shown in the screen-shot below. Note : Here, we assume
that a row with index value "Parrot" does not already exist
in the table.
Press the send icon or choose the Operations -> Send from
the menu bar. You will now find the index value and the column values
added to the InputMessage as shown in the screen-shot below. The Agent
sends a response message for the new row created as seen in the response
block.
Delete
a row from the table
To delete an existing row, from the ShoppingCartTable,
Select the Table object, SHOPPINGCARTMIBMODULE-ShoppingCartTable under
the delete command of the TL1 tree.
In the message payload block, specify the index value of the table
row to be deleted , for example, Dog
Press the send icon or choose the Operations -> Send from
the menu bar. You will now find the index value of the row to be deleted
added to the Input Message block. The Agent sends a response message for
the deleted row as shown in the screen shot below. You can repeat this
operation for deleting any other row in the table by providing the correct
index value of the row to be deleted.
The Shopping Cart application can be tested through the HTML Adaptor using any Web Browser for example Netscape, IE etc.
Start the Browser and specify the URL as : http://localhost:8030. The HTTP Console Login page is displayed.
Specify the User name and password for authentication and select Login. The default User Name is jmx and password is root.
On successful authentication, the JSP Home page is displayed. It has a left side tree view in which all the MBeans are grouped under their respective domains. These are the domain names with which the MBeans are registered in the MBean server. Clicking a domain, the MBeans registered under this domain are listed in the left side tree.
Select a Domain name, for example ShoppingCartAgent. MBeans in the selected domain are listed in a separate page.
MBeans are grouped under different domains. Select the MBean whose attribute you want to view, for example ShoppingCartTableAttributes of tabular data type are displayed as a table .
The following operations can be performed :
Modify Row/Add Row/Delete Row :
To modify a row, select the check box of the corresponding row and modify the value. For example, in the ShoppingCartTable, modify the quantity of Parrot purchased from 1 to 2 and select the Save button. The new values will be saved as shown in the screen-shot below:
New rows can be added using the New Row button at the bottom of the page. The Delete button can be used to delete a row from the table.
Get Scalar Values
The attributes of the selected scalar MBeans ShoppingCartSummaryInstrument are listed in table format with the following information: Attribute name, Attribute type, Attribute access, Attribute value, and Attribute Description. Values of Read-Write attributes are presented in editable text field.
The JavaServer pages also allow you to perform operations on MBeans. If operations can be performed on an MBean, then the Operations button is displayed at the right-top corner of the the MBean attribute page. Clicking this button presents a page with the list of operations. Selecting an operations hyperlink displays the following information pertaining to the MBean operation:
Operation Name: The name of the MBean operation.
Description: Short description about the operation.
Apart from these, SET operations are provided with text fields to specify the attribute values. Further chapters will discuss the implementation details of Scalar group and Tabular group.