Solaris System Management Agent Developer's Guide

demo_module_12 Code Example for Solstice Enterprise Agents Subagent Migration

The demo_module_12 demonstrates how to implement a Solstice Enterprise Agents subagent as an SMA module.

The demo_module_12 code example is by default located in the directory /usr/demo/sma_snmp/demo_module_12. The README_demo_module_12 file within that directory contains instructions that describe how to perform the following tasks:

You should perform the procedures in demo_module_12 to produce the templates that are analyzed in the following section.

Analysis of the demo_module_12 Solstice Enterprise Agents Templates

The mibcodgen tool produced several files. The following table describes and analyzes the files.

Table 10–2 Comparison of Solstice Enterprise Agents Templates to SMA Templates

Template File Name 

Content 

Comparison to SMA Templates 

example_tree.c

Contains the type or storage definition for the MIB information. 

Only the OID and column definitions contained in this file are also used in templates generated by mib2c. The agent or AgentX frameworks handle the rest for you.

example_stub.h

Contains extern function definitions for all get, set, and free functions that implement the variables in the MIB.

For each SNMP group, mib2c generates an include file that defines externs for similar functions for both scalars and tables.

example_stub.c

Contains all get, set, and free functions that implement the scalar variables in the MIB.

For each SNMP group, mib2c generates a source code file. The file implements code for similar functions for the data types that the group contains, scalars, or tables.

mib2c also generates the registration code that is invoked at initialization time. The registration code makes the agent aware of the OIDs that are supported. The registration code also identifies the get and set functions.

example_rwTableEntry.c

Contains all get, set, and free functions that implement the column variables for rwTableEntry in the MIB.

An equivalent file, tableType.c in the example, is generated by mib2c with one of the table configuration options. The mib2c-generated file contains similar functions but uses very different index handling.

mibcodegen generates a get method that is passed a parameter to indicate whether to perform a get or getnext request.

With mib2c, however, the index handling is performed prior to invoking the get method to handle a getnext request. A get_first method is exposed to the SMA agent so that the agent can find the first item in a table. A get_next method handles getting the next row in the table. When the correct row is found, the get or set method is called with the column to manipulate. This process applies to getting the correct row for get, getnext, or set functions when the data is external to the agent. If the data is held by the SMA master agent, table registration involves populating the table. After the table is populated, requests to the table would be handled directly by the SMA master agent.

example_trap.c

Contains trap definitions. 

mib2c does not generate equivalent code. Traps can be generated by calling send_enterprise_trap_vars().

example_appl.c

Contains code to support subagent. 

mib2c does not generate equivalent code because such code is not needed. The SMA agent or AgentX framework handles the overhead and invokes the code through API functions.