I'm trying to find if a row exists in a table.  If it doesn't exist, I will create it.  If it does exist, I need to modify a field in it.  The netsnmp examples I have followed show that when a row is created, all the fields (columns) are filled in before the add row call using netsnmp_set_row_column.  However, my application sets fields one at a time.  For example, if I have a table T1 with integer fields x,y,and z, my application will repeatedly call an agent function "set(table,index,field,value)" for every field.  This is the code snippet I use:

                row = netsnmp_create_table_data_row();
                netsnmp_table_row_add_index(row, ASN_INTEGER,&index,sizeof(index));
                netsnmp_set_row_column(row, field, ASN_INTEGER,(char*)&value,sizeof(value));

               //  add the row to the table
               pthread_mutex_lock(&snmp_objects_lock); //  might want to move this mutex to top of routine.

               //  table parameter indexes into object_char to get table.  Used to find the table to modify.
               netsnmp_table_dataset_add_row(snmp_objects[atoi(object_char)].the_table, row);
               netsnmp_register_auto_data_table(snmp_objects[atoi(object_char)].the_table,NULL);

               pthread_mutex_unlock(&snmp_objects_lock);


When the application calls this the first time, everything will work fine.  But, if a new field is being set for the same row (index), of course it fails because the row already exists. 

What I want to do is check if the row exists in the table. If so, I'll just read it, modify it (set field value), and replace it.  If it doesn't exist, then I will add it.  I tried to loop through the table getting a row at a time using netsnmp_table_data_set_get_first_row(the_table) and  netsnmp_table_data_set_get_next_row(the_table,row).  But, in the row returned I can't find the index for the life of me.  OID_Index always returns 1.

Any help or suggestions are greatly appreciated.

Thanks,

Mark


------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
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