13.0 Implementing SNMP Proxy

 


13.1 Overview

13.2 SNMP Master Agent

13.3 SNMP Subagent

13.4 Creating a Master Agent

13.5 Creating a Subagent

13.6 Registering the Subagent to the Master Agent

13.7 Different Types of Master Subagent Relationship

13.8 Knowing the Status of the Subagent (Heart Beat Mechanism)

13.9 Sending Traps From Subagents Through the Master Agent.

13.10 Security in Proxy (Using SNMPv3)

13.11 Making WebNMS Agents as Subagents to Third Party Agents (Including OS Native Agents)

13.12 Running the Example


13.1 Overview

 

In original model of SNMP Management, it is a monolithic agent that used to carry out all the management responsibilities on a given network element (node). This solution was not flexible enough to provide an effective management of increasingly complex and distributed systems. In addition to the agents typically provided by computer manufacturers  for hardware and operating system information, agents are also produced  by other software vendors for SQL, Application servers, etc.

 

Also in distributed systems where different components of the product will be present in different network nodes (different IP address), each component needs its own management requirement for which each component will have an SNMP agent. However, there should be a single gateway for managing the entire product (distributed components).

 

This disadvantage of the original SNMP model, being unable to accommodate such complex and heterogeneous systems, is solved using Master - Subagent concept where the Master agent acts as a proxy for other SNMP agents. WebNMS Agent Toolkit  provides generic comprehensive Master Subagent architecture for making agents Subagent to Master agent on the fly. This dynamic behavior can be accomplished by the "Dynamic Registration concept in Master Subagent Architecture".

 

13.2 SNMP Master Agent

 

The Master agent is an entity or process on a managed node that exchanges SNMP messages with the Management applications such as WebNMS Web NMS, HP Openview, IBM Tivoli, etc.,. It acts as a primary interface between the Network Manager and Subagents.

 

13.3 SNMP Subagent

 

Subagents are processes that access the management information and provide manageability to various applications/components within a system. These Subagents interact with the Master agent using SNMP. They  do not interact with the Managers directly.

 

13.4 Creating Master Agent

 

All the agents generated using MIB Compiler can act as both Master agent and Subagent. By default, the generated agent acts as a standalone monolithic agent. Follow the steps given below to make the standalone agent, a Master agent.

 

Using MIB Compiler UI

Using API

 

To enable Proxy using API calls, add any one of the following piece of code to the Master agent's Main File before the code for populating entries for aclTable based on the registration.

 

    //For OID Based Proxy

    dyn = new DynamicRegistration(false, "conf", "ProxyTable.xml");

    dyn.addRegistrationListener(hdlr, true);

     

    //For Context Based Proxy

    dynCom = new DynamicRegistrationWithCommunity(false, "conf", "ProxyTable.xml");

    dynCom.addRegistrationListener(hdlr, true);

     

    //For Instance Based Proxy

    dynIns = new DynamicRegistrationWithInstance(false, "conf", "ProxyTable.xml");

    dynIns.addRegistrationListener(hdlr, true);

These API call implements Proxy. Please note that the api calls will work provided the variable declaration private DynamicRegistration dyn = null; / private DynamicRegistrationwithCommunity dynCom = null; / private DynamicRegistrationwithInstance dynIns = null; are included respectively (based on the type of registration) in the Main file where all declarations are present.

 

13.5 Creating Subagent

 

All the agents generated using MIB Compiler can act as both Master agent and Subagent. By default, the generated agent can directly act as Subagent. There is no specific option to make an agent act as a Subagent. Any SNMP agent can act as a Subagent.  The Subagent's host, port number details are to be registered in the Master agent for forwarding the requests to the exact Subagent. So, create a simple agent using a MIB (from which you prefer to access the details) and make it act as a Subagent.

 

13.6 Registering Subagents in the Master Agent

 

There are two ways to register Subagents in the Master agent. It can be done either : (1) Before Agent Startup or (2) During Run Time.

 

13.6.1 Before Agent Startup

 

By registering the Subagent to the Master agent before agent startup, the Subagent information is hard coded in the Java file. To register the Subagent before agent-start up you can use either the MIB Compiler UI or Text/XML Files or API calls.

 

Using MIB Compiler UI

Using Text / XML Files / Runtime Memory

 

