Hi Dave,

Thanks for your reply.

1-Thank you for your response concerning the "not-accessible", I have 
corrected it and mib2c is generating the structure correclty
2-Below is what I did:

#define XXX 2
#define YYY 3
#define NNN 256

void
initialize_table_methodTable(void)
{
    static oid      methodTable_oid[] =
        { 1, 3, 6, 1, 4, 1, 6736, 1, 22, 6 };
    size_t          methodTable_oid_len = OID_LENGTH(methodTable_oid);
    netsnmp_handler_registration *reg;
    netsnmp_tdata  *table_data;
    netsnmp_table_registration_info *table_info;

    reg =
        netsnmp_create_handler_registration("methodTable",
                                            methodTable_handler,
                                            methodTable_oid,
                                            methodTable_oid_len,
                                            HANDLER_CAN_RONLY);

    table_data = netsnmp_tdata_create_table("methodTable",0);
    table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
    netsnmp_table_helper_add_indexes(table_info, ASN_OCTET_STR, /* index: 
name */
                                     0);

    table_info->min_column = XXX;
    table_info->max_column = YYY;

    netsnmp_tdata_register(reg, table_data, table_info);

    /*
     * Initialise the contents of the table here
     */
     setVal(table_data);
}
/*
 * create a new row in the table
 */
netsnmp_tdata_row *
methodTable_createEntry(netsnmp_tdata * table_data, char *name,
                        size_t name_len)
{
    struct methodTable_entry *entry;
    netsnmp_tdata_row *row;

    entry = SNMP_MALLOC_TYPEDEF(struct methodTable_entry);
    if (!entry)
        return NULL;

    row = netsnmp_tdata_create_row();
    if (!row) {
        SNMP_FREE(entry);
        return NULL;
    }
    row->data = entry;
    memcpy(entry->name, name, name_len);
    entry->name_len = name_len;

    entry->profact_total=1;
    entry->profact_ok=1;

    netsnmp_tdata_row_add_index(row, ASN_OCTET_STR, entry->name, name_len);
    netsnmp_tdata_add_row(table_data, row);
    return row;
}

...
int setVal(netsnmp_tdata  *table_data)
{
 netsnmp_tdata_row *rowt;

 rowt=(netsnmp_tdata_row*)methodTable_createEntry(table_data,"sms",3);
}

This is what I am doing now for testing purposes and I am not able to see 
the output in snmpwalk
env MIBS=All snmpwalk -v 2c -c public localhost jpm
gave:
JINNY-JPM-MIB::profact-total.0 = Counter32: 0
JINNY-JPM-MIB::profact-ok.0 = Counter32: 0

I was hoping to see something like:
JINNY-JPM-MIB::name."sms"="sms"
JINNY-JPM-MIB::profact-total."sms"=1
JINNY-JPM-MIB::profact-ok."sms"=1

The values displayed by snmpwalk are only the static values generated by
mib2c -c mib2c.scalar.conf  jpm

Are the values for min_column  and max_column correct ?
Could they be the problem? Acutally I followed your suggestion based on an 
answer I found concerning min_colomn and max_colomn
(http://www.mail-archive.com/[email protected]/msg13621.html)
In fact when I set XXX to 3 I get the following:
env MIBS=All snmpwalk -v 2c -c public localhost jpm

JINNY-JPM-MIB::profact-total.0 = Counter32: 0
JINNY-JPM-MIB::profact-ok.0 = Counter32: 0
JINNY-JPM-MIB::profact-ok."sms" = Counter32: 0

But I know that this is wrong and actually the ouptut is not completrly 
correct since its missing the profact-total colomn

3-I need the non numetic OID since I am parsing the name and searching for 
it in the shared memory.
In v4 the input received from an snmp request is of form:
[Base OID].jpm.profact-ok
So i used to take the name "jpm.profact-ok" and search for it in the shared 
memory
In addition I had to add the following to my agentx subagent:
netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT, 
NETSNMP_OID_OUTPUT_UCD);
In order to receive the data as I mentioned above.
My question is where is the OID in order to search for it? Is it available.
I know i can construct the name from each function for simple based ex:

int
                handle_profact_total(netsnmp_mib_handler *handler,
      netsnmp_handler_registration *reginfo,
      netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests)
{
    /*
     * We are never called for a GETNEXT if it's registered as a
     * "instance", as it's "magically" handled for us.
     */

    /*
     * a instance handler also only hands us one request at a time, so
     * we don't need to loop over a list of requests; we'll only get one.
     */
I know here that the name is jpm.profact-total and I can search for it, but 
what would I do for the tables, where can I find the index in the snmp 
request?
If you can redirect me to the index in the table, that would be sufficient 
and I will used the solution that I mentioned above.

Thanks in advance

Regards,
Marwan

----- Original Message ----- 
From: "Dave Shield" <[email protected]>
To: "Marwan Khoury" <[email protected]>
Cc: <[email protected]>
Sent: Wednesday, September 02, 2009 3:40 PM
Subject: Re: CPU consumption


> 2009/8/31 Marwan Khoury <[email protected]>:
>> 1-Why did mib2c generate the following structure:
>
>   [snip]
>
>> what is the reason behind the existing of two field of value name and
>> name_len
>
> Index columns are meant to be marked as "not-accessible".
> The mib2c templates expect this to hold, so generate fields
> in the data structure for both all index values (which won't
> be accessible) and accessible column objects (which won't
> be index values).
>
> If your MIB is malformed, and has accessible column objects,
> then the data structure generated will also be sub-obtimal.
>
>
>> 2-How can I set the values of each colomn in a row?
>
>   [snip]
>
> That looks OK at first sight.
> Whenever you call 'methodTable_createEntry()'
> to create a row in the table, that should initialise
> the column values appropriately.
>
>
>> and the following command:
>>    env MIBS=All snmpwalk -v 2c -c public localhost jpm
>> gave:
>> JINNY-JPM-MIB::profact-total.0 = Counter32: 0
>> JINNY-JPM-MIB::profact-ok.0 = Counter32: 0
>
> You haven't said anything about how you are initialising
> the table, or what rows you are creating.
>
>
>
>> 3-My aim is to read the OID from the snmp request and fetch the value of 
>> it
>> from a shared memory, How can I extract the OID from the request in order 
>> to
>> print it as a string and search fro it in the shared memory?
>
> Your handler shouldn't be concerned with OIDs as such - but with
> the index values for a given row.   This is extracted for you by the
> table handler, and made available via the 'request' parameter.
>
> Please see existing MIB module code for examples.
>
>
>
> Dave


--------------------------------------------------------------------------------



No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.409 / Virus Database: 270.13.75/2340 - Release Date: 09/01/09 
20:03:00


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
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

Reply via email to