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 SNMP Agent for the existing Shopping Cart application.
WebNMS Agent Toolkit provides the tool "MIB Editor" for defining SMIv1/v2 mibs. The application can be started from the Agent Toolkit launcher or from <Agent Toolkit Home>/bin directory 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
Defining the "ShoppingCart" MIB Module
To define the Shopping Cart MIB Module the following steps need to be followed.
Start the MIB Editor 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.
Module name - ShoppingCartMibModule
ModuleDirectory - mibs\ (by default).
MIB Version - Choose SMIv2 for this case.
Root OID - enterprises (by default).
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,
Module Identity - zoho (this has to start in lower case letters)
Sub ID - The subid to be mentioned. Default value is 1.
Parent ID - Disabled.
Last-Updated - Disabled.
Organization - ZOHO Corp. Inc.,
Contact Info - email@example.com
Description - Reference Implementation
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 MIB Editor with WebNMS below the enterprises key. Thus a new mib module is created.
Now, to define an Object Identifier, choose "zoho" in the MIB tree and add a new node by selecting 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.
The Object Identifier name as "shoppingCartModule".
Make sure that the Parent node selected in the combo box is "zoho".
Also fill the Sub ID no as 571. (i.e shoppingCartModule has an unique node for the enterprise named "zoho")
Then Press Add To Module button present below. The added "shoppingCartModule" gets displayed under "zoho" 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 zoho) 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 :
Object Type - totalItemCount
Sub ID - 1
Parent - shoppingCartSummary.
Syntax - Integer32 (Select from the combo-box items).
Max-Access - read-only.
Status - Current.
Description - The total number of Pet items.
Reference - (optional)
Defval - Need not specify anything.
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 :
Object Type - shoppingCartTable
Sub ID - 2
Parent - shoppingCartModule
Max-Access - not-accessible
Status - current
Description - This Table contains information about the items purchased in the shopping cart. Use "..." button for adding the content.
Reference - Need not specify.
Click Add Table.
The Table gets listed in the right side frame itself.
Now to add the Table entry fill in the following details :
Object Type - shoppingCartEntry
Table - shoppingCartTable
Syntax - shoppingCartEntry
Max-Access - not-accessible
Status - current
Need not fill in Description, Reference and Index column.
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,
Object-Type - petName
Sub Id - 2.
Entry - shoppingCartEntry
Index - Check the Index box. Now this column acts as the index column for the whole Table.
Syntax - DisplayString.
Max access - Not Accessible
Status - current
Description, Reference, Default values are optional.
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 "3". 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 "4". 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 "5". 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 "6". 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,
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 MibEditor. 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.