Hello ALL,

I am trying to work on snmpget and snmpset on an simple MIB that i have
created.
The objective of my subagent will be -
I have a simple text file which will contain only one word (eg either
Postgres or MySQL).
Now from the agent's machine i have to run a snmpset command for this file
which will change the content of this text file.


The following is a part of my MIB named "CONFILE-MIB"



confileModules   OBJECT IDENTIFIER ::= { confileMIBObjects 1 }


confileServerName OBJECT-TYPE
    SYNTAX      DisplayString
    MAX-ACCESS  read-write
    STATUS      current
    DESCRIPTION
        "This is an object that simply supports a writable integer
         when compiled into the agent.  See
         http://www.net-snmp.org/tutorial-5/toolkit/XXX for further
         implementation details."

    ::= { confileModules 1 }





After creating this i have run the mib2c command for the above objetct

mib2c -c mib2c.scalar.conf confileServerName


This created the .c and .h files.


Now i edited the tempate .c file for MODEGET :

Here is a sample extract of it:


    switch (reqinfo->mode) {

    case MODE_GET:
parse_textfile(srv_name);   /*this function parses my text file*/
srv_name_len=strlen(srv_name);
printf("Server name:%s ",srv_name);
        snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,
                                 (u_char
*)srv_name,srv_name_len);

        break;




I commented remaining all cases and then i compiled it and run the subagent.
Queried the foolowing :
snmpget -v 2c -c democommunity localhost confileServerName.0

This gave me the correct o/p:
CONFILE-MIB::confileServerName.0 = STRING: Postgres



Now i need help in setting the instance value for the above object and this
should get reflected in my file.

The other cases of switch statement are as follows:


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
         */
        if ( /* XXX if malloc, or whatever, failed: */ ) {
            netsnmp_set_request_error(reqinfo, requests,
                                      SNMP_ERR_RESOURCEUNAVAILABLE);
        }
        break;

    case MODE_SET_FREE:
        /*
         * XXX: free resources allocated in RESERVE1 and/or
         * RESERVE2.  Something failed somewhere, and the states
         * below won't be called.
         */
        break;

    case MODE_SET_ACTION:
        /*
         * XXX: perform the value change here
         */
        if ( /* XXX: error? */ ) {
            netsnmp_set_request_error(reqinfo, requests, /* some error */
                                      );
        }
        break;

    case MODE_SET_COMMIT:
        /*
         * XXX: delete temporary storage
         */
        if ( /* XXX: error? */ ) {
            /*
             * try _really_really_ hard to never get to this point
             */
            netsnmp_set_request_error(reqinfo, requests,
                                      SNMP_ERR_COMMITFAILED);
        }
        break;

    case MODE_SET_UNDO:
        /*
         * XXX: UNDO and return to previous value for the object
         */
        if ( /* XXX: error? */ ) {
            /*
             * try _really_really_ hard to never get to this point
             */
            netsnmp_set_request_error(reqinfo, requests,
                                      SNMP_ERR_UNDOFAILED);
        }
        break;







Please tell me where do i make changes and what changes are to be made.






Thank's in advance
-- 
Hemant Soundankar
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to