1. Introduction to the System Management Agent
Choosing Dynamic Modules or Subagents
How to Dynamically Load a Module and Restart the Agent
How to Dynamically Load a Module Without Restarting the Agent
Deploying a Module as a Subagent
demo_module_8 Code Example for Implementing a Subagent
8. Long-Running Data Collection
10. Migration of Solstice Enterprise Agents to the System Management Agent
The simplest way to load modules dynamically is to restart the agent after you add entries to the configuration file. Dynamic loading is the best method to use while you are developing and testing a module. Most of the demonstration modules in /usr/demo/sma_snmp use dynamic loading. You should use the procedure How to Dynamically Load a Module and Restart the Agent during the development and testing phase.
When you are using the module in a production environment, that environment might require you not to restart the agent. If you want to load modules without restarting the agent, you should use the procedure How to Dynamically Load a Module Without Restarting the Agent.
You should keep your .so files in a directory that is writable by non-root users.
In the /etc/sma/snmp/snmpd.conf file, add a line that is similar to the following, where testmodule is the name of the module.
dlmod testmodule /home/username/snmp/lib/testmodule.so
# svcadm restart svc:/application/management/sma:default
The module should now be loaded. You can use snmpget and snmpset commands to access the module's data to confirm that the module is loaded. You should make sure your MIB can be located by the snmpget and snmpset commands by setting your MIBDIRS and MIBS environment variables, as described in Setting MIB Environment Variables.
Tip - To unload a module, you would remove the dlmod line from the snmpd.conf file and restart the agent.
The UCD-DLMOD-MIB provides MIB entries for the module name, path, and status. By setting these MIB entries, you can cause the agent to load or unload the module without restarting the agent.
Note - This procedure causes the module to be loaded only for the current session of the agent. If you want the module to be loaded each time the agent starts, you should add a dlmod line to the snmpd.conf file. The process of adding the line is described in Step 2 of the previous procedure. Do not restart the agent after adding the line.
Look for the DlmodEntry and dlmodStatus entries, which appear as follows:
DlmodEntry ::= SEQUENCE { dlmodIndex Integer32, dlmodName DisplayString, dlmodPath DisplayString, dlmodError DisplayString, dlmodStatus INTEGER } dlmodStatus OBJECT-TYPE SYNTAX INTEGER { loaded(1), unloaded(2), error(3), load(4), unload(5), create(6), delete(7) } MAX-ACCESS read-write STATUS current DESCRIPTION "The current status of the loaded module." ::= { dlmodEntry 5 }
DlmodEntry defines a row in a table of dynamically loaded modules. A table row describes an instance by defining an index, name, path, error code, and status code. You need to set the name, path, and status of the first empty row of the table.
$ /usr/sfw/bin/snmpget -v 1 -c public localhost UCD-DLMOD-MIB::dlmodStatus.1 Error in packet Reason: (noSuchName) There is no such variable name in this MIB. Failed object: UCD-DLMOD-MIB::dlmodStatus.1
This response indicates that no other dynamic module is defined as instance 1. If you get back a positive response, examine dlmodStatus.2 with the same command.
$ /usr/sfw/bin/snmpset -v 1 -c private localhost \ UCD-DLMOD-MIB::dlmodStatus.1 i create UCD-DLMOD-MIB::dlmodStatus.1 = INTEGER: create(6)
$ /usr/sfw/bin/snmpget -v 1 -c public localhost \ UCD-DLMOD-MIB::dlmodStatus.1 UCD-DLMOD-MIB::dlmodStatus.1 = INTEGER: unloaded(2)
The instance now exists, but the module is unloaded currently.
$ /usr/sfw/bin/snmpset -v 1 -c private localhost \ UCD-DLMOD-MIB::dlmodName.1 s "testmodule" \ UCD-DLMOD-MIB::dlmodPath.1 s "/home/username/lib/testmodule.so" UCD-DLMOD-MIB::dlmodName.1 = STRING: testmodule UCD-DLMOD-MIB::dlmodPath.1 = STRING: /home/username/lib/testmodule.so
testmodule is the name of your module.
$ /usr/sfw/bin/snmpset -v 1 -c private localhost \ UCD-DLMOD-MIB::dlmodStatus.1 i load UCD-DLMOD-MIB::dlmodStatus.1 = INTEGER: load(4)
This command sets the dlmodStatus.1 variable to load.
$ /usr/sfw/bin/snmpget -v 1 -c public localhost \ UCD-DLMOD-MIB::dlmodStatus.1 UCD-DLMOD-MIB::dlmodStatus.1 = INTEGER: loaded(1)
The response indicates that the module is loaded.
$ /usr/sfw/bin/snmpset -v 1 -c private localhost \ UCD-DLMOD-MIB::dlmodStatus.1 i unload UCD-DLMOD-MIB::dlmodStatus.1 = INTEGER: unload(5)
$ /usr/sfw/bin/snmpget -v 1 -c public localhost \ UCD-DLMOD-MIB::dlmodStatus.1 Timeout: No Response from localhost.
The lack of response from localhost indicates that the module is unloaded.