Once the entries are added through MIB Compiler UI, the configurations are saved in a text or XML file namely ProxyTable.txt / .xml (for OID Based Proxy) under <Agent Toolkit Home>/snmpprojects/projectname/agent/bin/conf directory. To make use of this text file or xml file storage,

These files can be edited to add Manager entries. The ProxyTable.xml given below has been edited for adding a new Subagent entry with OID ".1.3.6.1.2.1.1" ; Manager Port : "8004".

Similarly, the text/xml files get generated for Context Based Proxy and Instance Based Proxy and they can be edited for adding new Subagent entries. Please note that the agent has to be restarted for the changes to take effect.

 

Run-Time Memory

 

Run-Time memory can be used to store the Manager information in the agent Memory . Using this option does not store the entries in text files or xml files. To use the run time memory for adding Manager entries dynamically, follow the instructions given below.

    1. Choose Project -> Settings menu from the menu bar of MIB Compiler UI.

    2. Select proxyTable from the Proxy Panel (can be any Proxy Table you prefer).

    3. Select Runtime Memory from the Storage Type.

    4. Add entries using the Add option.

After this, follow the steps given in adding entries From the Manager i.e During Runtime (13.6.2) . Please note that once the agent is killed, the added entries are removed from the memory.

 

Using API Calls

 

Add the following piece of code in the generated Main file of Master agent before the code for aclTable registration to register a Subagent entry. (OID Based Registration)

 

    dyn = new DynamicRegistration(false);

    Vector subAgentEntries = new Vector();

     

    com.adventnet.utils.agent.DynamicRegistrationEntry entry0 = dyn.createDynamicRegistrationEntry(".1.3.6.1.2.1","localhost",new Integer("161"),new Integer("2"),"public",new Long("4000"),new Long("0"));

    subAgentEntries.addElement(entry0);

     

    dyn.setTableVector(subAgentEntries);

    dyn.addRegistrationListener(hdlr, true);

Using this api method will also include Subagents to the Master agent. For Context Based Proxy and Instance Based Proxy the following api calls can be used

13.6.2 During Run Time

 

Subagents can also be registered in the Master agent during run time.

 

From the Manager

 

To add Subagent entries to the Master agent's Proxy Table from the Manager, follow the steps given below:

    1. Load AGENT-SNMP-CONFIG-MIB in the MIB Browser application.

    2. Select proxyTable (or whichever preferred Subagent table) from the subAgentTables module of agentConfiguration group.

    3. Selecting the respective table and clicking SNMP Table icon (View SNMP Table Data)in MIB Browser open up a wizard wherein entries can be added to the corresponding proxyTable.

    4. Click Add in that SNMP Table wizard. The corresponding columns of the Table are listed.

    5. Include the Subagent entries. The entries added from remote get updated in the text/XML file provided the storage option is selected.  

    6. Enable "Remote Configuration" option by selecting Proxy Panel of Project -> Settings menu in MIB Compiler UI or including any of the following API in the generated main method. Please note that it is possible to access the table from remote only if "Remote Configuration" is enabled.

By just including the below API for a particular type of Proxy in the initSnmpExtensionNodes() method in the generated main file, remote configuration of the respective Proxy Table is possible.

For OID Based Proxy


dyn = new DynamicRegistration(false, "conf", "ProxyTable.xml");
dyn.addRegistrationListener(hdlr, true);

For Context Based Proxy


dynCom.setTableVector(subAgentEntries);
dynCom.addRegistrationListener(hdlr, true);

For Instance Based Proxy


dynIns.setTableVector(subAgentEntries);
dynIns.addRegistrationListener(hdlr, true);

By making the argument as false [dynIns.addRegistrationListener(hdlr, false);], the facility of Remote configuration is disabled.

 

13.7 Different Types of Master - Subagent Relationship

 

Considering the design and the complexity of the distributed systems, it is very difficult to have just normal OID-based Master - Subagent relationship. This made us evolve the Master - Subagent relationship further and made us support different types of Master - Subagent relationship such as Context-based registration and Instance-based registration.

 

13.7.1 OID-based Registration

 

This is the normal registration where all Subagents implement different MIBs or different groups in the MIB. The proxyTable in AGENT-SNMP-CONFIG-MIB is used for this type of registration. Following are the columns present in the proxyTable :-

