Solaris System Management Agent Developer's Guide

Registering New Instances in the Module

The demo_module_7 code example module registers context name strings that represent files. GET requests to these contexts retrieve the size of the file.

You do not need to edit the module to register new instances. The module can be dynamically updated to register new instances through the snmpset command. A management application passes the file name to the module by issuing an snmpset command, of the following format:


/usr/sfw/bin/snmpset -v 3 -u username -l authNoPriv -A "password" \
 hostname createContext_OID s "filename"

For example, the register_file script in the demo_module_7 directory issues a command that registers the file /usr/sfw sbin/snmpd as a new context name with the module:


/usr/sfw/bin/snmpset -v 3 -u myuser -l authNoPriv \
-A "mypassword" localhost .1.3.6.1.4.1.42.2.2.4.4.6.1.2.0 \
s "/usr/sfw/sbin/snmpd"

The module registers the set_createContext handler to handle incoming snmpset requests for the specified OID. The set_createContext handler registers the new file name as a context string in the contextName member of the netsnmp_registration_handler struct for the me1filesize_oid.

A management application can request the size of the file in blocks by issuing an snmpget command of the following format:


/usr/sfw/bin/snmpget -v 3 -u username -n contextname\
 -l authNoPriv -A "password" hostname me1filesize_oid

For example, the get_filesize script in the demo_module_7 directory issues a command that is similar to the following command:


/usr/sfw/bin/snmpget -m+SDK-DEMO6-MIB -v 3 -u myuser \
-n "/usr/sfw/sbin/snmpd" -l authNoPriv -A "mypassword" localhost \
.1.3.6.1.4.1.42.2.2.4.4.6.1.1.0