As my table is "Read-Only" I can not use Snmpset !!!
I suppose to add a row and its value from the code it self 

-----Original Message-----
From: Katia S. [mailto:kat...@iit.demokritos.gr] 
Sent: 18 October 2012 14:28
To: Jatin Bodarya
Cc: net-snmp-coders@lists.sourceforge.net
Subject: Re: snmpwalk :No such Instance currently exist at this OID

It's me again.
Lets say that both this code and the subagent are working fine.
You are creating a table.
When initialized, the table is empty, so the 1.3.6.1.4.1.XXX.4.2.1 (index
= 1 therefore row = 1) does not exist (no rows in your table, thus a row
with index "1" should be inexistant as well).

Try the following:
1. First, add a row to your table. Example:
   snmpset -v 2c -c public localhost 1.3.6.1.4.1.XXX.4.2.1 i 1
   (This will create a new row with index 1 for you, since it does
    not already exist in your table, an give it an integer value of "1")

2. And now try to walk through the table to see if the same error occurs
   snmpwalk -v 2c -c public localhost 1.3.6.1.4.1.XXX.4.2.1

See how that goes..


> Below is my mib2c generated code.... while I m trying SNMPWALK on
>
> 1.3.6.1.4.1.XXX.4.2.1 it shows :: No such Instance currently exist at this
> OID
>
> Can anyone help me where it is going wrong ??
>
> Thanks in advance.
>
>
>
> /*
>
>  * Note: this file originally auto-generated by mib2c using
>
>  *  $
>
>  */
>
> #include <net-snmp/net-snmp-config.h>
>
> #include <net-snmp/net-snmp-includes.h>
>
> #include <net-snmp/agent/net-snmp-agent-includes.h>
>
> #include "pool.h"
>
>
>
> /** Initializes the pool module */
>
> void
>
> init_pool(void)
>
> {
>
>   /* here we initialize all the tables we're planning on supporting */
>
>     initialize_table_poolTable();
>
> }
>
>
>
>   //Determine the first/last column names
>
>
>
> /** Initialize the poolTable table by defining its contents and how it's
> structured */ void
>
> initialize_table_poolTable(void)
>
> {
>
>     const oid poolTable_oid[] = {1,3,6,1,4,1,XXX,4,2};
>
>     const size_t poolTable_oid_len   = OID_LENGTH(poolTable_oid);
>
>     netsnmp_handler_registration    *reg;
>
>     netsnmp_iterator_info           *iinfo;
>
>     netsnmp_table_registration_info *table_info;
>
>
>
>     DEBUGMSGTL(("pool:init", "initializing table poolTable\n"));
>
>
>
>     reg = netsnmp_create_handler_registration(
>
>               "poolTable",     poolTable_handler,
>
>               poolTable_oid, poolTable_oid_len,
>
>               HANDLER_CAN_RONLY
>
>               );
>
>
>
>     table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info );
>
>     netsnmp_table_helper_add_indexes(table_info,
>
>                            ASN_INTEGER,  /* index: ifIndex */
>
>                            0);
>
>     table_info->min_column = 1;
>
>     table_info->max_column = COLUMN_POOLINOCTETS;
>
>
>
>     iinfo = SNMP_MALLOC_TYPEDEF( netsnmp_iterator_info );
>
>     iinfo->get_first_data_point = poolTable_get_first_data_point;
>
>     iinfo->get_next_data_point  = poolTable_get_next_data_point;
>
>     iinfo->table_reginfo        = table_info;
>
>
>
>     netsnmp_register_table_iterator( reg, iinfo );
>
>
>
>     /* Initialise the contents of the table here */
>
>
>
> }
>
>
>
>     /* Typical data structure for a row entry */ struct poolTable_entry {
>
>     /* Index values */
>
>     long ifIndex;
>
>
>
>     /* Column values */
>
>     u_long poolInOctets;
>
>
>
>     /* Illustrate using a simple linked list */
>
>     int   valid;
>
>     struct poolTable_entry *next;
>
> };
>
>
>
> struct poolTable_entry  *poolTable_head;
>
>
>
> /* create a new row in the (unsorted) table */
>
>
>
>
>
> struct poolTable_entry *poolTable_createEntry(long  ifIndex) {
>
>
>
>         struct poolTable_entry *entry=poolTable_createEntry(1);
>
>         entry->poolInOctets(1)=42;
>
>
>
>         entry = SNMP_MALLOC_TYPEDEF(struct poolTable_entry);
>
>
>
>         if (!entry)
>
>         {
>
>                return NULL;
>
>         }
>
>
>
>         entry->ifIndex = ifIndex;
>
>         entry->next = poolTable_head;
>
>         poolTable_head = entry;
>
>         return entry;
>
> }
>
>
>
> /* remove a row from the table */
>
> void
>
> poolTable_removeEntry( struct poolTable_entry *entry ) {
>
>     struct poolTable_entry *ptr, *prev;
>
>
>
>     if (!entry)
>
>         return;    /* Nothing to remove */
>
>
>
>     for ( ptr  = poolTable_head, prev = NULL;
>
>           ptr != NULL;
>
>           prev = ptr, ptr = ptr->next ) {
>
>         if ( ptr == entry )
>
>             break;
>
>     }
>
>     if ( !ptr )
>
>         return;    /* Can't find it */
>
>
>
>     if ( prev == NULL )
>
>         poolTable_head = ptr->next;
>
>     else
>
>         prev->next = ptr->next;
>
>
>
>     SNMP_FREE( entry );   /* XXX - release any other internal resources */
>
> }
>
>
>
>
>
> /* Example iterator hook routines - using 'get_next' to do most of the
> work
> */ netsnmp_variable_list * poolTable_get_first_data_point(void
> **my_loop_context,
>
>                           void **my_data_context,
>
>                           netsnmp_variable_list *put_index_data,
>
>                           netsnmp_iterator_info *mydata) {
>
>     *my_loop_context = poolTable_head;
>
>     return poolTable_get_next_data_point(my_loop_context, my_data_context,
>
>                                     put_index_data,  mydata ); }
>
>
>
> netsnmp_variable_list *
>
> poolTable_get_next_data_point(void **my_loop_context,
>
>                           void **my_data_context,
>
>                           netsnmp_variable_list *put_index_data,
>
>                           netsnmp_iterator_info *mydata) {
>
>     struct poolTable_entry *entry = (struct poolTable_entry
> *)*my_loop_context;
>
>     netsnmp_variable_list *idx = put_index_data;
>
>
>
>     if ( entry ) {
>
>         snmp_set_var_typed_integer( idx, ASN_INTEGER, entry->ifIndex );
>
>         idx = idx->next_variable;
>
>         *my_data_context = (void *)entry;
>
>         *my_loop_context = (void *)entry->next;
>
>         return put_index_data;
>
>     } else {
>
>         return NULL;
>
>     }
>
> }
>
>
>
>
>
> /** handles requests for the poolTable table */ int poolTable_handler(
>
>     netsnmp_mib_handler               *handler,
>
>     netsnmp_handler_registration      *reginfo,
>
>     netsnmp_agent_request_info        *reqinfo,
>
>     netsnmp_request_info              *requests) {
>
>
>
>     netsnmp_request_info       *request;
>
>     netsnmp_table_request_info *table_info;
>
>     struct poolTable_entry          *table_entry;
>
>
>
>     DEBUGMSGTL(("pool:handler", "Processing request (%d)\n",
> reqinfo->mode));
>
>
>
>     switch (reqinfo->mode) {
>
>         /*
>
>          * Read-support (also covers GetNext requests)
>
>          */
>
>     case MODE_GET:
>
>         for (request=requests; request; request=request->next) {
>
>             table_entry = (struct poolTable_entry *)
>
>                               netsnmp_extract_iterator_context(request);
>
>             table_info  =     netsnmp_extract_table_info(      request);
>
>
>
>             switch (table_info->colnum) {
>
>             case COLUMN_POOLINOCTETS:
>
>                 if ( !table_entry ) {
>
>                     netsnmp_set_request_error(reqinfo, request,
>
>                                               SNMP_NOSUCHINSTANCE);
>
>                     continue;
>
>                 }
>
>                 snmp_set_var_typed_integer( request->requestvb,
> ASN_COUNTER,
>
>                                             table_entry->poolInOctets);
>
>                 break;
>
>             default:
>
>                 netsnmp_set_request_error(reqinfo, request,
>
>                                           SNMP_NOSUCHOBJECT);
>
>                 break;
>
>             }
>
>         }
>
>         break;
>
>     }
>
>     return SNMP_ERR_NOERROR;
>
> }
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct_______________________________________________
> Net-snmp-coders mailing list
> Net-snmp-coders@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
>


-- 
Katia Sarsempagieva

Research Associate
Media Networks Laboratory
Institute of Networks and Telecommunications
NCSR "Demokritos"



------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to