So, "Create a Master agent and a Subagent". To "Register Subagents in the Master Agent", please refer to the previous topic. With the explanation provided in "Registering Subagents" topic, you can add Subagent entries to the Proxy Table. Thus, General Master - Subagent feature is achieved. To test the same, please have a look at Running the Example, which explains the feature with an example.

 

13.7.2 Context-based Registration

 

This kind of registration helps in having more than one Subagent implementing the same MIB or a subtree in a MIB. In this case, the Master agent should have a criterion to identify the Subagent to forward the request. Community of the Subagent is made as the criteria. The contextBasedProxyTable in AGENT-SNMP-CONFIG-MIB stores the details of the Subagents. Following are the columns present in the contextBasedProxyTable :-

So, "Create a Master Agent and a Subagent". To "Register Subagents in the Master Agent", please refer to the previous topic. With the explanation provided in "Registering Subagents" topic, you can add Subagent entries to the Context-based Proxy Table. Thus, Context-based Master - Subagent feature is achieved. To test the same, please have a look at Running the Example , which explains the feature with an example.

 

13.7.3 Instance-based Registration

 

This kind of registration is used when the Subagents implement different rows of a table. The Master agent identifies the Subagent based on the instance value, present in the request received from the Manager, and forwards the request to the respective Subagent. The instanceBasedProxyTable in AGENT-SNMP-CONFIG-MIB stores the details of the Subagents. Following are the columns present in the instanceBasedproxyTable :-

So, "Create a Master Agent and a Subagent". To "Register Subagents in the Master Agent", please refer to the previous topic. With the explanation provided in "Registering Subagents" topic, you can add Subagent entries to the Instance-based Proxy Table. Thus, Instance-based Master - Subagent feature is achieved. To test the same, please have a look at Running the Example, which explains the feature with an example.

 

13.8 Knowing the Status of the Subagent (Heart Beat Mechanism)

 

As the name implies, Heart Beat Mechanism is helpful to determine the existence of a connection between Master - Subagent. This feature is implemented to constantly monitor the status of the Subagent and make it available to the Master agent.

By knowing the status, the Master agent does not forward the request to Subagents, which are not alive. Instead, the Master agent throws a 'general failure' error directly to the Manager.

 

13.8.1 Enabling Heart Beat Mechanism

 

Heart Beat mechanism can be enabled using MIB Compiler UI options or the API calls. To enable this feature in the Master agent,

 

Using MIB Compiler UI

Using API calls

 

Instead of the MIB Compiler UI options, the following API calls can be used for enabling Heart Beat Mechanism. Add the following piece of code in the initSnmpExtensionNodes method of the Master agent's generated Main file after the Dynamic Registration class instantiation to enable Heart Beat with the default values. For OID-based Proxy, add the following code.

    dyn.checkSubAgentHeartBeat(true, null, null, null, this);

Here, 'dyn' represents the instance of Dynamic Registration. This dyn varies according to the type of registration. For Instance-based and Context-based Proxy the code has to be as follows:

    dynIns.checkSubAgentHeartBeat(true, null, null, null, this);

    dynCom.checkSubAgentHeartBeat(true, null, null, null, this);

The Parameters true, null, null, null, this represents the following respectively.

Thus the code for Heartbeat is :

 

checkSubAgentHeartBeat (boolean toPoll, Long pollInterval, Integer timeOut, Integer retries, SnmpAgent agent);

 

To know how this Heart Beat functionality works refer to Running the Example section.

 

13.8.2 LinkUp and LinkDown Traps

 

Subagent's status is intimated to the Master agent through Heart Beat support. As per this support, the Row Status column of the proxyTable in the Master agent is updated frequently with NOT IN SERVICE and ACTIVE status. When the Subagent status is down, the Row Status column becomes NOT_IN_SERVICE and when it is up, the row status column becomes ACTIVE.

 

On becoming NOT_IN_SERVICE, a Link Down Trap can be generated and forwarded to the Managers by the Master agent. Similarly, a Link Up Trap can be generated when the status shifts to ACTIVE.

 

To know which Subagent is down or active, the Trap Details can be viewed. The Trap PDU contains the details of the Subagent Host and Port number and using these details Subagents can be identified by the Manager.

 

