>> I used the NET-SNMP-EXAMPLES-MIB.txt mib file for generating a scalar
>> subagent.

>How did you create the MIB module code for this subagent?

I used "mib2c -c mib2c.scalar.conf" to generate the source files and then 
"net-snmp-config --compile-subagent" on the generated files to build the 
subagent.

>> There seems to be some problem in making data persistent.

>What code do you have for saving and restoring the value?

If you mean the MODE_SET_ACTION, then I'm just copying the new string to the 
variable that is used in MODE_GET.
Nothing else apart from this.

Is the sub-agent supposed to actually write the persistent data to the 
/var/net-snmp/*.conf file?

>> c>     kill and restart the subagent

>What command do you use to kill the subagent?

I used "kill -9 <pid>"

>> Any pointers on how I can make my subagent store this data in a persistent
>> manner?

>A little more detail about exactly what your current code looks like,
>might be helpful.

Here is the relevant code. All other cases are blank.

    switch (reqinfo->mode) {

    case MODE_GET:
        snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,
                                 (u_char *) newStr, strlen (newStr));
        break;
    case MODE_SET_RESERVE1:
        /*
         * or you could use netsnmp_check_vb_type_and_size instead
         */
        ret = netsnmp_check_vb_type(requests->requestvb, ASN_OCTET_STR);
        if (ret != SNMP_ERR_NOERROR) {
            netsnmp_set_request_error(reqinfo, requests, ret);
        }
        break;
    case MODE_SET_RESERVE2:
        /*
         * XXX malloc "undo" storage buffer
         */
        memdup ((u_char **) &newStr, (u_char *) requests->requestvb->val.string,
               strlen (requests->requestvb->val.string));

        if (newStr == NULL) {
            netsnmp_set_request_error(reqinfo, requests,
                                      SNMP_ERR_RESOURCEUNAVAILABLE);
            return SNMP_ERR_NOCREATION;
        }
        break;
    case MODE_SET_ACTION:
        /*
         * XXX: perform the value change here
         */
        strcpy(newStr, (void *)requests->requestvb->val.string);
        break;



>Dave

http://www.mindtree.com/email/disclaimer.html

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to