Hi All,

 

I have a table with two indexes.

But I do not need the second index for all columns.

Can we create a row with one index for some columns and two indexes for
other columns.

 

Here is my sample code..

 

void initialize_table_abcTable(void) {

 

static oid abcTable_oid[] = {1,3,6,1,4,1,11456,3,3};

                size_t abcTable_oid_len = OID_LENGTH(abcTable_oid);

                

netsnmp_table_data_set *table_set;

                netsnmp_table_row *row;

 

                table_set = netsnmp_create_table_data_set("abcTable");

 

                table_set->allow_creation = 1;

 

                netsnmp_table_set_add_indexes(table_set,

                           ASN_INTEGER,  /* index: index1 */

                           ASN_INTEGER,  /* index: index2 */ 0);

 

                netsnmp_table_set_multi_add_default_row(table_set,

                                           /* COLUMN_ABCINDEX, ASN_INTEGER,
0,

                                            NULL, 0,*/

                                            COLUMN_ABCVALUE, ASN_OCTET_STR,
0,

                                            NULL, 0,

                                            COLUMN_ABCSIZE, ASN_INTEGER, 0,

                                            NULL, 0,

                              0);

    

 
netsnmp_register_table_data_set(netsnmp_create_handler_registration("abcTabl
e", abcTable_handler,

                                                        abcTable_oid,

                                                        abcTable_oid_len,

                                                        HANDLER_CAN_RWRITE),

                            table_set, NULL);

 

int index1 = 1;

                int index2 = 1;

                int defaultValue = 101;

 

                for(index1 = 1; index1 < 6; index1 ++) {

        for(index2 = 1; index2 < 3; index2 ++) {

 

                                row = netsnmp_create_table_data_row();

 

                                netsnmp_table_row_add_index(row,
ASN_INTEGER, &index1 , sizeof(index1));

netsnmp_table_row_add_index(row, ASN_INTEGER, &index2 , sizeof(index2));

 

                                char temp[10];

                                char abcName[10] = "ABC-";

                                sprintf(temp, "%d", defaultValue);

                                strcat(abcName, temp);

 

                                netsnmp_set_row_column(row, COLUMN_ABCVALUE,
ASN_OCTET_STR, abcName, strlen(abcName));

                                netsnmp_mark_row_column_writable(row,
COLUMN_ABCVALUE, 1);

 

                                netsnmp_set_row_column(row, COLUMN_ABCSIZE,
ASN_INTEGER, (char*) &defaultValue, sizeof(defaultValue));

                                netsnmp_mark_row_column_writable(row,
COLUMN_ABCSIZE, 1);

 

                                netsnmp_table_dataset_add_row(table_set,
row);

        

                                defaultValue ++;

                        }

                }

}

 

I want to display on snmpwalk

 

ABC-MIB::abcValue.1 = STRING: "ABC-101"

ABC-MIB::abcValue.2 = STRING: "ABC-102"

ABC-MIB::abcValue.3 = STRING: "ABC-103"

ABC-MIB::abcValue.4 = STRING: "ABC-104"

ABC-MIB::abcValue.5 = STRING: "ABC-105"

ABC-MIB::abcSize.1.1 = INTEGER: 1011

ABC-MIB::abcSize.1.2 = INTEGER: 1012

ABC-MIB::abcSize.2.1 = INTEGER: 1012

ABC-MIB::abcSize.2.2 = INTEGER: 1022

ABC-MIB::abcSize.3.1 = INTEGER: 1013

ABC-MIB::abcSize.3.2 = INTEGER: 1023

ABC-MIB::abcSize.4.1 = INTEGER: 1014

ABC-MIB::abcSize.4.2 = INTEGER: 1024

ABC-MIB::abcSize.5.1 = INTEGER: 1015

ABC-MIB::abcSize.5.2 = INTEGER: 1025

 

Please help.

 

Regards,

 

Prakash Raju

 

------------------------------------------------------------------------------
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to