These Trap details can be viewed by loading the AGENT-SNMP-CONFIG-MIB in MIB Browser application and querying the related tables. The OID of the General Based Proxy linkUp and linkDown traps in the AGENT-SNMP-CONFIG-MIB are .1.3.6.1.4.1.2162.10.3.1.4.1 and .1.3.6.1.4.1.2162.10.3.1.4.2 respectively. The Managers to whom these traps should be sent are identified using the entries in Trap Forwarding Table.

 

13.9 Sending Traps From Subagent Through Master Agent

 

Subagents generate traps and send them through the Master agent to the Manager. Even though traps can be sent directly to the Manager from the Subagent, normally the traps are forwarded to the Master agent. The Master agent forwards them to the interested Managers. This is most applicable in the real time environment and the details of the Managers (to whom these traps should be sent) can be availed from the Trap Forwarding Table. For more information about the Trap Forwarding Table and configuring Managers in the Forwarding Table, refer to Traps section.

 

13.9.1 Filtering Traps Received  from Subagent Using Trap Filtering Table

 

To restrict the generation of certain traps to the manager, the Subagent specifies a condition wherein every Trap passes through that condition before it is forwarded to the Manager through the Master agent. Only if that condition is satisfied, the trap reaches the manager. Thus, filtering is done and if required by the Manager, traps are sent across or else they are dropped.

 

To filter and send traps through the Master agent, a Trap Filtering Table is maintained by Agent Toolkit in the Master agent. This Trap Filtering table maintains information of the Subagents registered with the Master agent (Proxy Table). The Subagent registrations in the Trap Filtering Table purely depends on your requirement. You can either include all the Subagent details present in the Master agent (proxyTable) or a particular set of Subagents from which you prefer to receive traps. This table can also be used even if Master Subagent concept is not used.

 

The Trap Filtering Table contains the following columns defined in it : -

13.9.2 Enabling Trap Filtering Table

 

You can enable Trap Filtering Table either by using MIB Compiler UI or by using API Calls.

 

Using MIB Compiler UI

    Note:

    • The TrapReceiverPort can be configured without enabling the Trap Filtering Table.

    • v1v2MangerPort implies the target port to which the traps are to be sent. In TrapForwardingTable of the master-subagent relationship, the above port in the Master Agent refers to the port where the MIB Browser listens for traps. In the case of a Sub-agent this should be the port where the Master agent listens for traps.

Using API calls

 

Alternatively, you can add the following piece of code in the Master agent Main file toward the end of initSnmpExtensionNodes() after the SnmpTrapService instantiation, to enable Trap Filtering Table support

    // This takes care of forwarding the traps from Sub agents received at the port 8005. They get generated by default if Proxy is enabled. IN case proxy entries are added using API calls, then this entry has to be added.

     

    SnmpTrapReceiverService trapReceiverService = new SnmpTrapReceiverService(8005 );

    trapReceiverService.addTrapRequestListener(trapListener);

     

    // For TrapFilteringTable.

    trapTableListener = new com.adventnet.snmp.snmp2.agent.TrapTableRequestHandler (this, false);

    trapTableListener.addRegistrationListener(hdlr);

    trapReceiverService.setAgentTableModel(trapTableListener.getAgentTableModel());

    }

The following declaration has to be included in the Main file where all Variable declarations are present. The API call will work only when this declaration is included.

 

private com.adventnet.snmp.snmp2.agent.TrapTableRequestHandler trapTableListener = null;

 

13.9.3 Adding Subagent Entries to Trap Filtering Table

 

Subagent entries can be added to the Table either : (1) Before Agent Startup or (2) During Run Time.

 

13.9.3.1 Before Agent Startup

 

To add Manager Entries at Agent Startup, either use MIB Compiler UI option or Text/XML File / Runtime Memory option or API calls.

 

Using MIB Compiler UI

Using Text / XML File/ Runtime Memory

 

Once the entries are added through MIB Compiler UI and code is generated, the configurations are saved in a text or xml file namely TrapFilteringTable.xml/txt under <Agent Toolkit Home>/snmpprojects/projectname/agent/bin/conf directory. To make use of this text file or XML file storage,

