Solaris System Management Agent Developer's Guide

About Storing Module Data

You might want your module to store persistent data. Persistent data is information such as configuration settings that the module stores in a file and reads from that file. The data is preserved across restarts of the agent.

Modules can store tokens with assigned values in module-specific configuration files. A configuration file is created manually. Tokens can be written to the file or read from the file by a module. The module registers handlers that are associated with the module's specific configuration tokens.

Configuration Files

The snmp_config(4) man page discusses SNMP configuration files in general. The man page documents the locations where the files can be stored so the agent can find the files. These locations are on the default search path for SNMP configuration files.

For your modules, the best location to store configuration files is in a $HOME/.snmp directory, which is on the default search path. You can also set the SNMPCONFPATH environment variable if you want to use a non-default location for configuration files.

When you create your own configuration file, you must name the file module.conf or module.local.conf. You must place the file in one of the directories on the SNMP configuration file search path.


Note –

You might find that the Net-SNMP routines write your module's configuration file to the /var/sma_snmp directory. The routines make updates to that version of the file. However, the routines can find the configuration file in other locations when the module needs to initially read the file.


Defining New Configuration Tokens

Configuration tokens are used by modules to get persistent data during runtime. When your module uses custom configuration tokens, you should create one or more custom configuration files for the module. You might also choose to create one configuration file for several related modules. You can define new tokens in the custom configuration file.

Custom tokens must use the same format as the directives in snmpd.conf. One token is defined in each line of the configuration file. The configuration tokens are written in the form:

Token Value

For example, your token might be:


my_token 4

Modules should not define custom tokens in the SNMP configuration file, /etc/sma/snmp/snmpd.conf. If a module stores tokens in /etc/sma/snmp/snmpd.conf, namespace collisions can potentially occur. See Avoiding Namespace Collisions for more information about namespace collisions.