Based on the resources discussed in Application Notes, the MIB has to be defined. In this section, the steps involved in defining the MIB for the application is discussed. This will be the first step for developing a Multi-Protocol agent for the existing Shopping Cart application.
AdventNet Agent Toolkit provides the tool "MibEditor" for defining SMIv1/v2 mibs. The application can be started from the Agent Toolkit launcher or from <Agent Toolkit Home>/bindirectory using the MibEditor.bat or MibEditor.sh file.
We have defined a MIB module under which 3 groups exist. The basic work to land up with the "ShoppingCart" MIB module is :
Define the Shopping Cart MIB Module
Define the Scalar Group
Define the Tabular Group and
Define Notifications
|
|
Note:
|
Defining the "ShoppingCart" MIB Module
To define the Shopping Cart MIB Module the following steps need to be followed.
Start the MibEditor tool.
Select File -> Create Mib Module menu or toolbar icon to create the mib module.
A dialog box prompts asking to fill in the details of the mib. For this example, the following details have to be used.
Click OK.
The ShoppingCartMibModule gets added to the left side MIB Tree view with a module identity under enterprises.
Select moduleidentity and right click on it to enable Modify option.
Click Modify that enables the Module Identity tab where again details of the Mib Module has to be specified. The following values are specified,
Now click "SaveNode". Ignore Revision, Revision Description details. This is required when any changes are need to be made in the MIB and maintained later.
The ShoppingCartModule mib can be seen in the left side frame of the MibEditor with adventnet below the enterprises key. Thus a new mib module is created.
Operations -> Add Node from the menu bar (or) from the pop-up menu that appears on right click of the mouse (or) by clicking on the toolbar icon.
|
|
Note: As specified here, to add a new node any of the above said options can be used. These options are implied and hence can be used when you try to add a new node anywhere in the mib. |
Select Object Identifier and a tab gets displayed in the right frame.
Enter
Then Press Add To Module button present below. The added "shoppingCartModule" gets displayed under "adventnet" in the mib tree.
The next step is to define the 3 management objects under the Shopping Cart MIB module. To begin with, define the shoppingCartSummary group which has different scalars under it.
From the application resources explained in Application Notes section, you saw the "scalar" group information as totalItemCount and totalPrice. Hence a scalar group is defined in the MIB which contains scalar objects. (management objects which can hold only a single value).
Similar to the steps explained in the previous section (defining shoppingCartModule under adventnet) define an Object Identifier "shoppingCartSummary" under the shoppingCartModule node with id as "3" . The summary group gets created.
To add scalars under that group select "shoppingCartSummary" from the MIB tree in the left frame and right click on it. Use Add -> Scalar Object to add a scalar variable.
The MIB tree in the left frame gets deactivated and all the possible constructs (depending on whether the MIB file is v1 or v2) which can be added to the parent node gets activated in the wizard interface.
In the right side tab panel fill in the following details :
Then click on Add to Module button. The "totalItemCount" object gets added in the mib tree of left frame.
Similarly define the node "totalPrice" under the "shoppingCartSummary" node with id as 2. Now that the scalars are defined the next step would be define tables for the mib.
Steps involved in defining the table :-
Use Add- > Table Object construct to add the table shoppingCartTable under shoppingCartModule group.
The OBJECT TYPE Table construct opens up with the following columns in the right side tab. Fill in the required details :
Click Add Table.
The Table gets listed in the right side frame itself.
Now to add the Table entry fill in the following details :
Now Add Entry.
The ShoppingCartEntry gets listed below shoppingCartTable and the text-fields for adding column entries gets listed.
Just fill in the details as given below to add the first column petName,
Click "Add Column to Table".
The next column's Object-Type is "unitCost" . The syntax is "Integer32" with Max-Access "read-only" and Sub id "4". Index box need not be checked here. Finally, click Add Column to Table.
The next column's Object-Type is "quantity". The syntax is "Integer32" with Max-Access "read-write" and Sub id "5". Index box need not be checked here. Finally, click Add Column to Table.
The next column's Object-Type is "listPrice" . The syntax is "Integer32" with Max-Access "read-only" and Sub id "6". Index box need not be checked here. Finally, click Add Column to Table.
The next column's Object-Type is "rowStatus". The syntax is "Row Status" with Max-Access "read-write" and Sub id "7". Index box need not be checked here. Finally, click Add Column to Table.
The Add to Module gets activated only when an index column is present.
Since the petName column is already made as the index column, this gets enabled in the beginning itself. Now Press Add To Module button .
The Table gets added in the mib tree under "shoppingCartModule".
"out of Stock" Notification.
We have also defined a Notification group. Traps/Notifications are implemented in a manner such that Notifications get generated for a particular state of change in the Shopping Cart. The state of change can be an event happening in the application. Thus the notification implemented is,
outofStockNotification
As per our case, the SNMP Agent which we are trying to develop has to send Notifications to Managers when the following occurs :
Stock count reaches 15: The maximum inventory level is 20 for each item and when any of the pet item's stock reaches 15 a Notification is generated to the Managers stating that the stock level is reducing.
If this is the requirement, then we have to define a notification in the MIB (as it is of v2 type). It is very easy to define traps/notifications using MIB Editor. First, define the object group notification under the shoppingCartModule node with ID as 1.
Then, to define the Notification Type construct, select shoppingCartModule and right-click on it. Use Add -> Notification Type pop-up menu. The Notification Type construct tab gets enabled in the right.
The Notification Type is outofStockNotification
Sub ID is 1
Parent Node is shoppingCartModule
Status is current
The Objects are "petName and Quantity". This object can be chosen using the Browse option
Fill in the other details if required
Finally press "Add to Module" which adds the notification construct under shoppingCartModule
Thus the MIB is defined.