These files can be edited to add Manager entries. The TrapReceiverTable.xml given below has been edited for adding a new Subagent entry with agent Trap Port : "8004" and agentCommunity : "private".

    <?xml version="1.0" encoding="UTF-8"?>

    <Table>

    <row>

    <column name="agentHostType" value="IPv4" ></column>

    <column name="agentHost" value="127.0.0.1" ></column>

    <column name="agentTrapPortNumber" value="161" ></column>

    <column name="agentCommunity" value="public" ></column>

    <column name="agentStatus" value="1" ></column>

    </row>

     

    <row>

    <column name="agentHostType" value="IPv4" ></column>

    <column name="agentHost" value="127.0.0.1" ></column>

    <column name="agentTrapPortNumber" value="8004" ></column>

    <column name="agentCommunity" value="private" ></column>

    <column name="agentStatus" value="1" ></column>

    </row>

    </Table>

Please note that the agent has to be restarted for the changes to take effect.

 

Runtime Memory

 

Run-time memory can be used to store the Manager information in the agent Memory . Using this option does not store the entries in text files or XML files. To use the run-time memory for adding entries dynamically, follow the instructions given below:

After this, follow the steps given in adding entries From the Manager i.e During Runtime (13.9.3.2). Please note that once the agent is killed, the entries added are removed from the memory.

 

Using API Calls

 

Add the following piece of code in the generated Main file of Master agent after the code of Trap Table Listener instantiation i.e., above "trapTableListener.addRegistrationListener(hdlr);

    trapTableListener.createAndAddTrapFilteringEntry(new Integer(1), "127.0.0.1", 161, "public");

This will also add entries to the Trap Filtering Table.

 

13.9.3.2 During Run Time

 

From the Manager

 

To add Subagent entries to the Master agent's Trap Filtering Table from the Manager, follow the steps given below :

For better understanding on sending traps through Master agent please go through the example available in <Agent Toolkit Home>/examples/snmp/traps/trapthroughmasteragent directory. The information in readme.html will help you run the example.

 

13.10 Security in Proxy (Using SNMPv3)

 

WebNMS SNMP Agent also supports Proxy Concept in SNMPV3. Mostly, the Master and Subagents run in a private network and the Manager in a private network. So the only communication that takes place is between a Manager and the Master agent. Hence, the agents running in a private network may not require SNMP V3 as they would be well secured.

 

Having this in mind, WebNMS's implementation provides only v1/v2c support to Subagents. Even if the Manager sends a request of V3 type, the Master agent being a V3 agent would convert the V3 request to a V1/V2c Request and forward the PDU to the Subagents. The V1/V2c Response would be further converted to a V3 response and sent back to the Manager.

 

13.11 Making WebNMS Agents as Subagents to Third-Party Agents (including OS Native agents )

 

Because the Master - Subagent communication uses SNMP PDU, any agent that understands SNMP can be made as Subagent to WebNMS Master agent. Even the Native agents can be made as Subagent to WebNMS Master agent. WebNMS agents can also be made as Subagents to Third-Party agents / Native agents. This helps to derive the data of the OS you prefer. The supported OS by WebNMS are Windows, linux, and Solaris.

 

13.11.1 Configuring WebNMS Agent as Subagent to Solaris Agent

 

To make WebNMS agent as Subagent to Solaris agent,

13.11.2 Configuring WebNMS Agent as Subagent to Windows Agent Using apadll

 

To make WebNMS agent as Subagent to Windows agent,

13.11.2.1 Sending Traps Through Windows Master Agent

 

Trap generation support is also provided when the WebNMS agent is made to act as Windows Subagent. To avail Trap generation support here:

Setting the Properties of the SNMP Service

Stopping and Restarting the SNMP Service

             13.11.3  Configuring WebNMS Agent as Subagent to Linux Agent   

This proxy feature is supported by 4.2.1 and higher versions of UCD-SNMP. We support Redhat Linux 7.2 that provides 4.2.1 UCD SNMP. We also support Red Hat Linux Advanced Server release 2.1AS/i686 to enable this feature.  
 

13.11.4 MIB-II Support Using Native Agent as Subagent

 

All Operating Systems support MIB-II. Because our agent architecture support makes other third-party agents as Subagent to WebNMS Master agent, MIB-II support is not implemented. By making the Enterprise agent built using Agent Toolkit as Master agent and Native OS agent as Subagent, MIB-II support will be available through the Enterprise agent built using Agent Toolkit.

 

13.12 Running the Example

 

The example present under <Agent Toolkit Home>/examples/snmp/proxy directory will help you test the following functionalities.

Have a look at the readme.html for running the example.

 

 
 

Copyright © 2013, ZOHO Corp. All Rights Reserved.