As root, stop the agent if the agent is already running.
# svcadm disable -t svc:/application/management/sma:default |
Set up an SNMPv3 user.
For example, set up user name myuser with password mypassword as follows:
# $ /usr/sfw/bin/net-snmp-config --create-snmpv3-user myuser Enter authentication pass-phrase: mypassword Enter encryption pass-phrase: [press return to reuse the authentication pass-phrase] |
Edit the module to register context names that the module handles.
Find the init_module routine in the module. Add code to register context names that the module handles.
For example, you might add the following code:
void init_filesize(void) { // Declare the OID static oid filesize_oid[] = { 1,3,6,1,4,1,42,2,2,4,4,6,1,1,0 }; // Declare a registration handler netsnmp_handler_registration *myreg1; // Declare pointers to character arrays initialized // to the context name strings char *filexcon = "fileX"; char *fileycon = "fileY"; // Create a registration handler for the OID. // filesize is the name of handler. // get_filesize is the function to call when an SNMP // request for the OID is received, filesize_oid is the // OID for which the handler is registered, // OID_LENGTH(filesize_oid) passes the length of the // OID array to the agent. // HANDLER_CAN_RONLY is a constant that specifies that // this handler only handles get requests. myreg1 = netsnmp_create_handler_registration ("filesize", get_filesize, filesize_oid, OID_LENGTH(filesize_oid), HANDLER_CAN_RONLY); // Assign the string fileX to the contextName member of the // netsnmp_handler_registration struct myreg1->contextName=filexcon; // Register the netsnmp_handler_registration struct with the // agent. netsnmp_register_read_only is a helper function // that notifies the agent that this module only handles snmp // get requests. netsnmp_register_read_only_instance(myreg1); }