SNMP Subagent tutorial and Example

This example covers the basic use of the NET-SNMP Subagent in 6.0. When complete, you will have defined and created a snmpSubagent model and utilize all features from NET-SNMP. These programs include the master agent run on the server, snmpSubagent connecting to master agent; user can use snmp commands such as snmpget, snmpset, snmpwalk... to access to the agent.

Let's follow the steps below to create a snmpSubagent model and use it. The sample model is located in the examples/snmpSubagent/octrain_mib directory. We will learn how to create a such model. After that, we will compile this application (you should compile from source since not every line is shown in this tutorial) and run it.

Creating model

Create a Clovis project

The model after created look like

Importing MIB and modify the imported attributes: from menu Clovis > Import Mib Objects... Note that the mib file used in this example is located in examples/ComprehensiveExample/mib/clock.mib

Then click "Import". The Resource Editor looks like

Double click on any resource to see the objects definition. You can change some columns which are allowed to change such as Multiplicity, Initialized...

Open the Component Editor, clone all entities except node (sc this case) and cluster by selecting them, then press CTRL-C and CTRL-V. We'll have the cloned entities on the right

We'll change the attributes of the cloned entities

Add relationship from node (sc this case) to snmp_SU

Next, specify the path to the imported mib file by right-clicking at the snmpSubagent component > Sub Agent Properties...

Associate resource from alarm_clock component to the imported mib objects by right-clicking at the alarm_clock component > Associate Resources...

Create node instance for both alarm_clock and snmpSubagent and assign resources for alarm clock:

Now, you have created the model, next generate source codes from the model by clicking Project > Generate Source which will generate both clovis application code and snmp code from the imported mib file. Then build the model and make images.

Running

Deploy the image on a node and start it. After starting, the running model should look like

Now, you can access the mib objects by using snmp commands. Prior to being able to do it, you have to copy the imported mib file (clock.mib) to the share/snmp/mibs in safplus sandbox (image deployment directory) and export 2 environment variables:

You can see all the required mib files in the example:

Now, all is set. You can use snmp commmands, for example: