Reading through this section will help you start the Agent and the Shopping Cart application and work on it directly. To know how we developed the Agent and the Application please refer to the "Steps Involved in Developing the Application" section.
Running the Agent
Go to <Agent Toolkit Home>/reference/snmp/agent/bin directory from the command prompt.
Set the JAVA_HOME path.
Now execute run.bat/.sh file.
This will start the Agent at default port 8001.
Once the Agent is started, the Shopping Cart application UI also gets opened as follows :
Testing the Agent with Default Values
The Shopping Cart Agent can be tested using the MIB Browser application. This application creates a Manager environment. By querying from the Manager side, you will be acting as a Shopkeeper where you can add rows/delete rows and so on. Whereas by placing orders using the application you become the customer and you are restricted to place orders only on the available stock. To test the Agent using MIB Browser,
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 :
The tables can be queried by doing a GET / GET_NEXT / SET request. By default there will not be any entries and hence you will get "No data available in this tree" error. Follow the steps given to below to add entries through the application or through the MIB Browser and query the Table for it to respond with the values.
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.
Placing Orders for Pets
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.
Then, on querying the Table columns from the MIB Browser, the following results gets displayed :
PetName : Parrot
unit cost: $20
Quantity : 1
List Price :$20
The scalar group responds with totalItemCount as 1 and totalPrice as 20.
Even if values are set from the MIB Browser the Shopping cart application gets updated with the 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 screen shot 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.
Testing The Agent for Traps
For this Reference Implementation, the Agent has been configured such that it generates Traps when the stock level reaches 15 for any pet item. To test the same follow the steps given below. To know how Trap or Notification is implemented go through the steps mentioned in "Implemented SNMP Traps" section.
To view Traps from the Agent, follow the steps given below : -
Start the Agent from <Agent Toolkit Home>/reference/snmp/agent/bin directory using run.bat or run.sh file. Set the JAVA-HOME path in case it is not set.
The Agent gets started along with the Shopping Cart Application UI.
Start the MIB Browser application from <Agent Toolkit Home>/bin directory.
Load the Shopping Cart MIB in MIB Browser.
Also open the Trap Viewer in MIB Browser application. The Traps are listened at port 162 by default. Change the port settings to 8003 (Manager's Port) and click on Add in the Trap Viewer and Start listening for Traps.
Now go to the Shopping Cart Application and use Add button to place an order for16 Parrot items. You can also add 16 Parrot items from the Manager (MIB Browser) itself.
Whichever way the Pet item is added a Trap is generated and can be viewed in the Trap Viewer as below, as the inventory level has reached 15.
To know more on Testing, please refer to Testing the Agent section in Building SNMP Agents of Product Help documentation. Further chapters will discuss the implementation details of Scalar group and Tabular group.