How to create a table for an agentx Client in C

David Goldberg <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Hello,

I am working on creating a system for monitoring temperature and
humidity in server rooms based on the raspberry pi.
I am using NET-SNMP to send the data over the network to various
monitoring tools.

My Question is how do I create rows and columns using pointers to a
variable?

I have this so far:

void
initialize_table_semsSensorTable(void)
{
    const oid semsSensorTable_oid[] = {1,3,6,1,4,1,40790,1,1,1,1};
    netsnmp_table_data_set *table_set;
    netsnmp_table_row *row;

    /* create the table structure itself */
    table_set = netsnmp_create_table_data_set("semsSensorTable");

    /* comment this out or delete if you don't support creation of new
rows */
    table_set->allow_creation = 1;

    /***************************************************
     * Adding indexes     */
    DEBUGMSGTL(("initialize_table_semsSensorTable",
                "adding indexes to table semsSensorTable\n"));
    netsnmp_table_set_add_indexes(table_set,
                           ASN_UNSIGNED,  /* index: semsSensorPortNbr */
                          0);
    DEBUGMSGTL(("initialize_table_semsSensorTable",
                "adding column types to table semsSensorTable\n"));         
    netsnmp_table_set_multi_add_default_row(table_set,
                                            COLUMN_SEMSSENSORPORTNBR,
ASN_UNSIGNED, 0,
                                            NULL, 0,
                                            COLUMN_SEMSSENSORSTAUTS,
ASN_INTEGER, 0,
                                            NULL, 0,
                                            COLUMN_SEMSSENSORTYPE,
ASN_INTEGER, 0,
                                            NULL, 0,
                                            COLUMN_SEMSSENSORDATA,
ASN_OCTET_STR, 0,
                                            NULL, 0,
                                            COLUMN_SEMSSENSORLOC,
ASN_OCTET_STR, 1,
                                            NULL, 0,
                              0);
   
    /* registering the table with the master agent */
    /* note: if you don't need a subhandler to deal with any aspects
       of the request, change semsSensorTable_handler to "NULL" */
   
netsnmp_register_table_data_set(netsnmp_create_handler_registration("semsSensorTable",
semsSensorTable_handler,
                                                        semsSensorTable_oid,
                                                       
OID_LENGTH(semsSensorTable_oid),
                                                        HANDLER_CAN_RWRITE),
                            table_set, NULL);
  
   for (indx = 0; indx < 8; indx++){
    sensorTable t = {0,0,0,NULL,NULL};
    t.port = indx+1;
        sensors[indx] = &t;
       row = netsnmp_create_table_data_row();
       netsnmp_table_row_add_index(row,ASN_UNSIGNED,&indx,sizeof(indx));
       netsnmp_set_row_column(row, 1,
ASN_INTEGER,&sensors[indx]->status,sizeof(sensors[indx]->status));
       netsnmp_mark_row_column_writable(row, 1, 0);        // make
writable via SETs
       netsnmp_table_dataset_add_row(table_set, row);
   }
   netsnmp_register_auto_data_table(table_set, NULL); 
}

>From what i Observed it reported that I had to many columns when I did:
snmptable -v 2c -m + -c sems.inforelay localhost SST-SEMS::semsSensorTable

The MIBS can be downloaded @
https://github.com/atmega168/SEMS/tree/master/mibs

I really appreciate any help I can get on this.

Regards,
David Goldberg




------------------------------------------------------------------------------
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_d2d_feb
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.