5.0 Creating a Simple SNMP Agent using MIB Compiler

 


5.1 Overview
5.2 Creating a New Project
5.3 Loading the MIB in MIB Compiler
5.4 Generating Source Code for the MIB
5.5 Compiling the Generated Code
5.6 Starting and Stopping the Agent


 

5.1 Overview

 

This section will help you develop a simple SNMP agent using WebNMS Agent Toolkit. The basic operations that need to be performed for developing an SNMP Agent are: -

  1. Define MIBs using MIB Editor. To know how to define a MIB, please refer Defining a MIB section . It is not necessary that MIBs should be defined using MIB Editor. If MIBs are defined already, they can also be used.

  2. Create a project and generate source code for the defined MIB using MIB Compiler.

  3. Compile the generated code

  4. Instrument the agent stub files and

  5. Start the agent.

5.2 Creating a New Project

 

The first step towards creating an agent is Creating a Project for the agent. To create a project in MIB Compiler,

5.3 Loading the MIB in MIB Compiler

 

Now that a project is created, you will have to load the MIB for which the agent has to be created. To load a MIB in the Compiler,

5.4 Generating Source Code for the MIB

 

Source files can be generated either from MIB compiler or using commandline options. The MIB Compiler generates source files by reading the loaded MIB file. Bulk of effort involved in developing an agent is complete with the generation of source files.

 

The agent to be developed can be of v1, v2c, or v3 type. The Project -> Settings option in the menu bar can be used to configure the settings for an agent. By default, the version of the agent is v3.

 

From MIB Compiler UI

 

To generate source code for a given MIB,

From CommandLine Tool

 

Agent Toolkit provides command line options for code generation. This feature is not designed to be used as a standalone utility but intended to add command line control to GUI-assisted agent development process. The project file serves as the input.

 

Location of Commandline Utilities

 

The script files responsible for invoking the Command Line Utilities are available under <ATKT_Home>/bin directory where <ATKT_Home> is the working directory of Command Line Utility. The relevant script files are generated under the working directory as SnmpAgentSourceGen.bat / SnmpAgentSourceGen.sh files.

 

Operating the Commandline Utilities

 

To accomplish the command line source generation, the following command has to be executed.

 

//Syntax of the Command in Windows Operating Environment

ATKT_Home\bin\XXXAgentSourceGen.bat -x <Project file location>

 

//Syntax of the Command in Linux/Solaris Operating Environment

sh ATKT_Home\bin\XXXAgentSourceGen.sh -x<Project file location>

 

//A typical input will look like this:

ATKT_Home\bin\SnmpAgentSourceGen -x C:\WebNMS\JavaAgent\snmpprojects\TestProject\TestProject.prj

 

 

5.5 Compiling the Generated Code

 

The MIB Compiler generates a set of source files for each MIB file. Some of the source or stub files need to be instrumented to include the desired function. This section is explained with the notion of developing a simple agent with the default values. Hence the instrumentation part is not covered here. To know more on the same, refer Instrumenting the generated code of a MIB section.

 

The next step is to compile the generated code to form a complete agent. The agent can be compiled either from MIB Compiler UI or from Command line. For compiling the code,

 

From MIB Compiler UI

From Commandline

5.6 Starting and Stopping the Agent

 

Once the agent is developed, it can be started from MIB Compiler UI or from commandline.

 

From MIB Compiler UI

From Commandline

Now that the agent is developed and started, the next step is to test the agent by sending SNMP requests. To know how to perform Testing on the Agent, please refer to Testing the Agent section.

 

 

Copyright © 2013, ZOHO Corp. All Rights Reserved.